From e05626d0480681a07dc8a811e1c47396aa346329 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 17 Jun 2024 09:33:01 -0700 Subject: [PATCH 001/523] Add type for Authenticated user --- web-api/src/middleware/apiGatewayHelper.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/web-api/src/middleware/apiGatewayHelper.ts b/web-api/src/middleware/apiGatewayHelper.ts index a4a720152d4..033bccfbebc 100644 --- a/web-api/src/middleware/apiGatewayHelper.ts +++ b/web-api/src/middleware/apiGatewayHelper.ts @@ -8,6 +8,13 @@ import { headerOverride } from '../lambdaWrapper'; import { pick } from 'lodash'; import jwt from 'jsonwebtoken'; +export type AuthUser = { + role: string; + userId: string; + email: string; + name: string; +}; + /** * invokes the param fun and returns a lambda specific object containing error messages and status codes depending on any caught exceptions (or none) * @@ -168,13 +175,7 @@ export const getAuthHeader = event => { } }; -/** - * extracts and decodes the JWT token from the gateway response event's header / query string and returns the decoded user object - * - * @param {object} event the api gateway request event - * @returns {object} the user decoded from the JWT token - */ -export const getUserFromAuthHeader = event => { +export const getUserFromAuthHeader = (event): AuthUser | null => { const token = getAuthHeader(event); if (!token) return null; const decoded = jwt.decode(token); From 7eb022c5da69dccb581e84d01447357331dfa146 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 17 Jun 2024 10:02:51 -0700 Subject: [PATCH 002/523] devex: Remove passing in of empty user. If you want a user get it from the auth header or leave it as undefined --- todo_deleteme.md | 16 +++++++++++++ web-api/src/genericHandler.ts | 11 +++++++-- .../cases/checkForReadyForTrialCasesLambda.ts | 16 ++++--------- .../sendMaintenanceNotificationsLambda.ts | 1 - .../lambdas/notifications/disconnectLambda.ts | 2 +- .../public-api/casePublicSearchLambda.ts | 18 ++++++-------- .../generatePublicDocketRecordPdfLambda.ts | 2 +- .../getCaseForPublicDocketSearchLambda.ts | 18 ++++++-------- .../public-api/getPublicCaseExistsLambda.ts | 15 +++++------- .../lambdas/public-api/getPublicCaseLambda.ts | 15 +++++------- .../getPublicDocumentDownloadUrlLambda.ts | 20 +++++++--------- .../public-api/getPublicJudgesLambda.ts | 14 ++++------- .../public-api/opinionPublicSearchLambda.ts | 24 ++++++++----------- .../public-api/orderPublicSearchLambda.ts | 18 ++++++-------- .../public-api/todaysOpinionsLambda.ts | 14 ++++------- .../lambdas/public-api/todaysOrdersLambda.ts | 14 ++++------- 16 files changed, 98 insertions(+), 120 deletions(-) create mode 100644 todo_deleteme.md diff --git a/todo_deleteme.md b/todo_deleteme.md new file mode 100644 index 00000000000..76d621add79 --- /dev/null +++ b/todo_deleteme.md @@ -0,0 +1,16 @@ +# To do +- Understand if there was any reason to default user to empty object on these interactors + - web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts + - web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts + - web-api/src/lambdas/notifications/disconnectLambda.ts + - web-api/src/lambdas/public-api/casePublicSearchLambda.ts + - web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts + - web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts + - web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts + - web-api/src/lambdas/public-api/getPublicCaseLambda.ts + - web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts + - web-api/src/lambdas/public-api/getPublicJudgesLambda.ts + - web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts + - web-api/src/lambdas/public-api/orderPublicSearchLambda.ts + - web-api/src/lambdas/public-api/todaysOpinionsLambda.ts + - web-api/src/lambdas/public-api/todaysOrdersLambda.ts \ No newline at end of file diff --git a/web-api/src/genericHandler.ts b/web-api/src/genericHandler.ts index f66fe987cd7..03c87cb37c2 100644 --- a/web-api/src/genericHandler.ts +++ b/web-api/src/genericHandler.ts @@ -57,9 +57,16 @@ export const checkMaintenanceMode = async ({ applicationContext }) => { * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const genericHandler = (awsEvent, cb, options = {}) => { +export const genericHandler = ( + awsEvent, + cb, + options: { + bypassMaintenanceCheck?: boolean; + logResults?: boolean; + } = {}, +) => { return handle(awsEvent, async () => { - const user = options.user || getUserFromAuthHeader(awsEvent); + const user = getUserFromAuthHeader(awsEvent); const clientConnectionId = getConnectionIdFromEvent(awsEvent); const applicationContext = options.applicationContext || diff --git a/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts b/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts index 5be6f04f441..4f2d5831d4c 100644 --- a/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts +++ b/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts @@ -7,14 +7,8 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const checkForReadyForTrialCasesLambda = event => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .checkForReadyForTrialCasesInteractor(applicationContext); - }, - { - user: {}, - }, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .checkForReadyForTrialCasesInteractor(applicationContext); + }); diff --git a/web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts b/web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts index ab7997d0a63..d35088e6cc0 100644 --- a/web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts +++ b/web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts @@ -18,6 +18,5 @@ export const sendMaintenanceNotificationsLambda = event => }, { bypassMaintenanceCheck: true, - user: {}, }, ); diff --git a/web-api/src/lambdas/notifications/disconnectLambda.ts b/web-api/src/lambdas/notifications/disconnectLambda.ts index ebac451a2ad..f46a5ff8540 100644 --- a/web-api/src/lambdas/notifications/disconnectLambda.ts +++ b/web-api/src/lambdas/notifications/disconnectLambda.ts @@ -24,5 +24,5 @@ export const disconnectLambda = event => return results; }, - { bypassMaintenanceCheck: true, user: {} }, + { bypassMaintenanceCheck: true }, ); diff --git a/web-api/src/lambdas/public-api/casePublicSearchLambda.ts b/web-api/src/lambdas/public-api/casePublicSearchLambda.ts index 32435145b1f..c95701d4f58 100644 --- a/web-api/src/lambdas/public-api/casePublicSearchLambda.ts +++ b/web-api/src/lambdas/public-api/casePublicSearchLambda.ts @@ -7,14 +7,10 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const casePublicSearchLambda = event => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .casePublicSearchInteractor(applicationContext, { - ...event.queryStringParameters, - }); - }, - { user: {} }, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .casePublicSearchInteractor(applicationContext, { + ...event.queryStringParameters, + }); + }); diff --git a/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts b/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts index f729e26256c..3a35d56f3af 100644 --- a/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts +++ b/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts @@ -17,5 +17,5 @@ export const generatePublicDocketRecordPdfLambda = event => includePartyDetail: false, }); }, - { logResults: false, user: {} }, + { logResults: false }, ); diff --git a/web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts b/web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts index 5afffc3681b..9d2a6ac5782 100644 --- a/web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts +++ b/web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts @@ -7,14 +7,10 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getCaseForPublicDocketSearchLambda = event => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCaseForPublicDocketSearchInteractor(applicationContext, { - docketNumber: event.pathParameters.docketNumber, - }); - }, - { user: {} }, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getCaseForPublicDocketSearchInteractor(applicationContext, { + docketNumber: event.pathParameters.docketNumber, + }); + }); diff --git a/web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts b/web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts index 2cf2366762b..d2d7fa432f3 100644 --- a/web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts +++ b/web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts @@ -7,13 +7,10 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getPublicCaseExistsLambda = event => - genericHandler( - event, - ({ applicationContext }) => - applicationContext - .getUseCases() - .getCaseExistsInteractor(applicationContext, { - docketNumber: event.pathParameters.docketNumber, - }), - { user: {} }, + genericHandler(event, ({ applicationContext }) => + applicationContext + .getUseCases() + .getCaseExistsInteractor(applicationContext, { + docketNumber: event.pathParameters.docketNumber, + }), ); diff --git a/web-api/src/lambdas/public-api/getPublicCaseLambda.ts b/web-api/src/lambdas/public-api/getPublicCaseLambda.ts index cad8bb4bbd0..ff70c6981bd 100644 --- a/web-api/src/lambdas/public-api/getPublicCaseLambda.ts +++ b/web-api/src/lambdas/public-api/getPublicCaseLambda.ts @@ -7,13 +7,10 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getPublicCaseLambda = event => - genericHandler( - event, - ({ applicationContext }) => - applicationContext - .getUseCases() - .getPublicCaseInteractor(applicationContext, { - docketNumber: event.pathParameters.docketNumber, - }), - { user: {} }, + genericHandler(event, ({ applicationContext }) => + applicationContext + .getUseCases() + .getPublicCaseInteractor(applicationContext, { + docketNumber: event.pathParameters.docketNumber, + }), ); diff --git a/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts index 6b3eec57304..e3738e20a22 100644 --- a/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts @@ -7,15 +7,11 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getPublicDocumentDownloadUrlLambda = event => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getPublicDownloadPolicyUrlInteractor(applicationContext, { - ...event.pathParameters, - isTerminalUser: event.isTerminalUser, - }); - }, - { user: {} }, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getPublicDownloadPolicyUrlInteractor(applicationContext, { + ...event.pathParameters, + isTerminalUser: event.isTerminalUser, + }); + }); diff --git a/web-api/src/lambdas/public-api/getPublicJudgesLambda.ts b/web-api/src/lambdas/public-api/getPublicJudgesLambda.ts index dad085fb4d6..c7af98b5c7b 100644 --- a/web-api/src/lambdas/public-api/getPublicJudgesLambda.ts +++ b/web-api/src/lambdas/public-api/getPublicJudgesLambda.ts @@ -7,13 +7,9 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getPublicJudgesLambda = event => { - return genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getJudgesForPublicSearchInteractor(applicationContext); - }, - { user: {} }, - ); + return genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getJudgesForPublicSearchInteractor(applicationContext); + }); }; diff --git a/web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts b/web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts index 73d371ec12a..043895b2a3c 100644 --- a/web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts +++ b/web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts @@ -7,18 +7,14 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const opinionPublicSearchLambda = event => - genericHandler( - event, - async ({ applicationContext }) => { - const opinionTypes = - event.queryStringParameters.opinionTypes?.split(',') || []; + genericHandler(event, async ({ applicationContext }) => { + const opinionTypes = + event.queryStringParameters.opinionTypes?.split(',') || []; - return await applicationContext - .getUseCases() - .opinionPublicSearchInteractor(applicationContext, { - ...event.queryStringParameters, - opinionTypes, - }); - }, - { user: {} }, - ); + return await applicationContext + .getUseCases() + .opinionPublicSearchInteractor(applicationContext, { + ...event.queryStringParameters, + opinionTypes, + }); + }); diff --git a/web-api/src/lambdas/public-api/orderPublicSearchLambda.ts b/web-api/src/lambdas/public-api/orderPublicSearchLambda.ts index 66e10f89cc0..32c5983e3a6 100644 --- a/web-api/src/lambdas/public-api/orderPublicSearchLambda.ts +++ b/web-api/src/lambdas/public-api/orderPublicSearchLambda.ts @@ -7,14 +7,10 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const orderPublicSearchLambda = event => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .orderPublicSearchInteractor(applicationContext, { - ...event.queryStringParameters, - }); - }, - { user: {} }, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .orderPublicSearchInteractor(applicationContext, { + ...event.queryStringParameters, + }); + }); diff --git a/web-api/src/lambdas/public-api/todaysOpinionsLambda.ts b/web-api/src/lambdas/public-api/todaysOpinionsLambda.ts index f5c5f32004f..5b861f4b5d3 100644 --- a/web-api/src/lambdas/public-api/todaysOpinionsLambda.ts +++ b/web-api/src/lambdas/public-api/todaysOpinionsLambda.ts @@ -7,12 +7,8 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const todaysOpinionsLambda = event => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getTodaysOpinionsInteractor(applicationContext); - }, - { user: {} }, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getTodaysOpinionsInteractor(applicationContext); + }); diff --git a/web-api/src/lambdas/public-api/todaysOrdersLambda.ts b/web-api/src/lambdas/public-api/todaysOrdersLambda.ts index 8d25b4dd136..aeb093d36a0 100644 --- a/web-api/src/lambdas/public-api/todaysOrdersLambda.ts +++ b/web-api/src/lambdas/public-api/todaysOrdersLambda.ts @@ -7,12 +7,8 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const todaysOrdersLambda = event => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getTodaysOrdersInteractor(applicationContext, event.pathParameters); - }, - { user: {} }, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getTodaysOrdersInteractor(applicationContext, event.pathParameters); + }); From 30a0d2ab0b0625e418504fdb0ee1b414efadddef Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 17 Jun 2024 10:03:40 -0700 Subject: [PATCH 003/523] devex: docs --- todo_deleteme.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/todo_deleteme.md b/todo_deleteme.md index 76d621add79..21397870702 100644 --- a/todo_deleteme.md +++ b/todo_deleteme.md @@ -1,16 +1 @@ # To do -- Understand if there was any reason to default user to empty object on these interactors - - web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts - - web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts - - web-api/src/lambdas/notifications/disconnectLambda.ts - - web-api/src/lambdas/public-api/casePublicSearchLambda.ts - - web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts - - web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts - - web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts - - web-api/src/lambdas/public-api/getPublicCaseLambda.ts - - web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts - - web-api/src/lambdas/public-api/getPublicJudgesLambda.ts - - web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts - - web-api/src/lambdas/public-api/orderPublicSearchLambda.ts - - web-api/src/lambdas/public-api/todaysOpinionsLambda.ts - - web-api/src/lambdas/public-api/todaysOrdersLambda.ts \ No newline at end of file From 3aecc37d74f70f3f2a0cf5c97bcd8f5670d53f53 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 17 Jun 2024 12:08:26 -0700 Subject: [PATCH 004/523] devex: pass the through all of the handlers rather than using global applicationContext --- web-api/src/genericHandler.ts | 16 ++++++------- web-api/src/lambdaWrapper.ts | 23 ++++++++++++------- .../reports/getCustomCaseReportLambda.ts | 4 +++- web-api/src/middleware/apiGatewayHelper.ts | 15 ++++++------ 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/web-api/src/genericHandler.ts b/web-api/src/genericHandler.ts index 03c87cb37c2..b411725cdd1 100644 --- a/web-api/src/genericHandler.ts +++ b/web-api/src/genericHandler.ts @@ -1,7 +1,10 @@ -import { createApplicationContext } from './applicationContext'; import { + ServerApplicationContext, + createApplicationContext, +} from './applicationContext'; +import { + UnknownAuthUser, getConnectionIdFromEvent, - getUserFromAuthHeader, handle, } from './middleware/apiGatewayHelper'; @@ -59,18 +62,16 @@ export const checkMaintenanceMode = async ({ applicationContext }) => { export const genericHandler = ( awsEvent, - cb, + cb: (appContext: { applicationContext: ServerApplicationContext }) => any, + user: UnknownAuthUser, options: { bypassMaintenanceCheck?: boolean; logResults?: boolean; } = {}, ) => { return handle(awsEvent, async () => { - const user = getUserFromAuthHeader(awsEvent); const clientConnectionId = getConnectionIdFromEvent(awsEvent); - const applicationContext = - options.applicationContext || - createApplicationContext(user, awsEvent.logger); + const applicationContext = createApplicationContext(user, awsEvent.logger); delete awsEvent.logger; @@ -89,7 +90,6 @@ export const genericHandler = ( const results = await cb({ applicationContext, clientConnectionId, - user, }); const returnResults = dataSecurityFilter(results, { diff --git a/web-api/src/lambdaWrapper.ts b/web-api/src/lambdaWrapper.ts index c916aaf8227..af65e80a652 100644 --- a/web-api/src/lambdaWrapper.ts +++ b/web-api/src/lambdaWrapper.ts @@ -1,6 +1,9 @@ +import { + UnknownAuthUser, + getUserFromAuthHeader, +} from '@web-api/middleware/apiGatewayHelper'; import { get } from 'lodash'; import { getCurrentInvoke } from '@vendia/serverless-express'; -import { getUserFromAuthHeader } from '@web-api/middleware/apiGatewayHelper'; export const headerOverride = { 'Access-Control-Expose-Headers': 'X-Terminal-User', @@ -19,7 +22,7 @@ const defaultOptions: { } = {}; export const lambdaWrapper = ( - lambda, + lambda: (awsEvent: Record, user: UnknownAuthUser) => any, options = defaultOptions, applicationContext?: IApplicationContext, ) => { @@ -45,23 +48,27 @@ export const lambdaWrapper = ( queryStringParameters: req.query, }; + const user = getUserFromAuthHeader(event); + if (shouldMimicApiGatewayAsyncEndpoint) { // we return immediately before we try running the lambda because that is how // the api gateway works with async endpoints. res.status(204).send(''); } - const response = await lambda({ - ...event, - body: JSON.stringify(req.body), - logger: req.locals.logger, - }); + const response = await lambda( + { + ...event, + body: JSON.stringify(req.body), + logger: req.locals.logger, + }, + user, + ); const { asyncsyncid } = req.headers; if (options.isAsyncSync && asyncsyncid && applicationContext) { try { - const user = getUserFromAuthHeader(event); const fullResponse = { ...response, body: response.body ? JSON.parse(response.body) : response.body, diff --git a/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts b/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts index e69b23eb7fe..58b2083fba8 100644 --- a/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts +++ b/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts @@ -1,11 +1,13 @@ +import { UnknownAuthUser } from '@web-api/middleware/apiGatewayHelper'; import { genericHandler } from '../../genericHandler'; -export const getCustomCaseReportLambda = event => +export const getCustomCaseReportLambda = (event, user: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() .getCustomCaseReportInteractor( applicationContext, event.queryStringParameters, + user, ); }); diff --git a/web-api/src/middleware/apiGatewayHelper.ts b/web-api/src/middleware/apiGatewayHelper.ts index 033bccfbebc..c9fc4a9b1f8 100644 --- a/web-api/src/middleware/apiGatewayHelper.ts +++ b/web-api/src/middleware/apiGatewayHelper.ts @@ -15,6 +15,8 @@ export type AuthUser = { name: string; }; +export type UnknownAuthUser = AuthUser | undefined; + /** * invokes the param fun and returns a lambda specific object containing error messages and status codes depending on any caught exceptions (or none) * @@ -175,9 +177,9 @@ export const getAuthHeader = event => { } }; -export const getUserFromAuthHeader = (event): AuthUser | null => { +export const getUserFromAuthHeader = (event): UnknownAuthUser => { const token = getAuthHeader(event); - if (!token) return null; + if (!token) return undefined; const decoded = jwt.decode(token); if (decoded) { decoded.token = token; @@ -186,7 +188,7 @@ export const getUserFromAuthHeader = (event): AuthUser | null => { decoded.name = decoded.name || decoded['custom:name']; // custom:name only exists locally. This is a workaround for cognito-local. return decoded; } else { - return null; + return undefined; } }; @@ -196,11 +198,8 @@ export const getUserFromAuthHeader = (event): AuthUser | null => { * @param {object} event the api gateway request event * @returns {string|void} the connectionId */ -export const getConnectionIdFromEvent = event => { - if ( - event.queryStringParameters && - event.queryStringParameters.clientConnectionId - ) { +export const getConnectionIdFromEvent = (event): string | undefined => { + if (event?.queryStringParameters?.clientConnectionId) { return event.queryStringParameters.clientConnectionId; } }; From 16158387a5e1622e61563e354096d2245a8e47d9 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 17 Jun 2024 13:06:05 -0700 Subject: [PATCH 005/523] devex: Create schema to help validate an authenticated user. --- .../authorizationClientService.ts | 8 ++++- .../src/business/entities/EntityConstants.ts | 3 +- .../business/entities/authUser/AuthUser.ts | 31 +++++++++++++++++++ .../getCustomCaseReportInteractor.ts | 5 +-- .../reports/getCustomCaseReportLambda.ts | 15 +++++---- web-api/src/middleware/apiGatewayHelper.ts | 10 +----- 6 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 shared/src/business/entities/authUser/AuthUser.ts diff --git a/shared/src/authorization/authorizationClientService.ts b/shared/src/authorization/authorizationClientService.ts index cca1c7b108d..776d21f3bdc 100644 --- a/shared/src/authorization/authorizationClientService.ts +++ b/shared/src/authorization/authorizationClientService.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; + export const ROLE_PERMISSIONS = { ADD_CASE_TO_TRIAL_SESSION: 'ADD_CASE_TO_TRIAL_SESSION', ADD_EDIT_JUDGE_USER: 'ADD_EDIT_JUDGE_USER', @@ -340,7 +342,11 @@ export const AUTHORIZATION_MAP = { * @param {string} owner the user id of the owner of the item to verify * @returns {boolean} true if user is authorized, false otherwise */ -export const isAuthorized = (user, action, owner?): boolean => { +export const isAuthorized = ( + user: UnknownAuthUser, + action, + owner?, +): boolean => { if (!user) { return false; } diff --git a/shared/src/business/entities/EntityConstants.ts b/shared/src/business/entities/EntityConstants.ts index 522cdf67dfc..b2cffc07091 100644 --- a/shared/src/business/entities/EntityConstants.ts +++ b/shared/src/business/entities/EntityConstants.ts @@ -1034,8 +1034,7 @@ export const ROLES = { reportersOffice: 'reportersOffice', trialClerk: 'trialclerk', } as const; -const ROLES_TYPES = Object.values(ROLES); -export type Role = (typeof ROLES_TYPES)[number]; +export type Role = (typeof ROLES)[keyof typeof ROLES]; // this isn't a real role someone can login with, which is why // it's a separate constant. diff --git a/shared/src/business/entities/authUser/AuthUser.ts b/shared/src/business/entities/authUser/AuthUser.ts new file mode 100644 index 00000000000..1170099063d --- /dev/null +++ b/shared/src/business/entities/authUser/AuthUser.ts @@ -0,0 +1,31 @@ +import { ROLES, Role } from '@shared/business/entities/EntityConstants'; +import joi from 'joi'; + +export type AuthUser = { + role: Role; + userId: string; + email: string; + name: string; +}; + +export type UnknownAuthUser = AuthUser | undefined; + +export function isAuthUser(user): user is AuthUser { + const authUserSchema = joi.object().keys({ + email: joi.string().min(1).max(100).email({ tlds: false }).required(), + name: joi.string().min(1).required(), + role: joi + .string() + .min(1) + .valid(...Object.values(ROLES)) + .required(), + userId: joi.string().min(1).uuid().required(), + }); + + const { error } = authUserSchema.validate(user); + if (error) { + throw error; + } + + return true; +} diff --git a/web-api/src/business/useCases/caseInventoryReport/getCustomCaseReportInteractor.ts b/web-api/src/business/useCases/caseInventoryReport/getCustomCaseReportInteractor.ts index 7aaed9892a8..4ea1d632d43 100644 --- a/web-api/src/business/useCases/caseInventoryReport/getCustomCaseReportInteractor.ts +++ b/web-api/src/business/useCases/caseInventoryReport/getCustomCaseReportInteractor.ts @@ -12,6 +12,7 @@ import { isAuthorized, } from '@shared/authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export type CustomCaseReportFilters = { caseStatuses: CaseStatus[]; @@ -59,9 +60,9 @@ export type CustomCaseReportSearchAfter = { export const getCustomCaseReportInteractor = async ( applicationContext: IApplicationContext, params: GetCustomCaseReportRequest, + user: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_INVENTORY_REPORT)) { + if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_INVENTORY_REPORT)) { throw new UnauthorizedError('Unauthorized for case inventory report'); } diff --git a/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts b/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts index 58b2083fba8..2cdf3d89dcb 100644 --- a/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts +++ b/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts @@ -1,13 +1,16 @@ -import { UnknownAuthUser } from '@web-api/middleware/apiGatewayHelper'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCustomCaseReportInteractor } from '@web-api/business/useCases/caseInventoryReport/getCustomCaseReportInteractor'; export const getCustomCaseReportLambda = (event, user: UnknownAuthUser) => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCustomCaseReportInteractor( + genericHandler( + event, + async ({ applicationContext }) => { + return await getCustomCaseReportInteractor( applicationContext, event.queryStringParameters, user, ); - }); + }, + user, + ); diff --git a/web-api/src/middleware/apiGatewayHelper.ts b/web-api/src/middleware/apiGatewayHelper.ts index c9fc4a9b1f8..52c4eba0136 100644 --- a/web-api/src/middleware/apiGatewayHelper.ts +++ b/web-api/src/middleware/apiGatewayHelper.ts @@ -3,20 +3,12 @@ import { UnauthorizedError, UnsanitizedEntityError, } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createApplicationContext } from '../applicationContext'; import { headerOverride } from '../lambdaWrapper'; import { pick } from 'lodash'; import jwt from 'jsonwebtoken'; -export type AuthUser = { - role: string; - userId: string; - email: string; - name: string; -}; - -export type UnknownAuthUser = AuthUser | undefined; - /** * invokes the param fun and returns a lambda specific object containing error messages and status codes depending on any caught exceptions (or none) * From 3a5e3d03aa3490b1b46623d0c4e108ad585365d8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 17 Jun 2024 13:14:49 -0700 Subject: [PATCH 006/523] devex: Update isAuthorizedTo to be a typeguard so it can guarantee the AuthUser Type and validate for permissions --- .../authorizationClientService.ts | 22 +++++++++++-------- .../business/entities/authUser/AuthUser.ts | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/shared/src/authorization/authorizationClientService.ts b/shared/src/authorization/authorizationClientService.ts index 776d21f3bdc..3f567f8a833 100644 --- a/shared/src/authorization/authorizationClientService.ts +++ b/shared/src/authorization/authorizationClientService.ts @@ -1,4 +1,8 @@ -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { + AuthUser, + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; export const ROLE_PERMISSIONS = { ADD_CASE_TO_TRIAL_SESSION: 'ADD_CASE_TO_TRIAL_SESSION', @@ -333,7 +337,7 @@ export const AUTHORIZATION_MAP = { privatePractitioner: privatePractitionerPermissions, reportersOffice: allInternalUserPermissions, trialclerk: trialClerkPermissions, -}; +} as const; /** * Checks user permissions for an action @@ -346,24 +350,24 @@ export const isAuthorized = ( user: UnknownAuthUser, action, owner?, -): boolean => { - if (!user) { +): user is AuthUser => { + if (!isAuthUser(user)) { return false; } - if (user.userId && user.userId === owner) { + if (user.userId === owner) { return true; } const userRole = user.role; - if (!AUTHORIZATION_MAP[userRole]) { + const permissions = AUTHORIZATION_MAP[userRole]; + if (!permissions) { return false; } - const roleActionIndex = AUTHORIZATION_MAP[userRole].indexOf(action); + const roleActionIndex = permissions.indexOf(action); - const actionInRoleAuthorization = - !!AUTHORIZATION_MAP[userRole][roleActionIndex]; + const actionInRoleAuthorization = !!permissions[roleActionIndex]; return actionInRoleAuthorization; }; diff --git a/shared/src/business/entities/authUser/AuthUser.ts b/shared/src/business/entities/authUser/AuthUser.ts index 1170099063d..4873eabae67 100644 --- a/shared/src/business/entities/authUser/AuthUser.ts +++ b/shared/src/business/entities/authUser/AuthUser.ts @@ -24,7 +24,7 @@ export function isAuthUser(user): user is AuthUser { const { error } = authUserSchema.validate(user); if (error) { - throw error; + return false; } return true; From e73712747a8bc2b509f7a84338018eb402a490b4 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 17 Jun 2024 13:22:02 -0700 Subject: [PATCH 007/523] devex: Update isAuthorized to be typed --- .../authorization/authorizationClientService.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/shared/src/authorization/authorizationClientService.ts b/shared/src/authorization/authorizationClientService.ts index 3f567f8a833..367035e51df 100644 --- a/shared/src/authorization/authorizationClientService.ts +++ b/shared/src/authorization/authorizationClientService.ts @@ -85,7 +85,10 @@ export const ROLE_PERMISSIONS = { VIEW_SEALED_ADDRESS: 'VIEW_SEALED_ADDRESS', VIEW_SEALED_CASE: 'VIEW_SEALED_CASE', WORKITEM: 'WORKITEM', -}; +} as const; + +export type RolePermission = + (typeof ROLE_PERMISSIONS)[keyof typeof ROLE_PERMISSIONS]; const allInternalUserPermissions = [ ROLE_PERMISSIONS.ADD_CASE_TO_TRIAL_SESSION, @@ -339,17 +342,10 @@ export const AUTHORIZATION_MAP = { trialclerk: trialClerkPermissions, } as const; -/** - * Checks user permissions for an action - * @param {object} user the user to check for authorization - * @param {string} action the action to verify if the user is authorized for - * @param {string} owner the user id of the owner of the item to verify - * @returns {boolean} true if user is authorized, false otherwise - */ export const isAuthorized = ( user: UnknownAuthUser, - action, - owner?, + action: RolePermission, + owner?: string, ): user is AuthUser => { if (!isAuthUser(user)) { return false; From 343af0e524280cd638e818b00c5c01b47c60b0cc Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 17 Jun 2024 21:41:39 -0700 Subject: [PATCH 008/523] devex: Add a shim for old getUserFromAuthHeader until it can be transferred over. --- shared/src/business/entities/authUser/AuthUser.ts | 8 +++++++- web-api/src/genericHandler.ts | 9 +++++++-- web-api/src/lambdaWrapper.ts | 6 ++---- web-api/src/middleware/apiGatewayHelper.ts | 12 +++++++----- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/shared/src/business/entities/authUser/AuthUser.ts b/shared/src/business/entities/authUser/AuthUser.ts index 4873eabae67..ba36a80d315 100644 --- a/shared/src/business/entities/authUser/AuthUser.ts +++ b/shared/src/business/entities/authUser/AuthUser.ts @@ -1,4 +1,5 @@ import { ROLES, Role } from '@shared/business/entities/EntityConstants'; +import { pinkLog } from '@shared/tools/pinkLog'; import joi from 'joi'; export type AuthUser = { @@ -22,8 +23,13 @@ export function isAuthUser(user): user is AuthUser { userId: joi.string().min(1).uuid().required(), }); - const { error } = authUserSchema.validate(user); + const { error } = authUserSchema.validate(user, { + abortEarly: false, + allowUnknown: true, + }); + if (error) { + pinkLog('isAuthUser error', error); return false; } diff --git a/web-api/src/genericHandler.ts b/web-api/src/genericHandler.ts index b411725cdd1..d3fcfad9881 100644 --- a/web-api/src/genericHandler.ts +++ b/web-api/src/genericHandler.ts @@ -2,9 +2,10 @@ import { ServerApplicationContext, createApplicationContext, } from './applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { - UnknownAuthUser, getConnectionIdFromEvent, + getUserFromAuthHeader, handle, } from './middleware/apiGatewayHelper'; @@ -70,8 +71,12 @@ export const genericHandler = ( } = {}, ) => { return handle(awsEvent, async () => { + const deprecatedUser = getUserFromAuthHeader(awsEvent); // TODO: zach remove getting user here. Should be passed in. const clientConnectionId = getConnectionIdFromEvent(awsEvent); - const applicationContext = createApplicationContext(user, awsEvent.logger); + const applicationContext = createApplicationContext( + deprecatedUser, + awsEvent.logger, + ); delete awsEvent.logger; diff --git a/web-api/src/lambdaWrapper.ts b/web-api/src/lambdaWrapper.ts index af65e80a652..887aa408b20 100644 --- a/web-api/src/lambdaWrapper.ts +++ b/web-api/src/lambdaWrapper.ts @@ -1,9 +1,7 @@ -import { - UnknownAuthUser, - getUserFromAuthHeader, -} from '@web-api/middleware/apiGatewayHelper'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { get } from 'lodash'; import { getCurrentInvoke } from '@vendia/serverless-express'; +import { getUserFromAuthHeader } from '@web-api/middleware/apiGatewayHelper'; export const headerOverride = { 'Access-Control-Expose-Headers': 'X-Terminal-User', diff --git a/web-api/src/middleware/apiGatewayHelper.ts b/web-api/src/middleware/apiGatewayHelper.ts index 52c4eba0136..02dc2bdade6 100644 --- a/web-api/src/middleware/apiGatewayHelper.ts +++ b/web-api/src/middleware/apiGatewayHelper.ts @@ -174,11 +174,13 @@ export const getUserFromAuthHeader = (event): UnknownAuthUser => { if (!token) return undefined; const decoded = jwt.decode(token); if (decoded) { - decoded.token = token; - decoded.role = decoded['custom:role']; - decoded.userId = decoded['custom:userId']; - decoded.name = decoded.name || decoded['custom:name']; // custom:name only exists locally. This is a workaround for cognito-local. - return decoded; + decoded.token = token; // TODO zach: Understand if the token is needed for the auth user. Ideally not. + return { + email: decoded.email, + name: decoded.name || decoded['custom:name'], // custom:name only exists locally. This is a workaround for cognito-local. + role: decoded['custom:role'], + userId: decoded['custom:userId'], + }; } else { return undefined; } From a85ce7f39af1b957baf2281e29b38a17f8338e9e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:06:37 -0700 Subject: [PATCH 009/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/addPetitionerToCaseInteractor.ts | 4 +-- .../src/business/useCaseHelper/acquireLock.ts | 6 +++- .../getCustomCaseReportInteractor.ts | 4 +-- .../cases/addPetitionerToCaseLambda.ts | 29 +++++++++++++------ .../reports/getCustomCaseReportLambda.ts | 9 ++++-- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/shared/src/business/useCases/addPetitionerToCaseInteractor.ts b/shared/src/business/useCases/addPetitionerToCaseInteractor.ts index aeb7d1ae83d..da1bd000de0 100644 --- a/shared/src/business/useCases/addPetitionerToCaseInteractor.ts +++ b/shared/src/business/useCases/addPetitionerToCaseInteractor.ts @@ -6,6 +6,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -23,9 +24,8 @@ export const addPetitionerToCase = async ( contact, docketNumber, }: { caseCaption: string; contact: any; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_PETITIONER_TO_CASE)) { throw new UnauthorizedError('Unauthorized for adding petitioner to case'); } diff --git a/web-api/src/business/useCaseHelper/acquireLock.ts b/web-api/src/business/useCaseHelper/acquireLock.ts index c98ce029079..bd8e4afd872 100644 --- a/web-api/src/business/useCaseHelper/acquireLock.ts +++ b/web-api/src/business/useCaseHelper/acquireLock.ts @@ -1,6 +1,7 @@ import { ALLOWLIST_FEATURE_FLAGS } from '../../../../shared/src/business/entities/EntityConstants'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { ServiceUnavailableError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const checkLock = async ({ applicationContext, @@ -131,6 +132,7 @@ export function withLocking( interactor: ( applicationContext: ServerApplicationContext, options: InteractorInput, + authorizedUser: UnknownAuthUser, ) => Promise, getLockInfo: ( applicationContext: ServerApplicationContext, @@ -142,10 +144,12 @@ export function withLocking( ): ( applicationContext: ServerApplicationContext, options: InteractorInput, + authorizedUser: UnknownAuthUser, ) => Promise { return async function ( applicationContext: ServerApplicationContext, options: InteractorInput, + authorizedUser: UnknownAuthUser, ) { const { identifiers, ttl } = await getLockInfo(applicationContext, options); @@ -160,7 +164,7 @@ export function withLocking( let caughtError; let results: InteractorOutput; try { - results = await interactor(applicationContext, options); + results = await interactor(applicationContext, options, authorizedUser); } catch (err) { caughtError = err; } diff --git a/web-api/src/business/useCases/caseInventoryReport/getCustomCaseReportInteractor.ts b/web-api/src/business/useCases/caseInventoryReport/getCustomCaseReportInteractor.ts index 4ea1d632d43..595309a4be4 100644 --- a/web-api/src/business/useCases/caseInventoryReport/getCustomCaseReportInteractor.ts +++ b/web-api/src/business/useCases/caseInventoryReport/getCustomCaseReportInteractor.ts @@ -60,9 +60,9 @@ export type CustomCaseReportSearchAfter = { export const getCustomCaseReportInteractor = async ( applicationContext: IApplicationContext, params: GetCustomCaseReportRequest, - user: UnknownAuthUser, + authorizedUser: UnknownAuthUser, ): Promise => { - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_INVENTORY_REPORT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_INVENTORY_REPORT)) { throw new UnauthorizedError('Unauthorized for case inventory report'); } diff --git a/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts b/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts index 8145f878bec..929521e35a9 100644 --- a/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts +++ b/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { addPetitionerToCaseInteractor } from '@shared/business/useCases/addPetitionerToCaseInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const addPetitionerToCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .addPetitionerToCaseInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const addPetitionerToCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await addPetitionerToCaseInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); diff --git a/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts b/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts index 2cdf3d89dcb..74f10724140 100644 --- a/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts +++ b/web-api/src/lambdas/reports/getCustomCaseReportLambda.ts @@ -2,15 +2,18 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; import { getCustomCaseReportInteractor } from '@web-api/business/useCases/caseInventoryReport/getCustomCaseReportInteractor'; -export const getCustomCaseReportLambda = (event, user: UnknownAuthUser) => +export const getCustomCaseReportLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { return await getCustomCaseReportInteractor( applicationContext, event.queryStringParameters, - user, + authorizedUser, ); }, - user, + authorizedUser, ); From d4cc63381ff3fedda973fc33b0fd123bd730fa93 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:09:45 -0700 Subject: [PATCH 010/523] devex: Update interactors to accept authorizedUser as an argument --- .../archiveDraftDocumentInteractor.ts | 6 ++-- .../addDeficiencyStatisticInteractor.ts | 6 ++-- .../cases/addDeficiencyStatisticLambda.ts | 29 +++++++++++++------ .../documents/archiveDraftDocumentLambda.ts | 23 +++++++++++---- 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/shared/src/business/useCases/archiveDraftDocumentInteractor.ts b/shared/src/business/useCases/archiveDraftDocumentInteractor.ts index 2d13d70e15e..af4a539c019 100644 --- a/shared/src/business/useCases/archiveDraftDocumentInteractor.ts +++ b/shared/src/business/useCases/archiveDraftDocumentInteractor.ts @@ -4,6 +4,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -20,10 +21,9 @@ export const archiveDraftDocument = async ( docketEntryId, docketNumber, }: { docketEntryId: string; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.ARCHIVE_DOCUMENT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ARCHIVE_DOCUMENT)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts index c95ea191833..c05dc01431f 100644 --- a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts @@ -6,6 +6,7 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { Statistic } from '../../../../../shared/src/business/entities/Statistic'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -51,10 +52,9 @@ export const addDeficiencyStatistic = async ( year: string; yearOrPeriod: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS)) { throw new UnauthorizedError('Unauthorized for editing statistics'); } diff --git a/web-api/src/lambdas/cases/addDeficiencyStatisticLambda.ts b/web-api/src/lambdas/cases/addDeficiencyStatisticLambda.ts index a0dba962efd..225f894ffe9 100644 --- a/web-api/src/lambdas/cases/addDeficiencyStatisticLambda.ts +++ b/web-api/src/lambdas/cases/addDeficiencyStatisticLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { addDeficiencyStatisticInteractor } from '@web-api/business/useCases/caseStatistics/addDeficiencyStatisticInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const addDeficiencyStatisticLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .addDeficiencyStatisticInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const addDeficiencyStatisticLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await addDeficiencyStatisticInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); diff --git a/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts b/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts index ae7246c4c8d..e2c28461df6 100644 --- a/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts +++ b/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { archiveDraftDocumentInteractor } from '@shared/business/useCases/archiveDraftDocumentInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,9 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const archiveDraftDocumentLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .archiveDraftDocumentInteractor(applicationContext, event.pathParameters); - }); +export const archiveDraftDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await archiveDraftDocumentInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); + }, + authorizedUser, + ); From ebacf65a83e6823f7e26a53a17adfd9cf6418053 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:11:14 -0700 Subject: [PATCH 011/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/blockCaseFromTrialInteractor.ts | 4 +-- .../lambdas/cases/blockCaseFromTrialLambda.ts | 35 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/shared/src/business/useCases/blockCaseFromTrialInteractor.ts b/shared/src/business/useCases/blockCaseFromTrialInteractor.ts index c6931d876fb..2305963f0a7 100644 --- a/shared/src/business/useCases/blockCaseFromTrialInteractor.ts +++ b/shared/src/business/useCases/blockCaseFromTrialInteractor.ts @@ -4,6 +4,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -17,9 +18,8 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const blockCaseFromTrial = async ( applicationContext: IApplicationContext, { docketNumber, reason }: { docketNumber: string; reason: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.BLOCK_CASE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts b/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts index 5c0ba669591..f221e13d360 100644 --- a/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts +++ b/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { blockCaseFromTrialInteractor } from '@shared/business/useCases/blockCaseFromTrialInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,16 +8,25 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const blockCaseFromTrialLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const lambdaArguments = { - ...event.pathParameters, - ...JSON.parse(event.body), - }; +export const blockCaseFromTrialLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const lambdaArguments = { + ...event.pathParameters, + ...JSON.parse(event.body), + }; - return await applicationContext - .getUseCases() - .blockCaseFromTrialInteractor(applicationContext, { - ...lambdaArguments, - }); - }); + return await blockCaseFromTrialInteractor( + applicationContext, + { + ...lambdaArguments, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 7d989f6c61b7aa5f15ecfff66214e54eaab298ce Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:13:15 -0700 Subject: [PATCH 012/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/caseAdvancedSearchInteractor.ts | 3 ++- .../lambdas/cases/caseAdvancedSearchLambda.ts | 27 +++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/shared/src/business/useCases/caseAdvancedSearchInteractor.ts b/shared/src/business/useCases/caseAdvancedSearchInteractor.ts index a28a575a0c4..a036b874c18 100644 --- a/shared/src/business/useCases/caseAdvancedSearchInteractor.ts +++ b/shared/src/business/useCases/caseAdvancedSearchInteractor.ts @@ -8,6 +8,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { caseSearchFilter } from '../utilities/caseFilter'; import { createEndOfDayISO, @@ -31,8 +32,8 @@ export const caseAdvancedSearchInteractor = async ( petitionerState, startDate, }: CaseAdvancedSearchParamsRequestType, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); let searchStartDate; let searchEndDate; diff --git a/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts b/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts index 99af569db6e..0bf88c1f697 100644 --- a/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts +++ b/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { caseAdvancedSearchInteractor } from '@shared/business/useCases/caseAdvancedSearchInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const caseAdvancedSearchLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .caseAdvancedSearchInteractor(applicationContext, { - ...event.queryStringParameters, - }); - }); +export const caseAdvancedSearchLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await caseAdvancedSearchInteractor( + applicationContext, + { + ...event.queryStringParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From f40ec235ba92ca5334da0de5a6ee27a3d293c1c0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:14:10 -0700 Subject: [PATCH 013/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/createCaseFromPaperInteractor.ts | 3 +-- .../cases/createCaseFromPaperLambda.ts | 27 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/shared/src/business/useCases/createCaseFromPaperInteractor.ts b/shared/src/business/useCases/createCaseFromPaperInteractor.ts index 252a73bc820..25ef9889afb 100644 --- a/shared/src/business/useCases/createCaseFromPaperInteractor.ts +++ b/shared/src/business/useCases/createCaseFromPaperInteractor.ts @@ -81,9 +81,8 @@ export const createCaseFromPaperInteractor = async ( requestForPlaceOfTrialFileId?: string; stinFileId?: string; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.START_PAPER_CASE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts b/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts index 17409c6c41b..e50b3f0b2ff 100644 --- a/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts +++ b/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { createCaseFromPaperInteractor } from '@shared/business/useCases/createCaseFromPaperInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const createCaseFromPaperLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createCaseFromPaperInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const createCaseFromPaperLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await createCaseFromPaperInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 82fdfe6367594816f3381ac607d90545cde5cd16 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:17:36 -0700 Subject: [PATCH 014/523] devex: Update interactors to accept authorizedUser as an argument --- .../generateDraftStampOrderInteractor.ts | 6 +++--- .../documents/generateDraftStampOrderLambda.ts | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/shared/src/business/useCases/generateDraftStampOrderInteractor.ts b/shared/src/business/useCases/generateDraftStampOrderInteractor.ts index 100d22af91f..19a359d14f7 100644 --- a/shared/src/business/useCases/generateDraftStampOrderInteractor.ts +++ b/shared/src/business/useCases/generateDraftStampOrderInteractor.ts @@ -3,6 +3,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * generateDraftStampOrderInteractor @@ -32,10 +33,9 @@ export const generateDraftStampOrderInteractor = async ( stampData: any; stampedDocketEntryId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.STAMP_MOTION)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.STAMP_MOTION)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/documents/generateDraftStampOrderLambda.ts b/web-api/src/lambdas/documents/generateDraftStampOrderLambda.ts index fa88d4735ae..afe61b6952c 100644 --- a/web-api/src/lambdas/documents/generateDraftStampOrderLambda.ts +++ b/web-api/src/lambdas/documents/generateDraftStampOrderLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generateDraftStampOrderInteractor } from '@shared/business/useCases/generateDraftStampOrderInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,16 +8,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const generateDraftStampOrderLambda = event => +export const generateDraftStampOrderLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { - await applicationContext - .getUseCases() - .generateDraftStampOrderInteractor(applicationContext, { + await generateDraftStampOrderInteractor( + applicationContext, + { ...event.pathParameters, ...JSON.parse(event.body), - }); + }, + authorizedUser, + ); }, + authorizedUser, { logResults: false }, ); From c93d799a476a8a31f8d55f209b6d4d4bcff5fe88 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:19:11 -0700 Subject: [PATCH 015/523] devex: Update interactors to accept authorizedUser as an argument --- ...eneratePractitionerCaseListPdfInteractor.ts | 8 +++++--- .../generatePractitionerCaseListPdfLambda.ts | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.ts b/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.ts index 2f836039e23..64f356881eb 100644 --- a/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.ts +++ b/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.ts @@ -4,6 +4,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { partition } from 'lodash'; /** @@ -17,10 +18,11 @@ import { partition } from 'lodash'; export const generatePractitionerCaseListPdfInteractor = async ( applicationContext: IApplicationContext, { userId }: { userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.VIEW_PRACTITIONER_CASE_LIST)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_PRACTITIONER_CASE_LIST) + ) { throw new UnauthorizedError('Unauthorized to view practitioners cases'); } diff --git a/web-api/src/lambdas/cases/generatePractitionerCaseListPdfLambda.ts b/web-api/src/lambdas/cases/generatePractitionerCaseListPdfLambda.ts index be3443f33d4..c7c2ce1b730 100644 --- a/web-api/src/lambdas/cases/generatePractitionerCaseListPdfLambda.ts +++ b/web-api/src/lambdas/cases/generatePractitionerCaseListPdfLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generatePractitionerCaseListPdfInteractor } from '@shared/business/useCases/generatePractitionerCaseListPdfInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,17 +8,23 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const generatePractitionerCaseListPdfLambda = event => +export const generatePractitionerCaseListPdfLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { const { userId } = event.pathParameters; - return await applicationContext - .getUseCases() - .generatePractitionerCaseListPdfInteractor(applicationContext, { + return await generatePractitionerCaseListPdfInteractor( + applicationContext, + { userId, - }); + }, + authorizedUser, + ); }, + authorizedUser, { logResults: false }, ); From 4835a9f9f16aaf6758858be24e9fe156bb97f669 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:20:15 -0700 Subject: [PATCH 016/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/getAllUsersByRoleInteractor.ts | 3 ++- .../lambdas/users/getAllUsersByRoleLambda.ts | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/shared/src/business/useCases/getAllUsersByRoleInteractor.ts b/shared/src/business/useCases/getAllUsersByRoleInteractor.ts index 97db48c27bc..9a973212aa9 100644 --- a/shared/src/business/useCases/getAllUsersByRoleInteractor.ts +++ b/shared/src/business/useCases/getAllUsersByRoleInteractor.ts @@ -3,12 +3,13 @@ import { isAuthorized, } from '@shared/authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const getAllUsersByRoleInteractor = async ( applicationContext: IApplicationContext, { roles }: { roles: string[] }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/users/getAllUsersByRoleLambda.ts b/web-api/src/lambdas/users/getAllUsersByRoleLambda.ts index 12e9b8abb7f..30dafa9c255 100644 --- a/web-api/src/lambdas/users/getAllUsersByRoleLambda.ts +++ b/web-api/src/lambdas/users/getAllUsersByRoleLambda.ts @@ -1,16 +1,21 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getAllUsersByRoleInteractor } from '@shared/business/useCases/getAllUsersByRoleInteractor'; -export const getAllUsersByRoleLambda = event => +export const getAllUsersByRoleLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getAllUsersByRoleInteractor( - applicationContext, - event.queryStringParameters, - ); + return await getAllUsersByRoleInteractor( + applicationContext, + event.queryStringParameters, + authorizedUser, + ); }, + authorizedUser, { bypassMaintenanceCheck: true, }, From 68f90d4f27f97d9d72634593184a4057e52eafad Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:21:31 -0700 Subject: [PATCH 017/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/getBlockedCasesInteractor.ts | 4 ++-- .../lambdas/reports/getBlockedCasesLambda.ts | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/shared/src/business/useCases/getBlockedCasesInteractor.ts b/shared/src/business/useCases/getBlockedCasesInteractor.ts index cd92061108e..828f3406b32 100644 --- a/shared/src/business/useCases/getBlockedCasesInteractor.ts +++ b/shared/src/business/useCases/getBlockedCasesInteractor.ts @@ -3,6 +3,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * getBlockedCasesInteractor @@ -15,9 +16,8 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const getBlockedCasesInteractor = async ( applicationContext: IApplicationContext, { trialLocation }: { trialLocation: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.BLOCK_CASE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/reports/getBlockedCasesLambda.ts b/web-api/src/lambdas/reports/getBlockedCasesLambda.ts index e5333f6f4fb..2313a1fbe8e 100644 --- a/web-api/src/lambdas/reports/getBlockedCasesLambda.ts +++ b/web-api/src/lambdas/reports/getBlockedCasesLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getBlockedCasesInteractor } from '@shared/business/useCases/getBlockedCasesInteractor'; /** * used for getting all the blocked cases for a trial location @@ -6,11 +8,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getBlockedCasesLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getBlockedCasesInteractor(applicationContext, { - trialLocation: event.pathParameters.trialLocation, - }); - }); +export const getBlockedCasesLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getBlockedCasesInteractor( + applicationContext, + { + trialLocation: event.pathParameters.trialLocation, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 4064675e193ce8e0adccecc201af3828d543d86b Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 18 Jun 2024 22:22:47 -0700 Subject: [PATCH 018/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/getCaseDeadlinesInteractor.ts | 6 ++--- .../caseDeadline/getCaseDeadlinesLambda.ts | 27 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/shared/src/business/useCases/getCaseDeadlinesInteractor.ts b/shared/src/business/useCases/getCaseDeadlinesInteractor.ts index afafe465a69..62e5fea1abc 100644 --- a/shared/src/business/useCases/getCaseDeadlinesInteractor.ts +++ b/shared/src/business/useCases/getCaseDeadlinesInteractor.ts @@ -5,6 +5,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { pick } from 'lodash'; export const getCaseDeadlinesInteractor = async ( @@ -22,10 +23,9 @@ export const getCaseDeadlinesInteractor = async ( pageSize: number; startDate; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_DEADLINE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_DEADLINE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/caseDeadline/getCaseDeadlinesLambda.ts b/web-api/src/lambdas/caseDeadline/getCaseDeadlinesLambda.ts index 351b6022878..367e8c8c614 100644 --- a/web-api/src/lambdas/caseDeadline/getCaseDeadlinesLambda.ts +++ b/web-api/src/lambdas/caseDeadline/getCaseDeadlinesLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCaseDeadlinesInteractor } from '@shared/business/useCases/getCaseDeadlinesInteractor'; /** * get case deadlines between start and end date @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCaseDeadlinesLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCaseDeadlinesInteractor(applicationContext, { - ...event.queryStringParameters, - }); - }); +export const getCaseDeadlinesLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getCaseDeadlinesInteractor( + applicationContext, + { + ...event.queryStringParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 156be257c53c48cc807be1bdb7bc3997edc229d0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 21:54:10 -0700 Subject: [PATCH 019/523] devex: Update interactors to accept authorizedUser as an argument --- .../business/entities/authUser/AuthUser.ts | 2 - .../business/useCases/getCaseInteractor.ts | 50 ++++++++++++------- web-api/src/lambdas/cases/getCaseLambda.ts | 19 +++++-- web-api/src/lambdas/v1/getCaseLambda.ts | 19 +++++-- web-api/src/lambdas/v2/getCaseLambda.ts | 19 +++++-- 5 files changed, 74 insertions(+), 35 deletions(-) diff --git a/shared/src/business/entities/authUser/AuthUser.ts b/shared/src/business/entities/authUser/AuthUser.ts index ba36a80d315..c2afb07f451 100644 --- a/shared/src/business/entities/authUser/AuthUser.ts +++ b/shared/src/business/entities/authUser/AuthUser.ts @@ -1,5 +1,4 @@ import { ROLES, Role } from '@shared/business/entities/EntityConstants'; -import { pinkLog } from '@shared/tools/pinkLog'; import joi from 'joi'; export type AuthUser = { @@ -29,7 +28,6 @@ export function isAuthUser(user): user is AuthUser { }); if (error) { - pinkLog('isAuthUser error', error); return false; } diff --git a/shared/src/business/useCases/getCaseInteractor.ts b/shared/src/business/useCases/getCaseInteractor.ts index 5b1205332b5..dbcc099ff8e 100644 --- a/shared/src/business/useCases/getCaseInteractor.ts +++ b/shared/src/business/useCases/getCaseInteractor.ts @@ -1,3 +1,8 @@ +import { + AuthUser, + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { Case, canAllowDocumentServiceForCase, @@ -6,7 +11,7 @@ import { isAssociatedUser, isUserPartOfGroup, } from '../entities/cases/Case'; -import { NotFoundError } from '@web-api/errors/errors'; +import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors'; import { PublicCase } from '../entities/cases/PublicCase'; import { ROLE_PERMISSIONS, @@ -20,27 +25,27 @@ import { const getSealedCase = ({ applicationContext, + authorizedUser, caseRecord, isAssociatedWithCase, }: { applicationContext: IApplicationContext; caseRecord: RawCase; isAssociatedWithCase: boolean; + authorizedUser: AuthUser; }): RawCase | RawPublicCase => { - const currentUser = applicationContext.getCurrentUser(); - let isAuthorizedToViewSealedCase = isAuthorized( - currentUser, + authorizedUser, ROLE_PERMISSIONS.VIEW_SEALED_CASE, ); if (!isAuthorizedToViewSealedCase) { - const petitioner = getPetitionerById(caseRecord, currentUser.userId); + const petitioner = getPetitionerById(caseRecord, authorizedUser.userId); if (petitioner) { isAuthorizedToViewSealedCase = isAuthorized( - currentUser, + authorizedUser, ROLE_PERMISSIONS.VIEW_SEALED_CASE, - getPetitionerById(caseRecord, currentUser.userId).contactId, + getPetitionerById(caseRecord, authorizedUser.userId).contactId, ); } } @@ -106,7 +111,14 @@ export const decorateForCaseStatus = (caseRecord: RawCase) => { export const getCaseInteractor = async ( applicationContext: IApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { + if (!isAuthUser(authorizedUser)) { + throw new UnauthorizedError( + `Invalid User attempting to view docket Number: ${docketNumber}`, + ); + } + const caseRecord = decorateForCaseStatus( await applicationContext.getPersistenceGateway().getCaseByDocketNumber({ applicationContext, @@ -122,31 +134,29 @@ export const getCaseInteractor = async ( throw error; } - const currentUser = applicationContext.getCurrentUser(); - let isAuthorizedToGetCase = isAuthorized( - currentUser, + authorizedUser, ROLE_PERMISSIONS.GET_CASE, ); if (!isAuthorizedToGetCase) { - const petitioner = getPetitionerById(caseRecord, currentUser.userId); + const petitioner = getPetitionerById(caseRecord, authorizedUser.userId); if (petitioner) { isAuthorizedToGetCase = isAuthorized( - currentUser, + authorizedUser, ROLE_PERMISSIONS.GET_CASE, - getPetitionerById(caseRecord, currentUser.userId).contactId, + getPetitionerById(caseRecord, authorizedUser.userId).contactId, ); } else if (caseRecord.leadDocketNumber) { isAuthorizedToGetCase = isUserPartOfGroup({ consolidatedCases: caseRecord.consolidatedCases, - userId: currentUser.userId, + userId: authorizedUser.userId, }); } } let isAssociatedWithCase = isAssociatedUser({ caseRaw: caseRecord, - user: currentUser, + user: authorizedUser, }); if (caseRecord.leadDocketNumber) { @@ -154,7 +164,7 @@ export const getCaseInteractor = async ( isAssociatedWithCase || isUserPartOfGroup({ consolidatedCases: caseRecord.consolidatedCases, - userId: currentUser.userId, + userId: authorizedUser.userId, }); } @@ -168,11 +178,12 @@ export const getCaseInteractor = async ( if (isSealedCase) { caseDetailRaw = await getSealedCase({ applicationContext, + authorizedUser, caseRecord, isAssociatedWithCase, }); } else { - const { role: userRole } = currentUser; + const { role: userRole } = authorizedUser; const isInternalUser = User.isInternalUser(userRole); if (isInternalUser) { @@ -189,6 +200,9 @@ export const getCaseInteractor = async ( } } - caseDetailRaw = caseContactAddressSealedFormatter(caseDetailRaw, currentUser); + caseDetailRaw = caseContactAddressSealedFormatter( + caseDetailRaw, + authorizedUser, + ); return caseDetailRaw; }; diff --git a/web-api/src/lambdas/cases/getCaseLambda.ts b/web-api/src/lambdas/cases/getCaseLambda.ts index b62f7cb3847..e95e3191f56 100644 --- a/web-api/src/lambdas/cases/getCaseLambda.ts +++ b/web-api/src/lambdas/cases/getCaseLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCaseInteractor } from '@shared/business/useCases/getCaseInteractor'; /** * used for fetching a single case @@ -6,9 +8,16 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCaseLambda = event => - genericHandler(event, ({ applicationContext }) => - applicationContext.getUseCases().getCaseInteractor(applicationContext, { - docketNumber: event.pathParameters.docketNumber, - }), +export const getCaseLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + ({ applicationContext }) => + getCaseInteractor( + applicationContext, + { + docketNumber: event.pathParameters.docketNumber, + }, + authorizedUser, + ), + authorizedUser, ); diff --git a/web-api/src/lambdas/v1/getCaseLambda.ts b/web-api/src/lambdas/v1/getCaseLambda.ts index 91b8c0ce6b6..c3a06ba8592 100644 --- a/web-api/src/lambdas/v1/getCaseLambda.ts +++ b/web-api/src/lambdas/v1/getCaseLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCaseInteractor } from '@shared/business/useCases/getCaseInteractor'; import { marshallCase } from './marshallers/marshallCase'; import { v1ApiWrapper } from './v1ApiWrapper'; @@ -9,18 +11,25 @@ import { v1ApiWrapper } from './v1ApiWrapper'; * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCaseLambda = (event, options) => +export const getCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, + options, +) => genericHandler( event, ({ applicationContext }) => v1ApiWrapper(async () => { - const caseObject = await applicationContext - .getUseCases() - .getCaseInteractor(applicationContext, { + const caseObject = await getCaseInteractor( + applicationContext, + { docketNumber: event.pathParameters.docketNumber, - }); + }, + authorizedUser, + ); return marshallCase(caseObject); }), + authorizedUser, options, ); diff --git a/web-api/src/lambdas/v2/getCaseLambda.ts b/web-api/src/lambdas/v2/getCaseLambda.ts index e205975b52e..b151404b285 100644 --- a/web-api/src/lambdas/v2/getCaseLambda.ts +++ b/web-api/src/lambdas/v2/getCaseLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCaseInteractor } from '@shared/business/useCases/getCaseInteractor'; import { marshallCase } from './marshallers/marshallCase'; import { v2ApiWrapper } from './v2ApiWrapper'; @@ -9,18 +11,25 @@ import { v2ApiWrapper } from './v2ApiWrapper'; * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCaseLambda = (event, options) => +export const getCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, + options, +) => genericHandler( event, ({ applicationContext }) => v2ApiWrapper(async () => { - const caseObject = await applicationContext - .getUseCases() - .getCaseInteractor(applicationContext, { + const caseObject = await getCaseInteractor( + applicationContext, + { docketNumber: event.pathParameters.docketNumber, - }); + }, + authorizedUser, + ); return marshallCase(caseObject); }), + authorizedUser, options, ); From 8f18dbada4286c94154de32808153e703c1a712b Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 21:59:06 -0700 Subject: [PATCH 020/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/getCasesForUserInteractor.ts | 12 +++++++++++- .../lambdas/cases/getCasesForUserLambda.ts | 19 +++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/shared/src/business/useCases/getCasesForUserInteractor.ts b/shared/src/business/useCases/getCasesForUserInteractor.ts index fce9d99b9e9..45abd6ba23d 100644 --- a/shared/src/business/useCases/getCasesForUserInteractor.ts +++ b/shared/src/business/useCases/getCasesForUserInteractor.ts @@ -5,6 +5,11 @@ import { userIsDirectlyAssociated, } from '../entities/cases/Case'; import { PaymentStatusTypes } from '@shared/business/entities/EntityConstants'; +import { UnauthorizedError } from '@web-api/errors/errors'; +import { + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { compareISODateStrings } from '../utilities/sortFunctions'; import { partition, uniqBy } from 'lodash'; @@ -27,11 +32,16 @@ export type TAssociatedCase = { export const getCasesForUserInteractor = async ( applicationContext: IApplicationContext, + authorizedUser: UnknownAuthUser, ): Promise<{ openCaseList: TAssociatedCase[]; closedCaseList: TAssociatedCase[]; }> => { - const { userId } = await applicationContext.getCurrentUser(); + if (!isAuthUser(authorizedUser)) { + throw new UnauthorizedError('Invalid User attempting to get cases'); + } + + const { userId } = authorizedUser; const docketNumbers = ( await applicationContext.getPersistenceGateway().getCasesForUser({ diff --git a/web-api/src/lambdas/cases/getCasesForUserLambda.ts b/web-api/src/lambdas/cases/getCasesForUserLambda.ts index d6c5f2583f4..d7dadf0ba0c 100644 --- a/web-api/src/lambdas/cases/getCasesForUserLambda.ts +++ b/web-api/src/lambdas/cases/getCasesForUserLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCasesForUserInteractor } from '@shared/business/useCases/getCasesForUserInteractor'; /** * used for fetching all open and closed cases for a particular user @@ -6,9 +8,14 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCasesForUserLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCasesForUserInteractor(applicationContext); - }); +export const getCasesForUserLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getCasesForUserInteractor( + applicationContext, + authorizedUser, + ); + }, + authorizedUser, + ); From c9c1d17a32b2974a59fc320377b9938fefbbfd80 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 22:11:13 -0700 Subject: [PATCH 021/523] devex: Update interactors to accept authorizedUser as an argument --- shared/src/business/entities/cases/Case.ts | 15 ++++++++---- .../getDownloadPolicyUrlInteractor.ts | 12 +++++----- .../documents/downloadPolicyUrlLambda.ts | 23 ++++++++++++++----- .../documents/getDocumentDownloadUrlLambda.ts | 23 ++++++++++++++----- .../v1/getDocumentDownloadUrlLambda.ts | 19 +++++++++++---- .../v2/getDocumentDownloadUrlLambda.ts | 19 +++++++++++---- 6 files changed, 79 insertions(+), 32 deletions(-) diff --git a/shared/src/business/entities/cases/Case.ts b/shared/src/business/entities/cases/Case.ts index a3699d65f89..66816646bbb 100644 --- a/shared/src/business/entities/cases/Case.ts +++ b/shared/src/business/entities/cases/Case.ts @@ -22,6 +22,7 @@ import { PETITIONER_CONTACT_TYPES, PROCEDURE_TYPES, ROLES, + Role, SYSTEM_ROLE, TRIAL_CITY_STRINGS, TRIAL_LOCATION_MATCHER, @@ -61,10 +62,10 @@ import { JoiValidationEntity } from '../JoiValidationEntity'; import { Petitioner } from '../contacts/Petitioner'; import { PrivatePractitioner } from '../PrivatePractitioner'; import { PublicCase } from '@shared/business/entities/cases/PublicCase'; -import { type RawUser, User } from '../User'; import { Statistic } from '../Statistic'; import { TrialSession } from '../trialSessions/TrialSession'; import { UnprocessableEntityError } from '../../../../../web-api/src/errors/errors'; +import { User } from '../User'; import { clone, compact, includes, isEmpty, startCase } from 'lodash'; import { compareStrings } from '../../utilities/sortFunctions'; import { getDocketNumberSuffix } from '../../utilities/getDocketNumberSuffix'; @@ -2024,13 +2025,13 @@ export class Case extends JoiValidationEntity { ); } - userHasAccessToCase(user: RawUser): boolean { + userHasAccessToCase(user: { userId: string; role: Role }): boolean { return Case.userHasAccessToCase(this, user); } static userHasAccessToCase( rawCase: RawCase | RawPublicCase, - user: RawUser, + user: { userId: string; role: Role }, ): boolean { return rawCase.leadDocketNumber ? isUserPartOfGroup({ @@ -2192,7 +2193,13 @@ export const caseHasServedPetition = rawCase => { * @param {string} arguments.user the user account * @returns {boolean} if the case is associated */ -export const isAssociatedUser = function ({ caseRaw, user }) { +export const isAssociatedUser = function ({ + caseRaw, + user, +}: { + caseRaw: any; + user: { userId: string; role: Role }; +}) { const isIrsPractitioner = caseRaw.irsPractitioners && caseRaw.irsPractitioners.find(r => r.userId === user.userId); diff --git a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.ts b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.ts index 3bfa177309c..f6cf391cf21 100644 --- a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.ts +++ b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.ts @@ -6,15 +6,15 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '@shared/business/entities/User'; export const getDownloadPolicyUrlInteractor = async ( applicationContext: IApplicationContext, { docketNumber, key }: { docketNumber: string; key: string }, + authorizedUser: UnknownAuthUser, ): Promise<{ url: string }> => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.VIEW_DOCUMENTS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_DOCUMENTS)) { throw new UnauthorizedError('Unauthorized'); } @@ -37,12 +37,12 @@ export const getDownloadPolicyUrlInteractor = async ( if (key.includes('.pdf')) { if ( caseEntity.getCaseConfirmationGeneratedPdfFileName() !== key || - !caseEntity.userHasAccessToCase(user) + !caseEntity.userHasAccessToCase(authorizedUser) ) { throw new UnauthorizedError('Unauthorized'); } } else if (caseEntity.getCorrespondenceById({ correspondenceId: key })) { - if (!User.isInternalUser(user.role)) { + if (!User.isInternalUser(authorizedUser.role)) { throw new UnauthorizedError(UNAUTHORIZED_DOCUMENT_MESSAGE); } } else { @@ -68,7 +68,7 @@ export const getDownloadPolicyUrlInteractor = async ( !DocketEntry.isDownloadable(docketEntryEntity, { isTerminalUser: false, rawCase: caseData, - user, + user: authorizedUser, visibilityChangeDate: documentVisibilityChangeDate, }) ) { diff --git a/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts b/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts index 9079aed8a92..bba071d44ef 100644 --- a/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts +++ b/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getDownloadPolicyUrlInteractor } from '@shared/business/useCases/getDownloadPolicyUrlInteractor'; /** * used for getting the download policy which is needed for users to download files directly from S3 via the UI @@ -6,9 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const downloadPolicyUrlLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getDownloadPolicyUrlInteractor(applicationContext, event.pathParameters); - }); +export const downloadPolicyUrlLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getDownloadPolicyUrlInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); + }, + authorizedUser, + ); diff --git a/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts index ad025c40d18..41ef405473f 100644 --- a/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getDownloadPolicyUrlInteractor } from '@shared/business/useCases/getDownloadPolicyUrlInteractor'; /** * TODO: clone of downloadPolicyUrlLambda? @@ -7,9 +9,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getDocumentDownloadUrlLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getDownloadPolicyUrlInteractor(applicationContext, event.pathParameters); - }); +export const getDocumentDownloadUrlLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getDownloadPolicyUrlInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); + }, + authorizedUser, + ); diff --git a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts index 885029534f8..626aac8eedd 100644 --- a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getDownloadPolicyUrlInteractor } from '@shared/business/useCases/getDownloadPolicyUrlInteractor'; import { marshallDocumentDownloadUrl } from './marshallers/marshallDocumentDownloadUrl'; import { v1ApiWrapper } from './v1ApiWrapper'; @@ -9,19 +11,26 @@ import { v1ApiWrapper } from './v1ApiWrapper'; * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getDocumentDownloadUrlLambda = (event, options = {}) => +export const getDocumentDownloadUrlLambda = ( + event, + authorizedUser: UnknownAuthUser, + options = {}, +) => genericHandler( event, ({ applicationContext }) => { return v1ApiWrapper(async () => { - const urlObject = await applicationContext - .getUseCases() - .getDownloadPolicyUrlInteractor(applicationContext, { + const urlObject = await getDownloadPolicyUrlInteractor( + applicationContext, + { ...event.pathParameters, - }); + }, + authorizedUser, + ); return marshallDocumentDownloadUrl(urlObject); }); }, + authorizedUser, options, ); diff --git a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts index f619ed39601..61aefccad12 100644 --- a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getDownloadPolicyUrlInteractor } from '@shared/business/useCases/getDownloadPolicyUrlInteractor'; import { marshallDocumentDownloadUrl } from './marshallers/marshallDocumentDownloadUrl'; import { v2ApiWrapper } from './v2ApiWrapper'; @@ -9,19 +11,26 @@ import { v2ApiWrapper } from './v2ApiWrapper'; * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getDocumentDownloadUrlLambda = (event, options = {}) => +export const getDocumentDownloadUrlLambda = ( + event, + authorizedUser: UnknownAuthUser, + options = {}, +) => genericHandler( event, ({ applicationContext }) => { return v2ApiWrapper(async () => { - const urlObject = await applicationContext - .getUseCases() - .getDownloadPolicyUrlInteractor(applicationContext, { + const urlObject = await getDownloadPolicyUrlInteractor( + applicationContext, + { ...event.pathParameters, - }); + }, + authorizedUser, + ); return marshallDocumentDownloadUrl(urlObject); }); }, + authorizedUser, options, ); From 8baceb2b76bf084cee1d47dde9c08eb2e188fc58 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 22:14:39 -0700 Subject: [PATCH 022/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/getNotificationsInteractor.ts | 18 ++++++++---- .../lambdas/users/getNotificationsLambda.ts | 29 +++++++++++++------ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/shared/src/business/useCases/getNotificationsInteractor.ts b/shared/src/business/useCases/getNotificationsInteractor.ts index 5d1a54b9ccd..9685ae0792f 100644 --- a/shared/src/business/useCases/getNotificationsInteractor.ts +++ b/shared/src/business/useCases/getNotificationsInteractor.ts @@ -1,5 +1,10 @@ import { CHIEF_JUDGE, ROLES } from '../entities/EntityConstants'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnauthorizedError } from '@web-api/errors/errors'; +import { + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { isEmpty } from 'lodash'; const getJudgeUser = async ( @@ -28,6 +33,7 @@ export const getNotificationsInteractor = async ( caseServicesSupervisorData, judgeUserId, }: { judgeUserId: string; caseServicesSupervisorData: any }, + authorizedUser: UnknownAuthUser, ): Promise<{ qcIndividualInProgressCount: number; qcIndividualInboxCount: number; @@ -38,17 +44,19 @@ export const getNotificationsInteractor = async ( userInboxCount: number; userSectionCount: number; }> => { - const appContextUser = applicationContext.getCurrentUser(); - applicationContext.logger.info('getNotificationsInteractor start', { - appContextUser, + appContextUser: authorizedUser, }); + if (!isAuthUser(authorizedUser)) { + throw new UnauthorizedError('Invalid User getting notifications'); + } + const [currentUser, judgeUser] = await Promise.all([ applicationContext .getPersistenceGateway() - .getUserById({ applicationContext, userId: appContextUser.userId }), - getJudgeUser(judgeUserId, applicationContext, appContextUser.role), + .getUserById({ applicationContext, userId: authorizedUser.userId }), + getJudgeUser(judgeUserId, applicationContext, authorizedUser.role), ]); applicationContext.logger.info('getNotificationsInteractor getUser', { diff --git a/web-api/src/lambdas/users/getNotificationsLambda.ts b/web-api/src/lambdas/users/getNotificationsLambda.ts index 8d696fabdf5..693a3883ef4 100644 --- a/web-api/src/lambdas/users/getNotificationsLambda.ts +++ b/web-api/src/lambdas/users/getNotificationsLambda.ts @@ -1,16 +1,27 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getNotificationsInteractor } from '@shared/business/useCases/getNotificationsInteractor'; /** - * creates a new document and attaches it to a case. It also creates a work item on the docket section. + * creates a new document and attaches it to a case. It also creates a work item on the docket section. * * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getNotificationsLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getNotificationsInteractor(applicationContext, { - ...event.queryStringParameters, - }); - }); +export const getNotificationsLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getNotificationsInteractor( + applicationContext, + { + ...event.queryStringParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 2aa2e74c893ffe0af14af4ec6411e34904633527 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 22:16:57 -0700 Subject: [PATCH 023/523] devex: Update interactors to accept authorizedUser as an argument --- .../getPaperServicePdfUrlInteractor.ts | 6 +++--- .../getPaperServicePdfUrlLambda.ts | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/shared/src/business/useCases/getPaperServicePdfUrlInteractor.ts b/shared/src/business/useCases/getPaperServicePdfUrlInteractor.ts index a103813b8ff..47b5fc1b6be 100644 --- a/shared/src/business/useCases/getPaperServicePdfUrlInteractor.ts +++ b/shared/src/business/useCases/getPaperServicePdfUrlInteractor.ts @@ -3,14 +3,14 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '../../../../web-api/src/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const getPaperServicePdfUrlInteractor = async ( applicationContext: IApplicationContext, { fileId }: { fileId: string }, + authorizedUser: UnknownAuthUser, ): Promise<{ url: string }> => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts b/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts index 4edcb2131ff..d5bde74eb13 100644 --- a/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts +++ b/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts @@ -1,16 +1,21 @@ import { APIGatewayProxyEvent } from 'aws-lambda'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getPaperServicePdfUrlInteractor } from '@shared/business/useCases/getPaperServicePdfUrlInteractor'; -export const getPaperServicePdfUrlLambda = (event: APIGatewayProxyEvent) => +export const getPaperServicePdfUrlLambda = ( + event: APIGatewayProxyEvent, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getPaperServicePdfUrlInteractor( - applicationContext, - event.pathParameters, - ); + return await getPaperServicePdfUrlInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); }, + authorizedUser, { logResults: false }, ); From 2e93926860d16d23b2a5d1c20d92e997ab404763 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 22:19:39 -0700 Subject: [PATCH 024/523] devex: Update interactors to accept authorizedUser as an argument --- .../getReconciliationReportInteractor.ts | 3 ++- .../lambdas/v2/getReconciliationReportLambda.ts | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/shared/src/business/useCases/getReconciliationReportInteractor.ts b/shared/src/business/useCases/getReconciliationReportInteractor.ts index 8602e31ec64..0be273383c2 100644 --- a/shared/src/business/useCases/getReconciliationReportInteractor.ts +++ b/shared/src/business/useCases/getReconciliationReportInteractor.ts @@ -13,6 +13,7 @@ import { } from '../../authorization/authorizationClientService'; import { ReconciliationReportEntry } from '../entities/ReconciliationReportEntry'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; function isValidTime(time: string): boolean { return isValidDateString(time, [FORMATS.TIME_24_HOUR]); @@ -37,8 +38,8 @@ export const getReconciliationReportInteractor = async ( end?: string; start?: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.SERVICE_SUMMARY_REPORT)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/v2/getReconciliationReportLambda.ts b/web-api/src/lambdas/v2/getReconciliationReportLambda.ts index 0af2640ea4b..4a80cc25114 100644 --- a/web-api/src/lambdas/v2/getReconciliationReportLambda.ts +++ b/web-api/src/lambdas/v2/getReconciliationReportLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getReconciliationReportInteractor } from '@shared/business/useCases/getReconciliationReportInteractor'; import { v2ApiWrapper } from './v2ApiWrapper'; /** @@ -10,7 +12,11 @@ import { v2ApiWrapper } from './v2ApiWrapper'; * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the reconciliation report */ -export const getReconciliationReportLambda = (event, options = {}) => +export const getReconciliationReportLambda = ( + event, + authorizedUser: UnknownAuthUser, + options = {}, +) => genericHandler( event, ({ applicationContext }) => { @@ -18,12 +24,15 @@ export const getReconciliationReportLambda = (event, options = {}) => const { end, start } = event.queryStringParameters; //url will contain the reconciliation date in path parameters, and times in the query string const parms = { ...event.pathParameters, end, start }; - const report = await applicationContext - .getUseCases() - .getReconciliationReportInteractor(applicationContext, parms); + const report = await getReconciliationReportInteractor( + applicationContext, + parms, + authorizedUser, + ); return report; }); }, + authorizedUser, options, ); From 28fb051c620e9bf6987150186df020d35037ac88 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 22:21:13 -0700 Subject: [PATCH 025/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/getUploadPolicyInteractor.ts | 8 +++---- .../documents/getUploadPolicyLambda.ts | 24 ++++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/shared/src/business/useCases/getUploadPolicyInteractor.ts b/shared/src/business/useCases/getUploadPolicyInteractor.ts index 4c5c42c5264..96fe18cdd6c 100644 --- a/shared/src/business/useCases/getUploadPolicyInteractor.ts +++ b/shared/src/business/useCases/getUploadPolicyInteractor.ts @@ -3,6 +3,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../entities/User'; /** @@ -14,15 +15,14 @@ import { User } from '../entities/User'; export const getUploadPolicyInteractor = async ( applicationContext: IApplicationContext, { key }: { key: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.UPLOAD_DOCUMENT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPLOAD_DOCUMENT)) { throw new UnauthorizedError('Unauthorized'); } // we don't want external users to be able to overwrite existing s3 files - if (User.isExternalUser(user.role)) { + if (User.isExternalUser(authorizedUser.role)) { const isFileExists = await applicationContext .getPersistenceGateway() .isFileExists({ diff --git a/web-api/src/lambdas/documents/getUploadPolicyLambda.ts b/web-api/src/lambdas/documents/getUploadPolicyLambda.ts index b6610a30c62..1ba60acb3f0 100644 --- a/web-api/src/lambdas/documents/getUploadPolicyLambda.ts +++ b/web-api/src/lambdas/documents/getUploadPolicyLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getUploadPolicyInteractor } from '@shared/business/useCases/getUploadPolicyInteractor'; /** * used for getting the upload policy which is needed for users to upload directly to S3 via the UI @@ -6,11 +8,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getUploadPolicyLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getUploadPolicyInteractor(applicationContext, { - key: event.pathParameters.key, - }); - }); +export const getUploadPolicyLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getUploadPolicyInteractor( + applicationContext, + { + key: event.pathParameters.key, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 63dee458a16a96304dd36f6d09718cd35648879b Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 22:28:58 -0700 Subject: [PATCH 026/523] devex: Update interactors to accept authorizedUser as an argument --- shared/src/business/useCases/getUserInteractor.ts | 11 +++++++++-- web-api/src/lambdas/users/getUserLambda.ts | 9 +++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/shared/src/business/useCases/getUserInteractor.ts b/shared/src/business/useCases/getUserInteractor.ts index b4cba4c596a..b4505dd479e 100644 --- a/shared/src/business/useCases/getUserInteractor.ts +++ b/shared/src/business/useCases/getUserInteractor.ts @@ -2,15 +2,22 @@ import { IrsPractitioner, RawIrsPractitioner, } from '../entities/IrsPractitioner'; -import { NotFoundError } from '../../../../web-api/src/errors/errors'; +import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors'; import { Practitioner, RawPractitioner } from '../entities/Practitioner'; import { PrivatePractitioner } from '../entities/PrivatePractitioner'; import { RawUser, User } from '../entities/User'; +import { + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; export const getUserInteractor = async ( applicationContext: IApplicationContext, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); + if (!isAuthUser(authorizedUser)) { + throw new UnauthorizedError('Not authorized to get user'); + } const user = await applicationContext .getPersistenceGateway() diff --git a/web-api/src/lambdas/users/getUserLambda.ts b/web-api/src/lambdas/users/getUserLambda.ts index 212142d8d58..41324a7d8f3 100644 --- a/web-api/src/lambdas/users/getUserLambda.ts +++ b/web-api/src/lambdas/users/getUserLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getUserInteractor } from '@shared/business/useCases/getUserInteractor'; /** * used for fetching full user data @@ -6,14 +8,13 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getUserLambda = event => +export const getUserLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getUserInteractor(applicationContext); + return await getUserInteractor(applicationContext, authorizedUser); }, + authorizedUser, { bypassMaintenanceCheck: true, }, From 026a1ccf5dd7be67c911da60bd0236a07fdc41af Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 22:31:24 -0700 Subject: [PATCH 027/523] devex: Update interactors to accept authorizedUser as an argument --- .../opinionAdvancedSearchInteractor.ts | 4 +-- .../documents/opinionAdvancedSearchLambda.ts | 33 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/shared/src/business/useCases/opinionAdvancedSearchInteractor.ts b/shared/src/business/useCases/opinionAdvancedSearchInteractor.ts index 21ef2c5c9ec..0eedf229dd1 100644 --- a/shared/src/business/useCases/opinionAdvancedSearchInteractor.ts +++ b/shared/src/business/useCases/opinionAdvancedSearchInteractor.ts @@ -7,6 +7,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { omit } from 'lodash'; export const opinionAdvancedSearchInteractor = async ( @@ -30,9 +31,8 @@ export const opinionAdvancedSearchInteractor = async ( opinionTypes: string[]; startDate: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADVANCED_SEARCH)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/documents/opinionAdvancedSearchLambda.ts b/web-api/src/lambdas/documents/opinionAdvancedSearchLambda.ts index 85c92250957..03974974652 100644 --- a/web-api/src/lambdas/documents/opinionAdvancedSearchLambda.ts +++ b/web-api/src/lambdas/documents/opinionAdvancedSearchLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { opinionAdvancedSearchInteractor } from '@shared/business/useCases/opinionAdvancedSearchInteractor'; /** * used for fetching opinions matching the provided search string @@ -6,15 +8,24 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const opinionAdvancedSearchLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const opinionTypes = - event.queryStringParameters.opinionTypes?.split(',') || []; +export const opinionAdvancedSearchLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const opinionTypes = + event.queryStringParameters.opinionTypes?.split(',') || []; - return await applicationContext - .getUseCases() - .opinionAdvancedSearchInteractor(applicationContext, { - ...event.queryStringParameters, - opinionTypes, - }); - }); + return await opinionAdvancedSearchInteractor( + applicationContext, + { + ...event.queryStringParameters, + opinionTypes, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 58680c91869e2256773855d96dcf7ab3fcd5317f Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 22:33:07 -0700 Subject: [PATCH 028/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/orderAdvancedSearchInteractor.ts | 4 ++-- .../documents/orderAdvancedSearchLambda.ts | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/shared/src/business/useCases/orderAdvancedSearchInteractor.ts b/shared/src/business/useCases/orderAdvancedSearchInteractor.ts index 3d2320f9b37..de3877e2931 100644 --- a/shared/src/business/useCases/orderAdvancedSearchInteractor.ts +++ b/shared/src/business/useCases/orderAdvancedSearchInteractor.ts @@ -10,6 +10,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../entities/User'; import { caseSearchFilter } from '../utilities/caseFilter'; import { omit } from 'lodash'; @@ -35,9 +36,8 @@ export const orderAdvancedSearchInteractor = async ( keyword: string; startDate: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADVANCED_SEARCH)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/documents/orderAdvancedSearchLambda.ts b/web-api/src/lambdas/documents/orderAdvancedSearchLambda.ts index 912a91feee0..99cadfff47a 100644 --- a/web-api/src/lambdas/documents/orderAdvancedSearchLambda.ts +++ b/web-api/src/lambdas/documents/orderAdvancedSearchLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { orderAdvancedSearchInteractor } from '@shared/business/useCases/orderAdvancedSearchInteractor'; /** * used for fetching orders matching the provided search string @@ -6,12 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const orderAdvancedSearchLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .orderAdvancedSearchInteractor( +export const orderAdvancedSearchLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await orderAdvancedSearchInteractor( applicationContext, event.queryStringParameters, + authorizedUser, ); - }); + }, + authorizedUser, + ); From c405ea9edd7ad0f101b2041fef7b8a4180a979f5 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 19 Jun 2024 22:40:15 -0700 Subject: [PATCH 029/523] devex: Update interactors to accept authorizedUser as an argument --- .../useCases/prioritizeCaseInteractor.ts | 11 ++++---- .../src/lambdas/cases/prioritizeCaseLambda.ts | 26 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/shared/src/business/useCases/prioritizeCaseInteractor.ts b/shared/src/business/useCases/prioritizeCaseInteractor.ts index 3dbdcd04c00..c835af35e20 100644 --- a/shared/src/business/useCases/prioritizeCaseInteractor.ts +++ b/shared/src/business/useCases/prioritizeCaseInteractor.ts @@ -3,7 +3,9 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -15,11 +17,10 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the case data */ export const prioritizeCase = async ( - applicationContext, - { docketNumber, reason }, -) => { - const authorizedUser = applicationContext.getCurrentUser(); - + applicationContext: ServerApplicationContext, + { docketNumber, reason }: { docketNumber: string; reason: string }, + authorizedUser: UnknownAuthUser, +): Promise => { if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.PRIORITIZE_CASE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/cases/prioritizeCaseLambda.ts b/web-api/src/lambdas/cases/prioritizeCaseLambda.ts index f46596591e6..01a34579d2e 100644 --- a/web-api/src/lambdas/cases/prioritizeCaseLambda.ts +++ b/web-api/src/lambdas/cases/prioritizeCaseLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { prioritizeCaseInteractor } from '@shared/business/useCases/prioritizeCaseInteractor'; /** * used for prioritizing a case @@ -6,12 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const prioritizeCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .prioritizeCaseInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const prioritizeCaseLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await prioritizeCaseInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From c1744690b33460a6015f296420fb6449294c84d8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 25 Jun 2024 15:07:27 -0700 Subject: [PATCH 030/523] Devex: Begin pattern for fixing interactor unit tests where applicationContext.getCurrentUser has been replaced by user argument to interactor --- .../generateDraftStampOrderInteractor.test.ts | 75 +++++++++---------- shared/src/test/mockAuthUsers.ts | 16 ++++ 2 files changed, 52 insertions(+), 39 deletions(-) create mode 100644 shared/src/test/mockAuthUsers.ts diff --git a/shared/src/business/useCases/generateDraftStampOrderInteractor.test.ts b/shared/src/business/useCases/generateDraftStampOrderInteractor.test.ts index d8f6baba6f9..b7bcfc54840 100644 --- a/shared/src/business/useCases/generateDraftStampOrderInteractor.test.ts +++ b/shared/src/business/useCases/generateDraftStampOrderInteractor.test.ts @@ -1,9 +1,9 @@ -import { MOTION_DISPOSITIONS, ROLES } from '../entities/EntityConstants'; +import { MOTION_DISPOSITIONS } from '../entities/EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; import { generateDraftStampOrderInteractor } from './generateDraftStampOrderInteractor'; +import { mockJudgeUser, mockPetitionerUser } from '@shared/test/mockAuthUsers'; describe('generateDraftStampOrderInteractor', () => { - let mockCurrentUser; const docketNumber = '999-99'; const formattedDraftDocumentTitle = 'Motion GRANTED'; const motionDocketEntryId = '67fb412e-cb00-454c-9739-fa90a09dca1d'; @@ -11,48 +11,41 @@ describe('generateDraftStampOrderInteractor', () => { const stampData = { disposition: MOTION_DISPOSITIONS.GRANTED }; const stampedDocketEntryId = 'e9bdeaa1-8c49-479e-9f21-6f3303307f48'; - beforeEach(() => { - mockCurrentUser = { - role: ROLES.judge, - userId: '8675309b-18d0-43ec-bafb-654e83405411', - }; - - applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser); + it('throws an Unauthorized error when the user role is not allowed to access the method', async () => { + await expect( + generateDraftStampOrderInteractor( + applicationContext, + { + docketNumber, + formattedDraftDocumentTitle, + motionDocketEntryId, + parentMessageId, + stampData, + stampedDocketEntryId, + }, + mockPetitionerUser, + ), + ).rejects.toThrow('Unauthorized'); }); - it('throws an Unauthorized error if the user role is not allowed to access the method', async () => { - mockCurrentUser = { - role: ROLES.petitioner, - userId: '8675309b-18d0-43ec-bafb-654e83405411', - }; - - await expect( - generateDraftStampOrderInteractor(applicationContext, { + it('should add a docket entry for the draft stamp order', async () => { + await generateDraftStampOrderInteractor( + applicationContext, + { docketNumber, formattedDraftDocumentTitle, motionDocketEntryId, parentMessageId, stampData, stampedDocketEntryId, - }), - ).rejects.toThrow('Unauthorized'); - }); - - it('should add a docket entry for the draft stamp order', async () => { - await generateDraftStampOrderInteractor(applicationContext, { - docketNumber, - formattedDraftDocumentTitle, - motionDocketEntryId, - parentMessageId, - stampData, - stampedDocketEntryId, - }); + }, + mockJudgeUser, + ); expect( applicationContext.getUseCaseHelpers() .addDraftStampOrderDocketEntryInteractor, ).toHaveBeenCalled(); - expect( applicationContext.getUseCaseHelpers() .addDraftStampOrderDocketEntryInteractor.mock.calls[0][1], @@ -67,14 +60,18 @@ describe('generateDraftStampOrderInteractor', () => { }); it('should generate a stamped coversheet for the draft stamp order', async () => { - await generateDraftStampOrderInteractor(applicationContext, { - docketNumber, - formattedDraftDocumentTitle, - motionDocketEntryId, - parentMessageId, - stampData, - stampedDocketEntryId, - }); + await generateDraftStampOrderInteractor( + applicationContext, + { + docketNumber, + formattedDraftDocumentTitle, + motionDocketEntryId, + parentMessageId, + stampData, + stampedDocketEntryId, + }, + mockJudgeUser, + ); expect( applicationContext.getUseCaseHelpers() diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts new file mode 100644 index 00000000000..57124a79a81 --- /dev/null +++ b/shared/src/test/mockAuthUsers.ts @@ -0,0 +1,16 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { ROLES } from '@shared/business/entities/EntityConstants'; + +export const mockPetitionerUser: AuthUser = { + email: 'mockPetitioner@example.com', + name: 'Tax Payer', + role: ROLES.petitioner, + userId: 'e4988d2d-deb0-4b65-a97f-5abfadb0970a', +}; + +export const mockJudgeUser: AuthUser = { + email: 'mockJudge@example.com', + name: 'Judge Judy', + role: ROLES.judge, + userId: '3a13531b-0fc5-4a4c-8188-c72f50b1889d', +}; From 7f80f7269da8ebe27558515638b69c9d3a83db54 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 25 Jun 2024 15:12:31 -0700 Subject: [PATCH 031/523] Devex: Update tests to pass in authUser --- ...ePractitionerCaseListPdfInteractor.test.ts | 66 +++++++++++-------- shared/src/test/mockAuthUsers.ts | 6 ++ 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.test.ts b/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.test.ts index 0538d54321e..62643396490 100644 --- a/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.test.ts +++ b/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.test.ts @@ -1,15 +1,13 @@ -import { CASE_STATUS_TYPES, ROLES } from '../entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; import { applicationContext } from '../test/createTestApplicationContext'; import { generatePractitionerCaseListPdfInteractor } from './generatePractitionerCaseListPdfInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('generatePractitionerCaseListPdfInteractor', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); - }); - beforeEach(() => { applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ barNumber: 'PT1234', @@ -18,14 +16,14 @@ describe('generatePractitionerCaseListPdfInteractor', () => { }); it('returns an unauthorized error on non internal users', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: ROLES.petitioner, - }); - await expect( - generatePractitionerCaseListPdfInteractor(applicationContext, { - userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + generatePractitionerCaseListPdfInteractor( + applicationContext, + { + userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -51,9 +49,13 @@ describe('generatePractitionerCaseListPdfInteractor', () => { .fn() .mockResolvedValue('pdf'); - await generatePractitionerCaseListPdfInteractor(applicationContext, { - userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await generatePractitionerCaseListPdfInteractor( + applicationContext, + { + userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getUserById, @@ -70,9 +72,13 @@ describe('generatePractitionerCaseListPdfInteractor', () => { }); await expect( - generatePractitionerCaseListPdfInteractor(applicationContext, { - userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + generatePractitionerCaseListPdfInteractor( + applicationContext, + { + userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Practitioner not found'); }); @@ -104,9 +110,13 @@ describe('generatePractitionerCaseListPdfInteractor', () => { .fn() .mockResolvedValue('pdf'); - await generatePractitionerCaseListPdfInteractor(applicationContext, { - userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await generatePractitionerCaseListPdfInteractor( + applicationContext, + { + userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCasesByDocketNumbers, @@ -146,9 +156,13 @@ describe('generatePractitionerCaseListPdfInteractor', () => { .fn() .mockResolvedValue('pdf'); - await generatePractitionerCaseListPdfInteractor(applicationContext, { - userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await generatePractitionerCaseListPdfInteractor( + applicationContext, + { + userId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCasesByDocketNumbers, diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index 57124a79a81..2ee624ac9d3 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -7,6 +7,12 @@ export const mockPetitionerUser: AuthUser = { role: ROLES.petitioner, userId: 'e4988d2d-deb0-4b65-a97f-5abfadb0970a', }; +export const mockDocketClerkUser: AuthUser = { + email: 'mockDocketClerk@example.com', + name: 'Dimmy Docket', + role: ROLES.docketClerk, + userId: 'e4988d2d-deb0-4b65-a97f-5abfadb0970a', +}; export const mockJudgeUser: AuthUser = { email: 'mockJudge@example.com', From e3b74d3008ddefc28072da848d62359b7ee05351 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 25 Jun 2024 15:14:48 -0700 Subject: [PATCH 032/523] Devex: Update tests to pass in authUser --- .../getAllUsersByRoleInteractor.test.ts | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/shared/src/business/useCases/getAllUsersByRoleInteractor.test.ts b/shared/src/business/useCases/getAllUsersByRoleInteractor.test.ts index cdaa46972af..803076d25ac 100644 --- a/shared/src/business/useCases/getAllUsersByRoleInteractor.test.ts +++ b/shared/src/business/useCases/getAllUsersByRoleInteractor.test.ts @@ -1,32 +1,40 @@ import { applicationContext } from '../test/createTestApplicationContext'; -import { docketClerkUser } from '@shared/test/mockUsers'; import { getAllUsersByRoleInteractor } from '@shared/business/useCases/getAllUsersByRoleInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getAllUsersByRoleInteractor', () => { const TEST_ROLES = ['SOME', 'ROLES']; const EXPECTED_RESULTS = ['user1', 'user2']; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); applicationContext .getPersistenceGateway() .getAllUsersByRole.mockReturnValue(EXPECTED_RESULTS); }); it('should throw an Unauthorized error when user does not have permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - getAllUsersByRoleInteractor(applicationContext, { - roles: TEST_ROLES, - }), + getAllUsersByRoleInteractor( + applicationContext, + { + roles: TEST_ROLES, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should call the persistance method with corred params', async () => { - const results = await getAllUsersByRoleInteractor(applicationContext, { - roles: TEST_ROLES, - }); + const results = await getAllUsersByRoleInteractor( + applicationContext, + { + roles: TEST_ROLES, + }, + mockDocketClerkUser, + ); expect(results).toEqual(EXPECTED_RESULTS); From 9ca68eb75355f81cdc7b214d37eafdbbaaf24cde Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 25 Jun 2024 15:17:56 -0700 Subject: [PATCH 033/523] Devex: Update tests to pass in authUser --- .../getBlockedCasesInteractor.test.ts | 35 ++++++++++--------- shared/src/test/mockAuthUsers.ts | 9 ++++- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/shared/src/business/useCases/getBlockedCasesInteractor.test.ts b/shared/src/business/useCases/getBlockedCasesInteractor.test.ts index b5eda2819b7..b3f8ee91a63 100644 --- a/shared/src/business/useCases/getBlockedCasesInteractor.test.ts +++ b/shared/src/business/useCases/getBlockedCasesInteractor.test.ts @@ -1,14 +1,12 @@ -import { ROLES } from '../entities/EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; import { getBlockedCasesInteractor } from './getBlockedCasesInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getBlockedCasesInteractor', () => { it('calls search function with correct params and returns records', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); - applicationContext.getPersistenceGateway().getBlockedCases.mockReturnValue([ { docketNumber: '101-20', @@ -18,9 +16,13 @@ describe('getBlockedCasesInteractor', () => { }, ]); - const results = await getBlockedCasesInteractor(applicationContext, { - trialLocation: 'Boise, Idaho', - }); + const results = await getBlockedCasesInteractor( + applicationContext, + { + trialLocation: 'Boise, Idaho', + }, + mockPetitionsClerkUser, + ); expect(results).toEqual([ { @@ -33,16 +35,15 @@ describe('getBlockedCasesInteractor', () => { }); it('should throw an unauthorized error if the user does not have access to blocked cases', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'petitioner', - }); - let error; try { - await getBlockedCasesInteractor(applicationContext, { - trialLocation: 'Boise, Idaho', - }); + await getBlockedCasesInteractor( + applicationContext, + { + trialLocation: 'Boise, Idaho', + }, + mockPetitionerUser, + ); } catch (err) { error = err; } diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index 2ee624ac9d3..ff6011435c7 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -11,7 +11,7 @@ export const mockDocketClerkUser: AuthUser = { email: 'mockDocketClerk@example.com', name: 'Dimmy Docket', role: ROLES.docketClerk, - userId: 'e4988d2d-deb0-4b65-a97f-5abfadb0970a', + userId: '612e3eb3-332c-4f1f-aaff-44ac8eae9a5f', }; export const mockJudgeUser: AuthUser = { @@ -20,3 +20,10 @@ export const mockJudgeUser: AuthUser = { role: ROLES.judge, userId: '3a13531b-0fc5-4a4c-8188-c72f50b1889d', }; + +export const mockPetitionsClerkUser: AuthUser = { + email: 'mockPetitionsClerke@example.com', + name: 'Patty Petitions Clerk', + role: ROLES.petitionsClerk, + userId: 'd5234a80-64aa-4e3e-b0fd-59e6a835585e', +}; From 2b39db3cab7fef4cd92c9c8500e7107593e92c1c Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 25 Jun 2024 15:21:04 -0700 Subject: [PATCH 034/523] Devex: Update tests to pass in authUser --- .../getCaseDeadlinesInteractor.test.ts | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/shared/src/business/useCases/getCaseDeadlinesInteractor.test.ts b/shared/src/business/useCases/getCaseDeadlinesInteractor.test.ts index 3e376859d3a..a75bd091125 100644 --- a/shared/src/business/useCases/getCaseDeadlinesInteractor.test.ts +++ b/shared/src/business/useCases/getCaseDeadlinesInteractor.test.ts @@ -4,12 +4,14 @@ import { COUNTRY_TYPES, DOCKET_NUMBER_SUFFIXES, PARTY_TYPES, - ROLES, } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; -import { User } from '../entities/User'; import { applicationContext } from '../test/createTestApplicationContext'; import { getCaseDeadlinesInteractor } from './getCaseDeadlinesInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getCaseDeadlinesInteractor', () => { const mockDeadlines = [ @@ -79,12 +81,6 @@ describe('getCaseDeadlinesInteractor', () => { }, ]; - const mockPetitionsClerk = new User({ - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - const START_DATE = '2019-08-25T05:00:00.000Z'; const END_DATE = '2020-08-25T05:00:00.000Z'; @@ -99,14 +95,15 @@ describe('getCaseDeadlinesInteractor', () => { applicationContext .getPersistenceGateway() .getCasesByDocketNumbers.mockReturnValue(mockCases); - applicationContext.getCurrentUser.mockReturnValue(mockPetitionsClerk); }); - it('throws an error if the user is not valid or authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue(new User({})); - + it('throws an error when the user is not valid or authorized', async () => { await expect( - getCaseDeadlinesInteractor(applicationContext, {} as any), + getCaseDeadlinesInteractor( + applicationContext, + {} as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -114,6 +111,7 @@ describe('getCaseDeadlinesInteractor', () => { const result = await getCaseDeadlinesInteractor( applicationContext, {} as any, + mockPetitionsClerkUser, ); expect(result).toEqual({ @@ -152,13 +150,17 @@ describe('getCaseDeadlinesInteractor', () => { }); it('passes date and filtering params to getCaseDeadlinesByDateRange persistence call', async () => { - await getCaseDeadlinesInteractor(applicationContext, { - endDate: END_DATE, - from: 20, - judge: 'Buch', - pageSize: 50, - startDate: START_DATE, - }); + await getCaseDeadlinesInteractor( + applicationContext, + { + endDate: END_DATE, + from: 20, + judge: 'Buch', + pageSize: 50, + startDate: START_DATE, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseDeadlinesByDateRange @@ -219,7 +221,6 @@ describe('getCaseDeadlinesInteractor', () => { ], }, ]); - applicationContext .getPersistenceGateway() .getCaseDeadlinesByDateRange.mockReturnValue({ @@ -241,6 +242,7 @@ describe('getCaseDeadlinesInteractor', () => { const result = await getCaseDeadlinesInteractor( applicationContext, {} as any, + mockPetitionsClerkUser, ); expect(result).toEqual({ From 84b9be4e768e2731e84331d41965d8791dde8800 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 25 Jun 2024 15:34:45 -0700 Subject: [PATCH 035/523] Devex: Update tests to pass in authUser --- .../useCases/getCaseInteractor.test.ts | 271 +++++++++--------- shared/src/test/mockAuthUsers.ts | 9 +- 2 files changed, 150 insertions(+), 130 deletions(-) diff --git a/shared/src/business/useCases/getCaseInteractor.test.ts b/shared/src/business/useCases/getCaseInteractor.test.ts index b50af5b8dd8..2ec61d4a0b7 100644 --- a/shared/src/business/useCases/getCaseInteractor.test.ts +++ b/shared/src/business/useCases/getCaseInteractor.test.ts @@ -12,14 +12,18 @@ import { applicationContext } from '../test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; import { decorateForCaseStatus, getCaseInteractor } from './getCaseInteractor'; import { getOtherFilers } from '../entities/cases/Case'; +import { + mockDocketClerkUser, + mockPetitionerUser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getCaseInteractor', () => { const petitionsclerkId = '23c4d382-1136-492f-b1f4-45e893c34771'; - const docketClerkId = '44c4d382-1136-492f-b1f4-45e893c34771'; const irsPractitionerId = '6cf19fba-18c6-467a-9ea6-7a14e42add2f'; const practitionerId = '295c3640-7ff9-40bb-b2f1-8117bba084ea'; const practitioner2Id = '42614976-4228-49aa-a4c3-597dae1c7220'; - const petitionerId = '42624376-4228-49aa-a4c3-597dae1c7220'; const irsSuperuserId = '5a5c771d-ab63-4d78-a298-1de657dde621'; let testCase; @@ -35,9 +39,13 @@ describe('getCaseInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(testCase); - await getCaseInteractor(applicationContext, { - docketNumber: '000123-19S', - }); + await getCaseInteractor( + applicationContext, + { + docketNumber: '000123-19S', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber.mock @@ -49,11 +57,6 @@ describe('getCaseInteractor', () => { }); it('should throw an error when a case with the provided docketNumber is not found', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', - role: ROLES.petitionsClerk, - userId: petitionsclerkId, - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue( @@ -69,9 +72,13 @@ describe('getCaseInteractor', () => { ); await expect( - getCaseInteractor(applicationContext, { - docketNumber: '123-19', - }), + getCaseInteractor( + applicationContext, + { + docketNumber: '123-19', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Case 123-19 was not found.'); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber.mock @@ -90,19 +97,17 @@ describe('getCaseInteractor', () => { .getCaseByDocketNumber.mockReturnValue(mockInvalidCase); await expect( - getCaseInteractor(applicationContext, { - docketNumber: '00101-08', - }), + getCaseInteractor( + applicationContext, + { + docketNumber: '00101-08', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('The Case entity was invalid'); }); it('should return the case when the currentUser is an unassociated IRS practitioner', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'IRS Practitionerr', - role: ROLES.irsPractitioner, - userId: irsPractitionerId, - }); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockResolvedValue({ @@ -117,20 +122,23 @@ describe('getCaseInteractor', () => { userId: '320fce0e-b050-4e04-8720-db25da3ca598', }); - const result = await getCaseInteractor(applicationContext, { - docketNumber: '00101-00', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '00101-00', + }, + { + email: 'access@example.com', + name: 'IRS Practitionerr', + role: ROLES.irsPractitioner, + userId: irsPractitionerId, + }, + ); expect(result.docketNumber).toEqual('101-00'); }); it('should return the case when the currentUser is an irs superuser even if the case has sealed documents', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'IRS Superuser', - role: ROLES.irsSuperuser, - userId: irsSuperuserId, - }); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockResolvedValue({ @@ -155,9 +163,18 @@ describe('getCaseInteractor', () => { userId: '320fce0e-b050-4e04-8720-db25da3ca598', }); - const result = await getCaseInteractor(applicationContext, { - docketNumber: '00101-00', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '00101-00', + }, + { + email: 'superduper@example.com', + name: 'IRS Superuser', + role: ROLES.irsSuperuser, + userId: irsSuperuserId, + }, + ); expect(result.docketEntries[1]).toMatchObject({ docketEntryId: testCase.docketEntries[2].docketEntryId, @@ -167,9 +184,6 @@ describe('getCaseInteractor', () => { }); it('should return the case when the currentUser is the contactPrimary on the case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - userId: 'dc56e26e-f9fd-4165-8997-97676cc0523e', - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue( @@ -179,16 +193,20 @@ describe('getCaseInteractor', () => { petitioners: [ { ...mockCaseContactPrimary, - contactId: 'dc56e26e-f9fd-4165-8997-97676cc0523e', + contactId: mockPetitionerUser.userId, }, ], userId: '320fce0e-b050-4e04-8720-db25da3ca598', }), ); - const result = await getCaseInteractor(applicationContext, { - docketNumber: '00101-00', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '00101-00', + }, + mockPetitionerUser, + ); expect(result.docketNumber).toEqual('101-00'); expect(result.petitioners[0].address1).toBeDefined(); @@ -196,9 +214,6 @@ describe('getCaseInteractor', () => { }); it('should return the case when the currentUser is the contactSecondary on the case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - userId: '754a3191-884f-42f0-ad2c-e6c706685299', - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockResolvedValue({ @@ -212,16 +227,20 @@ describe('getCaseInteractor', () => { }, { ...mockCaseContactPrimary, - contactId: '754a3191-884f-42f0-ad2c-e6c706685299', + contactId: mockPetitionerUser.userId, contactType: CONTACT_TYPES.secondary, }, ], userId: '320fce0e-b050-4e04-8720-db25da3ca598', }); - const result = await getCaseInteractor(applicationContext, { - docketNumber: '00101-00', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '00101-00', + }, + mockPetitionerUser, + ); expect(result.docketNumber).toEqual('101-00'); expect(result.petitioners[0].address1).toBeDefined(); @@ -229,11 +248,6 @@ describe('getCaseInteractor', () => { }); it('should return the full case (non public) when the user is part of the consolidated group', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', - role: ROLES.petitioner, - userId: petitionerId, - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue({ @@ -245,7 +259,7 @@ describe('getCaseInteractor', () => { petitioners: [ { ...testCase.petitioners[0], - contactId: petitionerId, + contactId: mockPetitionerUser.userId, }, ], }, @@ -254,9 +268,14 @@ describe('getCaseInteractor', () => { leadDocketNumber: '101-20', }); - const result = await getCaseInteractor(applicationContext, { - docketNumber: '101-18', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '101-18', + }, + mockPetitionerUser, + ); + expect(result.entityName).toEqual('Case'); }); @@ -276,15 +295,13 @@ describe('getCaseInteractor', () => { }); it(`allows unfiltered view of sealed contact addresses when role is ${ROLES.docketClerk}`, async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Security Officer Worf', - role: ROLES.docketClerk, - userId: docketClerkId, - }); - - const result = await getCaseInteractor(applicationContext, { - docketNumber: '101-18', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '101-18', + }, + mockDocketClerkUser, + ); const contactPrimary = result.petitioners[0]; const contactSecondary = result.petitioners[1]; @@ -299,15 +316,13 @@ describe('getCaseInteractor', () => { }); it('returns limited contact address information when address is sealed and requesting user is not docket clerk', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Reginald Barclay', - role: ROLES.privatePractitioner, - userId: applicationContext.getUniqueId(), - }); - - const result = await getCaseInteractor(applicationContext, { - docketNumber: '101-18', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '101-18', + }, + mockPrivatePractitionerUser, + ); expect(result.petitioners[0].city).toBeUndefined(); expect(result.petitioners[1].city).toBeUndefined(); @@ -350,15 +365,13 @@ describe('getCaseInteractor', () => { }); it('should return a PublicCase entity when the current user is NOT authorized to view a sealed case and is NOT associated with the case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', - role: ROLES.privatePractitioner, - userId: practitioner2Id, - }); - - const result = await getCaseInteractor(applicationContext, { - docketNumber: '101-18', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '101-18', + }, + mockPrivatePractitionerUser, + ); expect(result).toEqual({ canAllowDocumentService: undefined, @@ -378,15 +391,13 @@ describe('getCaseInteractor', () => { }); it('should return a Case entity when the current user is authorized to view a sealed case and is NOT associated with the case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', - role: ROLES.docketClerk, - userId: docketClerkId, - }); - - const result = await getCaseInteractor(applicationContext, { - docketNumber: '101-18', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '101-18', + }, + mockDocketClerkUser, + ); const contactPrimary = result.petitioners[0]; expect(contactPrimary.address1).toBeDefined(); @@ -394,15 +405,18 @@ describe('getCaseInteractor', () => { }); it('should return a Case entity when the current user is associated with a sealed case and NOT authorized to view it', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', - role: ROLES.privatePractitioner, - userId: practitionerId, - }); - - const result = await getCaseInteractor(applicationContext, { - docketNumber: '101-18', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '101-18', + }, + { + email: 'noaccess@example.com', + name: 'Katherine Pulaski', + role: ROLES.privatePractitioner, + userId: practitionerId, + }, + ); const contactPrimary = result.petitioners[0]; expect(contactPrimary.address1).toBeDefined(); @@ -430,15 +444,13 @@ describe('getCaseInteractor', () => { }); it('should return a Case entity when the current user is an internal user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', - role: ROLES.docketClerk, - userId: docketClerkId, - }); - - const result = await getCaseInteractor(applicationContext, { - docketNumber: '101-18', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '101-18', + }, + mockDocketClerkUser, + ); const contactPrimary = result.petitioners[0]; expect(contactPrimary.address1).toBeDefined(); @@ -446,15 +458,13 @@ describe('getCaseInteractor', () => { }); it('should return a PublicCase entity when the current user is an external user who is NOT associated with the case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', - role: ROLES.privatePractitioner, - userId: practitionerId, - }); - - const result = await getCaseInteractor(applicationContext, { - docketNumber: '101-18', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '101-18', + }, + mockPrivatePractitionerUser, + ); const contactPrimary = result.petitioners[0]; expect(contactPrimary.address1).toBeUndefined(); @@ -463,15 +473,18 @@ describe('getCaseInteractor', () => { }); it('should return a Case entity when the current user is associated with the case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', - role: ROLES.privatePractitioner, - userId: practitioner2Id, - }); - - const result = await getCaseInteractor(applicationContext, { - docketNumber: '101-18', - }); + const result = await getCaseInteractor( + applicationContext, + { + docketNumber: '101-18', + }, + { + email: 'accessgranted@example.com', + name: 'Katherine Pulaski', + role: ROLES.privatePractitioner, + userId: practitioner2Id, + }, + ); const contactPrimary = result.petitioners[0]; expect(contactPrimary.address1).toBeDefined(); diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index ff6011435c7..faa373f46f0 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -22,8 +22,15 @@ export const mockJudgeUser: AuthUser = { }; export const mockPetitionsClerkUser: AuthUser = { - email: 'mockPetitionsClerke@example.com', + email: 'mockPetitionsClerk@example.com', name: 'Patty Petitions Clerk', role: ROLES.petitionsClerk, userId: 'd5234a80-64aa-4e3e-b0fd-59e6a835585e', }; + +export const mockPrivatePractitionerUser: AuthUser = { + email: 'mockPrivatePractitioner@example.com', + name: 'Reginald Barclay', + role: ROLES.privatePractitioner, + userId: '73dedd03-e353-4703-bf6b-5b864b8c16ae', +}; From bfdd530fa2ddd61a6a3e95312a60c20dfd63e450 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 25 Jun 2024 15:39:19 -0700 Subject: [PATCH 036/523] Devex: Update tests to pass in authUser --- .../getCasesForUserInteractor.test.ts | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/shared/src/business/useCases/getCasesForUserInteractor.test.ts b/shared/src/business/useCases/getCasesForUserInteractor.test.ts index 1bb462bd729..ccee1c3ff25 100644 --- a/shared/src/business/useCases/getCasesForUserInteractor.test.ts +++ b/shared/src/business/useCases/getCasesForUserInteractor.test.ts @@ -1,11 +1,16 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { CASE_STATUS_TYPES } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; import { applicationContext } from '../test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; import { getCasesForUserInteractor } from './getCasesForUserInteractor'; +import { mockPetitionerUser } from '@shared/test/mockAuthUsers'; describe('getCasesForUserInteractor', () => { - const userId = MOCK_CASE.petitioners[0].contactId; + const mockPetitioner: AuthUser = { + ...mockPetitionerUser, + userId: MOCK_CASE.petitioners[0].contactId, + }; let leadCase; let memberCase1; let memberCase2; @@ -64,10 +69,6 @@ describe('getCasesForUserInteractor', () => { }); consolidatedGroupLeadCase11119 = [leadCase, memberCase1, memberCase2]; - - applicationContext.getCurrentUser.mockResolvedValue({ - userId, - }); }); describe('Consolidated cases', () => { it('should return the expected associated cases combined with the consolidated group cases for 111-19', async () => { @@ -102,7 +103,10 @@ describe('getCasesForUserInteractor', () => { consolidatedGroupLeadCase11119, ); - const userCases = await getCasesForUserInteractor(applicationContext); + const userCases = await getCasesForUserInteractor( + applicationContext, + mockPetitioner, + ); expect(userCases).toMatchObject({ closedCaseList: [ @@ -165,7 +169,10 @@ describe('getCasesForUserInteractor', () => { consolidatedGroup, ); - const userCases = await getCasesForUserInteractor(applicationContext); + const userCases = await getCasesForUserInteractor( + applicationContext, + mockPetitioner, + ); const expectedCaseList = [ expect.objectContaining({ @@ -201,7 +208,10 @@ describe('getCasesForUserInteractor', () => { consolidatedGroup, ); - const userCases = await getCasesForUserInteractor(applicationContext); + const userCases = await getCasesForUserInteractor( + applicationContext, + mockPetitioner, + ); const expectedCaseList = [ expect.objectContaining({ @@ -237,7 +247,10 @@ describe('getCasesForUserInteractor', () => { consolidatedGroup, ); - const userCases = await getCasesForUserInteractor(applicationContext); + const userCases = await getCasesForUserInteractor( + applicationContext, + mockPetitioner, + ); const expectedCaseList = [ expect.objectContaining({ @@ -298,7 +311,10 @@ describe('getCasesForUserInteractor', () => { consolidatedGroup, ); - const userCases = await getCasesForUserInteractor(applicationContext); + const userCases = await getCasesForUserInteractor( + applicationContext, + mockPetitioner, + ); const actualOrder = userCases.closedCaseList.map( aCase => aCase.docketNumber, @@ -341,7 +357,10 @@ describe('getCasesForUserInteractor', () => { consolidatedGroupLeadCase11119, ); - const userCases = await getCasesForUserInteractor(applicationContext); + const userCases = await getCasesForUserInteractor( + applicationContext, + mockPetitioner, + ); expect(unconsolidatedCase1.docketEntries).toBeDefined(); expect(unconsolidatedCase2.docketEntries).toBeDefined(); @@ -379,7 +398,10 @@ describe('getCasesForUserInteractor', () => { unconsolidatedClosedCase1, ]); - const userCases = await getCasesForUserInteractor(applicationContext); + const userCases = await getCasesForUserInteractor( + applicationContext, + mockPetitioner, + ); expect(userCases.closedCaseList).toEqual([ expect.objectContaining({ @@ -426,7 +448,7 @@ describe('getCasesForUserInteractor', () => { //call validate to ensure that, yes, the case fails validation (todo) //call getCasesForUser and expect that no exceptions were thrown await expect( - getCasesForUserInteractor(applicationContext), + getCasesForUserInteractor(applicationContext, mockPetitioner), ).resolves.not.toThrow(); }); }); From e8d94db626a438084e05614cc71c46a64140ff17 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 26 Jun 2024 09:52:40 -0700 Subject: [PATCH 037/523] Devex: Update tests get user from state. Fix imports --- web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts | 2 +- web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts | 2 +- web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts | 2 +- web-api/src/lambdas/cases/createCaseFromPaperLambda.ts | 2 +- web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts | 2 +- web-client/src/presenter/actions/createCaseAction.test.ts | 5 ++--- web-client/src/presenter/actions/createCaseAction.ts | 2 +- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts b/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts index 929521e35a9..ed15d56b9a5 100644 --- a/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts +++ b/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts @@ -1,5 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { addPetitionerToCaseInteractor } from '@shared/business/useCases/addPetitionerToCaseInteractor'; +import { addPetitionerToCaseInteractor } from '@web-api/business/useCases/addPetitionerToCaseInteractor'; import { genericHandler } from '../../genericHandler'; /** diff --git a/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts b/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts index f221e13d360..b88e3d88840 100644 --- a/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts +++ b/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts @@ -1,5 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { blockCaseFromTrialInteractor } from '@shared/business/useCases/blockCaseFromTrialInteractor'; +import { blockCaseFromTrialInteractor } from '@web-api/business/useCases/blockCaseFromTrialInteractor'; import { genericHandler } from '../../genericHandler'; /** diff --git a/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts b/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts index 0bf88c1f697..f74264a56f2 100644 --- a/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts +++ b/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts @@ -1,5 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { caseAdvancedSearchInteractor } from '@shared/business/useCases/caseAdvancedSearchInteractor'; +import { caseAdvancedSearchInteractor } from '@web-api/business/useCases/caseAdvancedSearchInteractor'; import { genericHandler } from '../../genericHandler'; /** diff --git a/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts b/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts index e50b3f0b2ff..627454890e0 100644 --- a/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts +++ b/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts @@ -1,5 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { createCaseFromPaperInteractor } from '@shared/business/useCases/createCaseFromPaperInteractor'; +import { createCaseFromPaperInteractor } from '@web-api/business/useCases/createCaseFromPaperInteractor'; import { genericHandler } from '../../genericHandler'; /** diff --git a/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts b/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts index e2c28461df6..8adaab4c58b 100644 --- a/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts +++ b/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts @@ -1,5 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { archiveDraftDocumentInteractor } from '@shared/business/useCases/archiveDraftDocumentInteractor'; +import { archiveDraftDocumentInteractor } from '@web-api/business/useCases/archiveDraftDocumentInteractor'; import { genericHandler } from '../../genericHandler'; /** diff --git a/web-client/src/presenter/actions/createCaseAction.test.ts b/web-client/src/presenter/actions/createCaseAction.test.ts index 68d83b148f3..a69e946f4d9 100644 --- a/web-client/src/presenter/actions/createCaseAction.test.ts +++ b/web-client/src/presenter/actions/createCaseAction.test.ts @@ -67,9 +67,6 @@ describe('createCaseAction', () => { petitionFileId: '123', stinFileId: '123', }); - applicationContext.getCurrentUser.mockReturnValue({ - email: 'petitioner1@example.com', - }); }); it('should call createCaseInteractor and addCoversheetInteractor THREE times (when we have an CDS form) with the petition metadata and files, then call the success path after completion', async () => { @@ -105,6 +102,7 @@ describe('createCaseAction', () => { }, state: { form: mockPetitionMetadata, + user: { email: 'petitioner1@example.com' }, }, }); @@ -144,6 +142,7 @@ describe('createCaseAction', () => { }, state: { form: mockPetitionMetadata, + user: { email: 'petitioner1@example.com' }, }, }); diff --git a/web-client/src/presenter/actions/createCaseAction.ts b/web-client/src/presenter/actions/createCaseAction.ts index 12a67c3c1ef..45f20b253f1 100644 --- a/web-client/src/presenter/actions/createCaseAction.ts +++ b/web-client/src/presenter/actions/createCaseAction.ts @@ -19,7 +19,7 @@ export const createCaseAction = async ({ const form: ElectronicCreatedCaseType = omit(petitionMetadata, 'trialCities'); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); form.contactPrimary.email = user.email; let caseDetail; From 155709d649e0963afa0dd765ae79e2f8a230fe51 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 10:37:51 -0700 Subject: [PATCH 038/523] devex: Set applicationContext to any for withLocking as giving it a type creates any functions when it retrns. --- web-api/src/business/useCaseHelper/acquireLock.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web-api/src/business/useCaseHelper/acquireLock.ts b/web-api/src/business/useCaseHelper/acquireLock.ts index bd8e4afd872..d4e3ec26343 100644 --- a/web-api/src/business/useCaseHelper/acquireLock.ts +++ b/web-api/src/business/useCaseHelper/acquireLock.ts @@ -130,24 +130,24 @@ export const removeLock = ({ */ export function withLocking( interactor: ( - applicationContext: ServerApplicationContext, + applicationContext: any, options: InteractorInput, authorizedUser: UnknownAuthUser, ) => Promise, getLockInfo: ( - applicationContext: ServerApplicationContext, + applicationContext: any, options: any, ) => | Promise<{ identifiers: string[]; ttl?: number }> | { identifiers: string[]; ttl?: number }, onLockError?: Error | Function, ): ( - applicationContext: ServerApplicationContext, + applicationContext: any, options: InteractorInput, authorizedUser: UnknownAuthUser, ) => Promise { return async function ( - applicationContext: ServerApplicationContext, + applicationContext: any, options: InteractorInput, authorizedUser: UnknownAuthUser, ) { From 993136d1dfbd720368ae612a27cacf3f86645e65 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 10:50:04 -0700 Subject: [PATCH 039/523] devex: Refactor to auth user --- .../addPetitionerToCaseInteractor.test.ts | 117 ++++++++++-------- 1 file changed, 63 insertions(+), 54 deletions(-) diff --git a/web-api/src/business/useCases/addPetitionerToCaseInteractor.test.ts b/web-api/src/business/useCases/addPetitionerToCaseInteractor.test.ts index fa114d9db73..c2e121096e6 100644 --- a/web-api/src/business/useCases/addPetitionerToCaseInteractor.test.ts +++ b/web-api/src/business/useCases/addPetitionerToCaseInteractor.test.ts @@ -7,12 +7,13 @@ import { } from '../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../shared/src/test/mockLock'; -import { - ServiceUnavailableError, - UnauthorizedError, -} from '@web-api/errors/errors'; +import { ServiceUnavailableError } from '@web-api/errors/errors'; import { addPetitionerToCaseInteractor } from './addPetitionerToCaseInteractor'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('addPetitionerToCaseInteractor', () => { let mockContact; @@ -38,11 +39,6 @@ describe('addPetitionerToCaseInteractor', () => { state: 'CO', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue({ @@ -58,11 +54,15 @@ describe('addPetitionerToCaseInteractor', () => { }); await expect( - addPetitionerToCaseInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, - contact: mockContact, - docketNumber: MOCK_CASE.docketNumber, - }), + addPetitionerToCaseInteractor( + applicationContext, + { + caseCaption: MOCK_CASE.caseCaption, + contact: mockContact, + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Unauthorized for adding petitioner to case'); }); @@ -75,27 +75,35 @@ describe('addPetitionerToCaseInteractor', () => { }); await expect( - addPetitionerToCaseInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, - contact: mockContact, - docketNumber: MOCK_CASE.docketNumber, - }), + addPetitionerToCaseInteractor( + applicationContext, + { + caseCaption: MOCK_CASE.caseCaption, + contact: mockContact, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow( `Case with docketNumber ${MOCK_CASE.docketNumber} has not been served`, ); }); it('should add the petitioner to the case and send the updated case to persistence, and return the updated case', async () => { - await addPetitionerToCaseInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, + await addPetitionerToCaseInteractor( + applicationContext, + { + caseCaption: MOCK_CASE.caseCaption, - contact: { - ...mockContact, - country: 'Georgia', - countryType: COUNTRY_TYPES.INTERNATIONAL, + contact: { + ...mockContact, + country: 'Georgia', + countryType: COUNTRY_TYPES.INTERNATIONAL, + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -114,6 +122,7 @@ describe('addPetitionerToCaseInteractor', () => { contact: mockContact, docketNumber: MOCK_CASE.docketNumber, }, + mockDocketClerkUser, ); expect(updatedCase.petitioners.length).toEqual(2); @@ -130,11 +139,15 @@ describe('addPetitionerToCaseInteractor', () => { const mockUpdatedCaption = 'An updated caption'; - await addPetitionerToCaseInteractor(applicationContext, { - caseCaption: mockUpdatedCaption, - contact: mockContact, - docketNumber: MOCK_CASE.docketNumber, - }); + await addPetitionerToCaseInteractor( + applicationContext, + { + caseCaption: mockUpdatedCaption, + contact: mockContact, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -146,11 +159,15 @@ describe('addPetitionerToCaseInteractor', () => { mockLock = MOCK_LOCK; await expect( - addPetitionerToCaseInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, - contact: mockContact, - docketNumber: MOCK_CASE.docketNumber, - }), + addPetitionerToCaseInteractor( + applicationContext, + { + caseCaption: MOCK_CASE.caseCaption, + contact: mockContact, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -159,11 +176,15 @@ describe('addPetitionerToCaseInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await addPetitionerToCaseInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, - contact: mockContact, - docketNumber: MOCK_CASE.docketNumber, - }); + await addPetitionerToCaseInteractor( + applicationContext, + { + caseCaption: MOCK_CASE.caseCaption, + contact: mockContact, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -180,16 +201,4 @@ describe('addPetitionerToCaseInteractor', () => { identifiers: [`case|${MOCK_CASE.docketNumber}`], }); }); - - it('should throw an Unauthorized error if the user is not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - - await expect( - addPetitionerToCaseInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, - contact: mockContact, - docketNumber: MOCK_CASE.docketNumber, - }), - ).rejects.toThrow(UnauthorizedError); - }); }); From f6633c19f7773b723f5a4655d8f4f9150ea5bf55 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 10:55:18 -0700 Subject: [PATCH 040/523] devex: Update getworkItemInteractor --- .../workItems/getWorkItemInteractor.test.ts | 52 +++++++++---------- .../workItems/getWorkItemInteractor.ts | 12 +++-- .../lambdas/workitems/getWorkItemLambda.ts | 24 ++++++--- 3 files changed, 51 insertions(+), 37 deletions(-) diff --git a/web-api/src/business/useCases/workItems/getWorkItemInteractor.test.ts b/web-api/src/business/useCases/workItems/getWorkItemInteractor.test.ts index 53b805d7b35..ed1010f4439 100644 --- a/web-api/src/business/useCases/workItems/getWorkItemInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/getWorkItemInteractor.test.ts @@ -1,9 +1,10 @@ -import { - DOCKET_SECTION, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { DOCKET_SECTION } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getWorkItemInteractor } from './getWorkItemInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getWorkItemInteractor', () => { let mockWorkItem = { @@ -28,26 +29,19 @@ describe('getWorkItemInteractor', () => { workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }; - const mockPetitionerUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - - const mockDocketClerkUser = { - role: ROLES.docketClerk, - userId: 'docketclerk', - }; - it('throws an error if the work item was not found', async () => { - applicationContext.getCurrentUser.mockReturnValue(mockPetitionerUser); applicationContext .getPersistenceGateway() .getWorkItemById.mockResolvedValue(null); let error; try { - await getWorkItemInteractor(applicationContext, { - workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await getWorkItemInteractor( + applicationContext, + { + workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockPetitionerUser, + ); } catch (e) { error = e; } @@ -55,16 +49,19 @@ describe('getWorkItemInteractor', () => { }); it('throws an error if the user does not have access to the work item', async () => { - applicationContext.getCurrentUser.mockReturnValue(mockPetitionerUser); applicationContext .getPersistenceGateway() .getWorkItemById.mockResolvedValue(mockWorkItem); let error; try { - await getWorkItemInteractor(applicationContext, { - workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await getWorkItemInteractor( + applicationContext, + { + workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockPetitionerUser, + ); } catch (e) { error = e; } @@ -72,14 +69,17 @@ describe('getWorkItemInteractor', () => { }); it('successfully returns the work item for a docketclerk', async () => { - applicationContext.getCurrentUser.mockReturnValue(mockDocketClerkUser); applicationContext .getPersistenceGateway() .getWorkItemById.mockResolvedValue(mockWorkItem); - const result = await getWorkItemInteractor(applicationContext, { - workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + const result = await getWorkItemInteractor( + applicationContext, + { + workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ docketEntry: { sentBy: 'petitioner' }, docketNumber: '101-18', diff --git a/web-api/src/business/useCases/workItems/getWorkItemInteractor.ts b/web-api/src/business/useCases/workItems/getWorkItemInteractor.ts index b524124150e..a97e59ffa0a 100644 --- a/web-api/src/business/useCases/workItems/getWorkItemInteractor.ts +++ b/web-api/src/business/useCases/workItems/getWorkItemInteractor.ts @@ -4,6 +4,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; /** @@ -17,6 +18,7 @@ import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; export const getWorkItemInteractor = async ( applicationContext: ServerApplicationContext, { workItemId }: { workItemId: string }, + authorizedUser: UnknownAuthUser, ) => { const workItem = await applicationContext .getPersistenceGateway() @@ -29,9 +31,13 @@ export const getWorkItemInteractor = async ( throw new NotFoundError(`WorkItem ${workItemId} was not found.`); } - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.WORKITEM, workItem.assigneeId)) { + if ( + !isAuthorized( + authorizedUser, + ROLE_PERMISSIONS.WORKITEM, + workItem.assigneeId, + ) + ) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/workitems/getWorkItemLambda.ts b/web-api/src/lambdas/workitems/getWorkItemLambda.ts index b3858ba5813..96e1d10465c 100644 --- a/web-api/src/lambdas/workitems/getWorkItemLambda.ts +++ b/web-api/src/lambdas/workitems/getWorkItemLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getWorkItemInteractor } from '@web-api/business/useCases/workItems/getWorkItemInteractor'; /** * returns a single work item via the workItemId passed in the path of the url @@ -6,11 +8,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getWorkItemLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getWorkItemInteractor(applicationContext, { - workItemId: event.pathParameters.workItemId, - }); - }); +export const getWorkItemLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getWorkItemInteractor( + applicationContext, + { + workItemId: event.pathParameters.workItemId, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 6abdda8521dd8cbfcbcbc0705fa0514393f96080 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 11:00:26 -0700 Subject: [PATCH 041/523] devex: refactor to authUser --- .../reports/coldCaseReportInteractor.test.ts | 26 ++++++++----------- .../reports/coldCaseReportInteractor.ts | 6 ++--- .../lambdas/reports/coldCaseReportLambda.ts | 16 +++++++----- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/web-api/src/business/useCases/reports/coldCaseReportInteractor.test.ts b/web-api/src/business/useCases/reports/coldCaseReportInteractor.test.ts index a54b487baaa..8561e3e1903 100644 --- a/web-api/src/business/useCases/reports/coldCaseReportInteractor.test.ts +++ b/web-api/src/business/useCases/reports/coldCaseReportInteractor.test.ts @@ -1,7 +1,10 @@ import { ColdCaseEntry } from './coldCaseReportInteractor'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { coldCaseReportInteractor } from './coldCaseReportInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('coldCaseReportInteractor', () => { const mockColdCases: ColdCaseEntry[] = [ @@ -23,23 +26,16 @@ describe('coldCaseReportInteractor', () => { }); it('should throw an unauthorized error when the user does not have access', async () => { - applicationContext.getCurrentUser.mockImplementation(() => ({ - role: ROLES.petitioner, - userId: 'petitioner', - })); - - await expect(coldCaseReportInteractor(applicationContext)).rejects.toThrow( - 'Unauthorized', - ); + await expect( + coldCaseReportInteractor(applicationContext, mockPetitionerUser), + ).rejects.toThrow('Unauthorized'); }); it('should return the expected mocked data', async () => { - applicationContext.getCurrentUser.mockImplementation(() => ({ - role: ROLES.docketClerk, - userId: 'docketclerk', - })); - - const coldCases = await coldCaseReportInteractor(applicationContext); + const coldCases = await coldCaseReportInteractor( + applicationContext, + mockDocketClerkUser, + ); expect(coldCases).toEqual(mockColdCases); }); diff --git a/web-api/src/business/useCases/reports/coldCaseReportInteractor.ts b/web-api/src/business/useCases/reports/coldCaseReportInteractor.ts index efe812b0974..25280457cea 100644 --- a/web-api/src/business/useCases/reports/coldCaseReportInteractor.ts +++ b/web-api/src/business/useCases/reports/coldCaseReportInteractor.ts @@ -4,6 +4,7 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export type ColdCaseEntry = { createdAt: string; @@ -17,10 +18,9 @@ export type ColdCaseEntry = { export const coldCaseReportInteractor = async ( applicationContext: ServerApplicationContext, + authorizedUser: UnknownAuthUser, ): Promise => { - const requestUser = applicationContext.getCurrentUser(); - - if (!isAuthorized(requestUser, ROLE_PERMISSIONS.COLD_CASE_REPORT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.COLD_CASE_REPORT)) { throw new UnauthorizedError( 'Unauthorized for viewing the cold case report data', ); diff --git a/web-api/src/lambdas/reports/coldCaseReportLambda.ts b/web-api/src/lambdas/reports/coldCaseReportLambda.ts index 0b2484b70d1..b118a6a93c9 100644 --- a/web-api/src/lambdas/reports/coldCaseReportLambda.ts +++ b/web-api/src/lambdas/reports/coldCaseReportLambda.ts @@ -1,8 +1,12 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { coldCaseReportInteractor } from '@web-api/business/useCases/reports/coldCaseReportInteractor'; import { genericHandler } from '../../genericHandler'; -export const coldCaseReportLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .coldCaseReportInteractor(applicationContext); - }); +export const coldCaseReportLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await coldCaseReportInteractor(applicationContext, authorizedUser); + }, + authorizedUser, + ); From 02e86bdabacc2a2e62065140da830255bc4bd560 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 11:12:03 -0700 Subject: [PATCH 042/523] devex: refactor to authUser --- .../getMessagesForCaseInteractor.test.ts | 25 +++++++++-------- .../messages/getMessagesForCaseInteractor.ts | 4 +-- .../messages/getMessagesForCaseLambda.ts | 27 +++++++++++++------ 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/web-api/src/business/useCases/messages/getMessagesForCaseInteractor.test.ts b/web-api/src/business/useCases/messages/getMessagesForCaseInteractor.test.ts index 22e0ac38251..38e6287940c 100644 --- a/web-api/src/business/useCases/messages/getMessagesForCaseInteractor.test.ts +++ b/web-api/src/business/useCases/messages/getMessagesForCaseInteractor.test.ts @@ -1,23 +1,25 @@ import { CASE_STATUS_TYPES, PETITIONS_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getMessagesForCaseInteractor } from './getMessagesForCaseInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getMessagesForCaseInteractor', () => { it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - getMessagesForCaseInteractor(applicationContext, { - docketNumber: '101-20', - }), + getMessagesForCaseInteractor( + applicationContext, + { + docketNumber: '101-20', + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -42,10 +44,6 @@ describe('getMessagesForCaseInteractor', () => { toSection: PETITIONS_SECTION, toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getMessagesByDocketNumber.mockReturnValue([mockMessage]); @@ -55,6 +53,7 @@ describe('getMessagesForCaseInteractor', () => { { docketNumber: mockMessage.docketNumber, }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/messages/getMessagesForCaseInteractor.ts b/web-api/src/business/useCases/messages/getMessagesForCaseInteractor.ts index 6724e2af7ae..3755469add7 100644 --- a/web-api/src/business/useCases/messages/getMessagesForCaseInteractor.ts +++ b/web-api/src/business/useCases/messages/getMessagesForCaseInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * gets messages for a case @@ -17,9 +18,8 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const getMessagesForCaseInteractor = async ( applicationContext: ServerApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/getMessagesForCaseLambda.ts b/web-api/src/lambdas/messages/getMessagesForCaseLambda.ts index ee14f7ae3d0..337eec7c549 100644 --- a/web-api/src/lambdas/messages/getMessagesForCaseLambda.ts +++ b/web-api/src/lambdas/messages/getMessagesForCaseLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getMessagesForCaseInteractor } from '@web-api/business/useCases/messages/getMessagesForCaseInteractor'; /** * lambda which is used for retrieving messages for a case @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getMessagesForCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getMessagesForCaseInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const getMessagesForCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getMessagesForCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 8e717209e6b98450f5d3ef682806f1872b4e82cf Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 11:15:02 -0700 Subject: [PATCH 043/523] devex: refactor to authUser --- ...PractitionersBySearchKeyInteractor.test.ts | 31 +++++++------------ ...etIrsPractitionersBySearchKeyInteractor.ts | 6 ++-- .../getIrsPractitionersBySearchKeyLambda.ts | 29 +++++++++++------ 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.test.ts b/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.test.ts index 4639eb73a55..45112573c76 100644 --- a/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.test.ts +++ b/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.test.ts @@ -1,32 +1,30 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getIrsPractitionersBySearchKeyInteractor } from './getIrsPractitionersBySearchKeyInteractor'; - -let user; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getIrsPractitionersBySearchKeyInteractor', () => { beforeEach(() => { applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockImplementation(() => user); }); it('should throw an error when not authorized', async () => { - user = { - barNumber: 'PT1234', - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - applicationContext .getPersistenceGateway() .getUsersBySearchKey.mockResolvedValue([]); let error; try { - await getIrsPractitionersBySearchKeyInteractor(applicationContext, { - searchKey: 'something', - }); + await getIrsPractitionersBySearchKeyInteractor( + applicationContext, + { + searchKey: 'something', + }, + mockPetitionerUser, + ); } catch (err) { error = err; } @@ -34,12 +32,6 @@ describe('getIrsPractitionersBySearchKeyInteractor', () => { }); it('should return users from persistence', async () => { - user = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - applicationContext .getPersistenceGateway() .getUsersBySearchKey.mockResolvedValue([ @@ -56,6 +48,7 @@ describe('getIrsPractitionersBySearchKeyInteractor', () => { { searchKey: 'Test Practitioner', }, + mockPetitionsClerkUser, ); expect(result).toMatchObject([{ name: 'Test Practitioner' }]); diff --git a/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.ts b/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.ts index 93419f16f65..9efbcb7ff32 100644 --- a/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.ts +++ b/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * getIrsPractitionersBySearchKeyInteractor @@ -17,11 +18,10 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const getIrsPractitionersBySearchKeyInteractor = async ( applicationContext: ServerApplicationContext, { searchKey }: { searchKey: string }, + authorizedUser: UnknownAuthUser, ) => { - const authenticatedUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(authenticatedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) ) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/users/getIrsPractitionersBySearchKeyLambda.ts b/web-api/src/lambdas/users/getIrsPractitionersBySearchKeyLambda.ts index 3f56c5575be..371df8a2b61 100644 --- a/web-api/src/lambdas/users/getIrsPractitionersBySearchKeyLambda.ts +++ b/web-api/src/lambdas/users/getIrsPractitionersBySearchKeyLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getIrsPractitionersBySearchKeyInteractor } from '@web-api/business/useCases/user/getIrsPractitionersBySearchKeyInteractor'; /** * gets irsPractitioner users by a search string (name or bar number) @@ -6,13 +8,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getIrsPractitionersBySearchKeyLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { searchKey } = event.queryStringParameters; +export const getIrsPractitionersBySearchKeyLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { searchKey } = event.queryStringParameters; - return await applicationContext - .getUseCases() - .getIrsPractitionersBySearchKeyInteractor(applicationContext, { - searchKey, - }); - }); + return await getIrsPractitionersBySearchKeyInteractor( + applicationContext, + { + searchKey, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 9fe17a59a62718b090f9b4ad3a80cb2ce8b19faf Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 11:20:38 -0700 Subject: [PATCH 044/523] devex: refactor to authUser --- shared/src/test/mockAuthUsers.ts | 7 +++++ ...getPractitionerDocumentsInteractor.test.ts | 22 ++++++++------- .../getPractitionerDocumentsInteractor.ts | 6 ++--- .../getPractitionerDocumentsLambda.ts | 27 +++++++++++++------ 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index faa373f46f0..8ffed72514d 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -34,3 +34,10 @@ export const mockPrivatePractitionerUser: AuthUser = { role: ROLES.privatePractitioner, userId: '73dedd03-e353-4703-bf6b-5b864b8c16ae', }; + +export const mockAdmissionsClerkUser: AuthUser = { + email: 'mockAdmissionsClerk@example.com', + name: 'Nora Scott', + role: ROLES.admissionsClerk, + userId: 'e796d8cd-2e85-4d79-b4e1-281b59cacd5f', +}; diff --git a/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.test.ts b/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.test.ts index e36dbadbbe7..0fe5d026179 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.test.ts @@ -1,15 +1,12 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getPractitionerDocumentsInteractor } from './getPractitionerDocumentsInteractor'; +import { + mockAdmissionsClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getPractitionersDocumentsInteractor', () => { - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'admissionsClerk', - }); - }); - it('throws an unauthorized error exception when user is not an admissions clerk', async () => { applicationContext.getCurrentUser.mockReturnValue({ role: ROLES.petitioner, @@ -17,9 +14,13 @@ describe('getPractitionersDocumentsInteractor', () => { }); await expect( - getPractitionerDocumentsInteractor(applicationContext, { - barNumber: 'PT1234', - }), + getPractitionerDocumentsInteractor( + applicationContext, + { + barNumber: 'PT1234', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for getting practitioner documents'); }); @@ -47,6 +48,7 @@ describe('getPractitionersDocumentsInteractor', () => { { barNumber: 'PT1234', }, + mockAdmissionsClerkUser, ); expect(documents.length).toEqual(1); diff --git a/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.ts b/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.ts index d632a9b8ddd..c40e6616a34 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * getPractitionerDocumentsInteractor @@ -21,11 +22,10 @@ export const getPractitionerDocumentsInteractor = async ( }: { barNumber: string; }, + authorizedUser: UnknownAuthUser, ) => { - const requestUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(requestUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) ) { throw new UnauthorizedError( 'Unauthorized for getting practitioner documents', diff --git a/web-api/src/lambdas/practitioners/getPractitionerDocumentsLambda.ts b/web-api/src/lambdas/practitioners/getPractitionerDocumentsLambda.ts index 4237b4c8d59..3779f536b99 100644 --- a/web-api/src/lambdas/practitioners/getPractitionerDocumentsLambda.ts +++ b/web-api/src/lambdas/practitioners/getPractitionerDocumentsLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getPractitionerDocumentsInteractor } from '@web-api/business/useCases/practitioner/getPractitionerDocumentsInteractor'; /** * creates a practitioner document for a practitioner @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getPractitionerDocumentsLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getPractitionerDocumentsInteractor(applicationContext, { - barNumber: event.pathParameters.barNumber, - }); - }); +export const getPractitionerDocumentsLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getPractitionerDocumentsInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 7f1e7d6f25c325b6162175f2fba3cbe7fecb7a4e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 11:22:55 -0700 Subject: [PATCH 045/523] devex: refactor to authUser --- ...pletedMessagesForSectionInteractor.test.ts | 25 +++++++++-------- ...etCompletedMessagesForSectionInteractor.ts | 4 +-- .../getCompletedMessagesForSectionLambda.ts | 27 +++++++++++++------ 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/web-api/src/business/useCases/messages/getCompletedMessagesForSectionInteractor.test.ts b/web-api/src/business/useCases/messages/getCompletedMessagesForSectionInteractor.test.ts index 54a78bec552..69f8639f8ab 100644 --- a/web-api/src/business/useCases/messages/getCompletedMessagesForSectionInteractor.test.ts +++ b/web-api/src/business/useCases/messages/getCompletedMessagesForSectionInteractor.test.ts @@ -2,24 +2,26 @@ import { CASE_STATUS_TYPES, DOCKET_SECTION, PETITIONS_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getCompletedMessagesForSectionInteractor } from './getCompletedMessagesForSectionInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('getCompletedMessagesForSectionInteractor', () => { it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - getCompletedMessagesForSectionInteractor(applicationContext, { - section: DOCKET_SECTION, - }), + getCompletedMessagesForSectionInteractor( + applicationContext, + { + section: DOCKET_SECTION, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -51,10 +53,6 @@ describe('getCompletedMessagesForSectionInteractor', () => { toSection: PETITIONS_SECTION, toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getCompletedSectionInboxMessages.mockReturnValue([messageData]); @@ -64,6 +62,7 @@ describe('getCompletedMessagesForSectionInteractor', () => { { section: DOCKET_SECTION, }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/messages/getCompletedMessagesForSectionInteractor.ts b/web-api/src/business/useCases/messages/getCompletedMessagesForSectionInteractor.ts index 50ee9b9d8e1..dea4a478395 100644 --- a/web-api/src/business/useCases/messages/getCompletedMessagesForSectionInteractor.ts +++ b/web-api/src/business/useCases/messages/getCompletedMessagesForSectionInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * getCompletedMessagesForSectionInteractor @@ -17,9 +18,8 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const getCompletedMessagesForSectionInteractor = async ( applicationContext: ServerApplicationContext, { section }: { section }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/getCompletedMessagesForSectionLambda.ts b/web-api/src/lambdas/messages/getCompletedMessagesForSectionLambda.ts index 02440b0a6d4..cd836a37a23 100644 --- a/web-api/src/lambdas/messages/getCompletedMessagesForSectionLambda.ts +++ b/web-api/src/lambdas/messages/getCompletedMessagesForSectionLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCompletedMessagesForSectionInteractor } from '@web-api/business/useCases/messages/getCompletedMessagesForSectionInteractor'; /** * gets the completed messages for the section @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCompletedMessagesForSectionLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCompletedMessagesForSectionInteractor(applicationContext, { - section: event.pathParameters.section, - }); - }); +export const getCompletedMessagesForSectionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getCompletedMessagesForSectionInteractor( + applicationContext, + { + section: event.pathParameters.section, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 6fec88664160721f06ac90135141aaf916d171c0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 11:25:55 -0700 Subject: [PATCH 046/523] devex: refactor to authUser --- ...getOutboxMessagesForUserInteractor.test.ts | 25 +++++++++-------- .../getOutboxMessagesForUserInteractor.ts | 4 +-- .../getOutboxMessagesForUserLambda.ts | 27 +++++++++++++------ 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/web-api/src/business/useCases/messages/getOutboxMessagesForUserInteractor.test.ts b/web-api/src/business/useCases/messages/getOutboxMessagesForUserInteractor.test.ts index a3e940cccf1..11518cb8968 100644 --- a/web-api/src/business/useCases/messages/getOutboxMessagesForUserInteractor.test.ts +++ b/web-api/src/business/useCases/messages/getOutboxMessagesForUserInteractor.test.ts @@ -1,24 +1,26 @@ import { CASE_STATUS_TYPES, PETITIONS_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getOutboxMessagesForUserInteractor } from './getOutboxMessagesForUserInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('getOutboxMessagesForUserInteractor', () => { it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - getOutboxMessagesForUserInteractor(applicationContext, { - userId: 'bob', - }), + getOutboxMessagesForUserInteractor( + applicationContext, + { + userId: 'bob', + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -47,10 +49,6 @@ describe('getOutboxMessagesForUserInteractor', () => { trialDate: '2028-03-01T21:40:46.415Z', trialLocation: 'El Paso, Texas', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getUserOutboxMessages.mockReturnValue([messageData]); @@ -60,6 +58,7 @@ describe('getOutboxMessagesForUserInteractor', () => { { userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/messages/getOutboxMessagesForUserInteractor.ts b/web-api/src/business/useCases/messages/getOutboxMessagesForUserInteractor.ts index c2c15e30ce9..1e509895c56 100644 --- a/web-api/src/business/useCases/messages/getOutboxMessagesForUserInteractor.ts +++ b/web-api/src/business/useCases/messages/getOutboxMessagesForUserInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * getOutboxMessagesForUserInteractor @@ -17,9 +18,8 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const getOutboxMessagesForUserInteractor = async ( applicationContext: ServerApplicationContext, { userId }: { userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/getOutboxMessagesForUserLambda.ts b/web-api/src/lambdas/messages/getOutboxMessagesForUserLambda.ts index 953b4bde3cd..432d0cf209f 100644 --- a/web-api/src/lambdas/messages/getOutboxMessagesForUserLambda.ts +++ b/web-api/src/lambdas/messages/getOutboxMessagesForUserLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getOutboxMessagesForUserInteractor } from '@web-api/business/useCases/messages/getOutboxMessagesForUserInteractor'; /** * gets the outbox messages for the user @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getOutboxMessagesForUserLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getOutboxMessagesForUserInteractor(applicationContext, { - userId: event.pathParameters.userId, - }); - }); +export const getOutboxMessagesForUserLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getOutboxMessagesForUserInteractor( + applicationContext, + { + userId: event.pathParameters.userId, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 9f28e5eb5f10df41d69936c90bafeddcbf15f737 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 11:34:45 -0700 Subject: [PATCH 047/523] devex: refactor to authUser --- ...ppendAmendedPetitionFormInteractor.test.ts | 75 +++++++++++-------- .../appendAmendedPetitionFormInteractor.ts | 4 +- .../appendAmendedPetitionFormLambda.ts | 19 +++-- 3 files changed, 59 insertions(+), 39 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedOrder/appendAmendedPetitionFormInteractor.test.ts b/web-api/src/business/useCases/courtIssuedOrder/appendAmendedPetitionFormInteractor.test.ts index f2fc68b3a0b..d174d4ab64f 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/appendAmendedPetitionFormInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/appendAmendedPetitionFormInteractor.test.ts @@ -1,9 +1,10 @@ -import { - AMENDED_PETITION_FORM_NAME, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { AMENDED_PETITION_FORM_NAME } from '../../../../../shared/src/business/entities/EntityConstants'; import { appendAmendedPetitionFormInteractor } from './appendAmendedPetitionFormInteractor'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; const mockDocketEntryId = 'd594360c-0514-4acd-a2ac-24a402060756'; @@ -13,11 +14,6 @@ describe('appendAmendedPetitionFormInteractor', () => { const returnedCombinedPdf = 'ever'; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: '432', - }); - applicationContext .getPersistenceGateway() .getDocument.mockReturnValue(fakeFile1); @@ -34,13 +30,12 @@ describe('appendAmendedPetitionFormInteractor', () => { }); it('should throw an error when the user is not authorized to modify docket entries', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '432', - }); - await expect( - appendAmendedPetitionFormInteractor(applicationContext, {} as any), + appendAmendedPetitionFormInteractor( + applicationContext, + {} as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -50,16 +45,24 @@ describe('appendAmendedPetitionFormInteractor', () => { .getDocument.mockRejectedValueOnce('Not Found'); await expect( - appendAmendedPetitionFormInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - }), + appendAmendedPetitionFormInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(`Docket entry ${mockDocketEntryId} was not found`); }); it('should use the provided docketEntryId to retrieve the file from s3', async () => { - await appendAmendedPetitionFormInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - }); + await appendAmendedPetitionFormInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDocument.mock.calls[0][0] @@ -68,9 +71,13 @@ describe('appendAmendedPetitionFormInteractor', () => { }); it('should make a call to retrieve the amended petition form from s3', async () => { - await appendAmendedPetitionFormInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - }); + await appendAmendedPetitionFormInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getStorageClient().getObject.mock.calls[0][0].Key, @@ -78,9 +85,13 @@ describe('appendAmendedPetitionFormInteractor', () => { }); it('should make a call to combine the order and form documents', async () => { - await appendAmendedPetitionFormInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - }); + await appendAmendedPetitionFormInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getUtilities().combineTwoPdfs.mock.calls[0][0], @@ -91,9 +102,13 @@ describe('appendAmendedPetitionFormInteractor', () => { }); it('should use the provided docketEntryId to overwrite the order file in s3', async () => { - await appendAmendedPetitionFormInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - }); + await appendAmendedPetitionFormInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getUtilities().uploadToS3.mock.calls[0][0], diff --git a/web-api/src/business/useCases/courtIssuedOrder/appendAmendedPetitionFormInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/appendAmendedPetitionFormInteractor.ts index b1212c0627b..5724fa2338f 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/appendAmendedPetitionFormInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/appendAmendedPetitionFormInteractor.ts @@ -5,6 +5,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * @@ -17,9 +18,8 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; export const appendAmendedPetitionFormInteractor = async ( applicationContext: ServerApplicationContext, { docketEntryId }: { docketEntryId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - const hasPermission = isAuthorized( authorizedUser, ROLE_PERMISSIONS.EDIT_ORDER, diff --git a/web-api/src/lambdas/courtIssuedOrder/appendAmendedPetitionFormLambda.ts b/web-api/src/lambdas/courtIssuedOrder/appendAmendedPetitionFormLambda.ts index 236d2396485..655571734e8 100644 --- a/web-api/src/lambdas/courtIssuedOrder/appendAmendedPetitionFormLambda.ts +++ b/web-api/src/lambdas/courtIssuedOrder/appendAmendedPetitionFormLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { appendAmendedPetitionFormInteractor } from '@web-api/business/useCases/courtIssuedOrder/appendAmendedPetitionFormInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,16 +8,19 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const appendAmendedPetitionFormLambda = event => +export const appendAmendedPetitionFormLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .appendAmendedPetitionFormInteractor( - applicationContext, - event.pathParameters, - ); + return await appendAmendedPetitionFormInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); }, + authorizedUser, { logResults: false }, ); From 8408ff2a055b83114358fe9b99f15a2fd28ad94e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:08:03 -0700 Subject: [PATCH 048/523] devex: refactor to authUser --- .../setWorkItemAsReadInteractor.test.ts | 58 ++++++++++--------- .../workItems/setWorkItemAsReadInteractor.ts | 6 +- .../workitems/setWorkItemAsReadLambda.ts | 29 +++++++--- 3 files changed, 55 insertions(+), 38 deletions(-) diff --git a/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.test.ts b/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.test.ts index b20c5552ced..2819573f75c 100644 --- a/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.test.ts @@ -2,16 +2,17 @@ import { CASE_STATUS_TYPES, DOCKET_NUMBER_SUFFIXES, DOCKET_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { setWorkItemAsReadInteractor } from './setWorkItemAsReadInteractor'; describe('setWorkItemAsReadInteractor', () => { - let user; - const mockWorkItem = { assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', assigneeName: 'bob', @@ -26,13 +27,6 @@ describe('setWorkItemAsReadInteractor', () => { }; beforeEach(() => { - user = { - role: ROLES.docketClerk, - userId: 'docketclerk', - }; - - applicationContext.getCurrentUser.mockImplementation(() => user); - applicationContext .getPersistenceGateway() .getWorkItemById.mockResolvedValue(mockWorkItem); @@ -48,14 +42,14 @@ describe('setWorkItemAsReadInteractor', () => { }); it('should throw an error when an unauthorized user tries to invoke this interactor', async () => { - user = { - userId: 'baduser', - }; - await expect( - setWorkItemAsReadInteractor(applicationContext, { - workItemId: mockWorkItem.workItemId, - }), + setWorkItemAsReadInteractor( + applicationContext, + { + workItemId: mockWorkItem.workItemId, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -68,16 +62,24 @@ describe('setWorkItemAsReadInteractor', () => { }); await expect( - setWorkItemAsReadInteractor(applicationContext, { - workItemId: mockWorkItem.workItemId, - }), + setWorkItemAsReadInteractor( + applicationContext, + { + workItemId: mockWorkItem.workItemId, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(NotFoundError); }); it('should call updateDocketEntry with the docket entry work item marked as read', async () => { - await setWorkItemAsReadInteractor(applicationContext, { - workItemId: mockWorkItem.workItemId, - }); + await setWorkItemAsReadInteractor( + applicationContext, + { + workItemId: mockWorkItem.workItemId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateDocketEntry.mock @@ -88,9 +90,13 @@ describe('setWorkItemAsReadInteractor', () => { }); it('should call saveWorkItem with the work item marked as read', async () => { - await setWorkItemAsReadInteractor(applicationContext, { - workItemId: mockWorkItem.workItemId, - }); + await setWorkItemAsReadInteractor( + applicationContext, + { + workItemId: mockWorkItem.workItemId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem.mock.calls[0][0], diff --git a/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.ts b/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.ts index 19ded896870..a15699bbdf6 100644 --- a/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.ts +++ b/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.ts @@ -5,6 +5,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * setWorkItemAsReadInteractor @@ -17,10 +18,9 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; export const setWorkItemAsReadInteractor = async ( applicationContext: ServerApplicationContext, { workItemId }: { workItemId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.GET_READ_MESSAGES)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.GET_READ_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/workitems/setWorkItemAsReadLambda.ts b/web-api/src/lambdas/workitems/setWorkItemAsReadLambda.ts index b9f7b35564b..5a922d4e847 100644 --- a/web-api/src/lambdas/workitems/setWorkItemAsReadLambda.ts +++ b/web-api/src/lambdas/workitems/setWorkItemAsReadLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { setWorkItemAsReadInteractor } from '@web-api/business/useCases/workItems/setWorkItemAsReadInteractor'; /** * assigns a list of work item ids to an assignee @@ -6,13 +8,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const setWorkItemAsReadLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { workItemId } = event.pathParameters || {}; +export const setWorkItemAsReadLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { workItemId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .setWorkItemAsReadInteractor(applicationContext, { - workItemId, - }); - }); + return await setWorkItemAsReadInteractor( + applicationContext, + { + workItemId, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 96e937220980d7f88d7ba324791999ae57f4f068 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:10:39 -0700 Subject: [PATCH 049/523] devex: refactor to authUser --- .../blockCaseFromTrialInteractor.test.ts | 60 +++++++++++-------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/web-api/src/business/useCases/blockCaseFromTrialInteractor.test.ts b/web-api/src/business/useCases/blockCaseFromTrialInteractor.test.ts index 72ccfba2e17..6e3197f3113 100644 --- a/web-api/src/business/useCases/blockCaseFromTrialInteractor.test.ts +++ b/web-api/src/business/useCases/blockCaseFromTrialInteractor.test.ts @@ -1,9 +1,12 @@ import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../shared/src/test/mockLock'; -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { blockCaseFromTrialInteractor } from './blockCaseFromTrialInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('blockCaseFromTrialInteractor', () => { let mockLock; @@ -14,10 +17,6 @@ describe('blockCaseFromTrialInteractor', () => { }); beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); @@ -30,10 +29,14 @@ describe('blockCaseFromTrialInteractor', () => { }); it('should update the case with the blocked flag set as true and attach a reason', async () => { - const result = await blockCaseFromTrialInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }); + const result = await blockCaseFromTrialInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ); expect(result).toMatchObject({ blocked: true, @@ -53,10 +56,14 @@ describe('blockCaseFromTrialInteractor', () => { mockLock = MOCK_LOCK; await expect( - blockCaseFromTrialInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }), + blockCaseFromTrialInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -65,10 +72,14 @@ describe('blockCaseFromTrialInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await blockCaseFromTrialInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }); + await blockCaseFromTrialInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -87,15 +98,14 @@ describe('blockCaseFromTrialInteractor', () => { }); it('should throw an unauthorized error if the user has no access to block cases', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: 'nope', - userId: 'nope', - }); - await expect( - blockCaseFromTrialInteractor(applicationContext, { - docketNumber: '123-45', - } as any), + blockCaseFromTrialInteractor( + applicationContext, + { + docketNumber: '123-45', + } as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); }); From 936c308fb5c6e7905bb563a4ef690cd1e7b9a460 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:15:24 -0700 Subject: [PATCH 050/523] devex: refactor to authUser --- shared/src/test/mockAuthUsers.ts | 7 ++++ ...leTrialSessionCopyReportInteractor.test.ts | 23 ++++------- ...intableTrialSessionCopyReportInteractor.ts | 3 +- ...tePrintableTrialSessionCopyReportLambda.ts | 41 ++++++++++++------- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index 8ffed72514d..64750d385a3 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -41,3 +41,10 @@ export const mockAdmissionsClerkUser: AuthUser = { role: ROLES.admissionsClerk, userId: 'e796d8cd-2e85-4d79-b4e1-281b59cacd5f', }; + +export const mockTrialClerkUser: AuthUser = { + email: 'mockTrialClerk@example.com', + name: 'Emil Lawerance', + role: ROLES.trialClerk, + userId: '474492fc-5aaf-4fe8-829d-b80a9c933e93', +}; diff --git a/web-api/src/business/useCases/trialSessions/generatePrintableTrialSessionCopyReportInteractor.test.ts b/web-api/src/business/useCases/trialSessions/generatePrintableTrialSessionCopyReportInteractor.test.ts index 112c69f930c..e82e4827caf 100644 --- a/web-api/src/business/useCases/trialSessions/generatePrintableTrialSessionCopyReportInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/generatePrintableTrialSessionCopyReportInteractor.test.ts @@ -1,11 +1,13 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_TRIAL_REGULAR } from '../../../../../shared/src/test/mockTrial'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generatePrintableTrialSessionCopyReportInteractor } from './generatePrintableTrialSessionCopyReportInteractor'; +import { + mockPetitionerUser, + mockTrialClerkUser, +} from '@shared/test/mockAuthUsers'; describe('generatePrintableTrialSessionCopyReportInteractor', () => { - let mockUser; let mockTrialSession; const interactorProps = { @@ -40,13 +42,6 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { }); beforeEach(() => { - mockUser = { - role: ROLES.trialClerk, - userId: 'trialclerk', - }; - - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - mockTrialSession = MOCK_TRIAL_REGULAR; }); @@ -57,15 +52,11 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { }); it('should throw an unauthorized error when the user does not have access', async () => { - mockUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( generatePrintableTrialSessionCopyReportInteractor( applicationContext, interactorProps, + mockPetitionerUser, ), ).rejects.toThrow('Unauthorized'); }); @@ -74,6 +65,7 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { await generatePrintableTrialSessionCopyReportInteractor( applicationContext, interactorProps, + mockTrialClerkUser, ); expect( @@ -89,6 +81,7 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { await generatePrintableTrialSessionCopyReportInteractor( applicationContext, interactorProps, + mockTrialClerkUser, ); expect(applicationContext.getStorageClient).toHaveBeenCalled(); @@ -99,6 +92,7 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { const results = await generatePrintableTrialSessionCopyReportInteractor( applicationContext, interactorProps, + mockTrialClerkUser, ); expect( @@ -116,6 +110,7 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { generatePrintableTrialSessionCopyReportInteractor( applicationContext, interactorProps, + mockTrialClerkUser, ), ).rejects.toEqual('error'); expect(applicationContext.logger.error).toHaveBeenCalled(); diff --git a/web-api/src/business/useCases/trialSessions/generatePrintableTrialSessionCopyReportInteractor.ts b/web-api/src/business/useCases/trialSessions/generatePrintableTrialSessionCopyReportInteractor.ts index b0b1cae4a27..461cfb44558 100644 --- a/web-api/src/business/useCases/trialSessions/generatePrintableTrialSessionCopyReportInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generatePrintableTrialSessionCopyReportInteractor.ts @@ -6,6 +6,7 @@ import { import { RawTrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const generatePrintableTrialSessionCopyReportInteractor = async ( applicationContext: ServerApplicationContext, @@ -26,8 +27,8 @@ export const generatePrintableTrialSessionCopyReportInteractor = async ( sort: string; userHeading: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); if ( !isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY) ) { diff --git a/web-api/src/lambdas/trialSessions/getGeneratePrintableTrialSessionCopyReportLambda.ts b/web-api/src/lambdas/trialSessions/getGeneratePrintableTrialSessionCopyReportLambda.ts index a22feeb91d2..b210e453351 100644 --- a/web-api/src/lambdas/trialSessions/getGeneratePrintableTrialSessionCopyReportLambda.ts +++ b/web-api/src/lambdas/trialSessions/getGeneratePrintableTrialSessionCopyReportLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generatePrintableTrialSessionCopyReportInteractor } from '@web-api/business/useCases/trialSessions/generatePrintableTrialSessionCopyReportInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,18 +8,27 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getGeneratePrintableTrialSessionCopyReportLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const body = JSON.parse(event.body); - return await applicationContext - .getUseCases() - .generatePrintableTrialSessionCopyReportInteractor(applicationContext, { - filters: body.filters, - formattedCases: body.formattedCases, - formattedTrialSession: body.formattedTrialSession, - sessionNotes: body.sessionNotes, - showCaseNotes: body.showCaseNotes, - sort: body.sort, - userHeading: body.userHeading, - }); - }); +export const getGeneratePrintableTrialSessionCopyReportLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const body = JSON.parse(event.body); + return await generatePrintableTrialSessionCopyReportInteractor( + applicationContext, + { + filters: body.filters, + formattedCases: body.formattedCases, + formattedTrialSession: body.formattedTrialSession, + sessionNotes: body.sessionNotes, + showCaseNotes: body.showCaseNotes, + sort: body.sort, + userHeading: body.userHeading, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 10fe6404457dcb0ad05504de9109c24e2e82ab0e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:26:57 -0700 Subject: [PATCH 051/523] devex: refactor to authUser --- ...atchDownloadTrialSessionInteractor.test.ts | 104 +++++++++++------- .../batchDownloadTrialSessionInteractor.ts | 33 +++--- .../batchDownloadTrialSessionLambda.ts | 29 +++-- 3 files changed, 102 insertions(+), 64 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.test.ts index 6d347b2f992..a34ad4f1224 100644 --- a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.test.ts @@ -1,16 +1,13 @@ -import { - CASE_STATUS_TYPES, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { batchDownloadTrialSessionInteractor, generateValidDocketEntryFilename, } from './batchDownloadTrialSessionInteractor'; +import { mockJudgeUser, mockPetitionerUser } from '@shared/test/mockAuthUsers'; describe('batchDownloadTrialSessionInteractor', () => { - let user; let mockCase; beforeEach(() => { @@ -48,11 +45,6 @@ describe('batchDownloadTrialSessionInteractor', () => { }, ]; - user = { - role: ROLES.judge, - userId: 'abc-123', - }; - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext .getPersistenceGateway() .getCalendaredCasesForTrialSession.mockReturnValue([ @@ -110,10 +102,15 @@ describe('batchDownloadTrialSessionInteractor', () => { expect(filename).toBe(expectedName); }); }); + it('skips DocketEntry that are not in docketrecord or have documents in S3', async () => { - await batchDownloadTrialSessionInteractor(applicationContext, { - trialSessionId: '123', - }); + await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId: '123', + }, + mockJudgeUser, + ); expect( applicationContext.getPersistenceGateway().zipDocuments, @@ -139,9 +136,13 @@ describe('batchDownloadTrialSessionInteractor', () => { .getPersistenceGateway() .isFileExists.mockResolvedValue(false); - await batchDownloadTrialSessionInteractor(applicationContext, { - trialSessionId: '123', - }); + await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId: '123', + }, + mockJudgeUser, + ); const errorCall = applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -154,14 +155,13 @@ describe('batchDownloadTrialSessionInteractor', () => { }); it('throws an Unauthorized error if the user role is not allowed to access the method', async () => { - user = { - role: ROLES.petitioner, - userId: 'abc-123', - }; - - await batchDownloadTrialSessionInteractor(applicationContext, { - trialSessionId: '123', - }); + await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId: '123', + }, + mockPetitionerUser, + ); expect(applicationContext.logger.error).toHaveBeenCalledWith( 'Error when batch downloading trial session with id 123 - Unauthorized', @@ -175,7 +175,7 @@ describe('batchDownloadTrialSessionInteractor', () => { action: 'batch_download_error', error: expect.anything(), }, - userId: 'abc-123', + userId: mockPetitionerUser.userId, }); }); @@ -184,9 +184,13 @@ describe('batchDownloadTrialSessionInteractor', () => { .getPersistenceGateway() .getCalendaredCasesForTrialSession.mockRejectedValueOnce(new Error()); - await batchDownloadTrialSessionInteractor(applicationContext, { - trialSessionId: '123', - }); + await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId: '123', + }, + mockJudgeUser, + ); expect(applicationContext.logger.error).toHaveBeenCalledWith( 'Error when batch downloading trial session with id 123 - unknown error', @@ -200,7 +204,7 @@ describe('batchDownloadTrialSessionInteractor', () => { action: 'batch_download_error', error: expect.anything(), }, - userId: 'abc-123', + userId: mockJudgeUser.userId, }); }); @@ -210,9 +214,13 @@ describe('batchDownloadTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockResolvedValue(false); - await batchDownloadTrialSessionInteractor(applicationContext, { - trialSessionId: mockTrialSessionId, - }); + await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId: mockTrialSessionId, + }, + mockJudgeUser, + ); expect(applicationContext.logger.error).toHaveBeenCalledWith( `Error when batch downloading trial session with id ${mockTrialSessionId} - Trial session ${mockTrialSessionId} was not found.`, @@ -226,14 +234,18 @@ describe('batchDownloadTrialSessionInteractor', () => { action: 'batch_download_error', error: expect.anything(), }, - userId: 'abc-123', + userId: mockJudgeUser.userId, }); }); it('calls persistence functions to fetch trial sessions and associated cases and then zips their associated documents', async () => { - await batchDownloadTrialSessionInteractor(applicationContext, { - trialSessionId: '123', - }); + await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId: '123', + }, + mockJudgeUser, + ); expect( applicationContext.getPersistenceGateway().getTrialSessionById, @@ -257,9 +269,13 @@ describe('batchDownloadTrialSessionInteractor', () => { }, ]); - await batchDownloadTrialSessionInteractor(applicationContext, { - trialSessionId: '123', - }); + await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId: '123', + }, + mockJudgeUser, + ); expect( applicationContext.getPersistenceGateway().getTrialSessionById, @@ -294,9 +310,13 @@ describe('batchDownloadTrialSessionInteractor', () => { }, ]); - await batchDownloadTrialSessionInteractor(applicationContext, { - trialSessionId: '123', - }); + await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId: '123', + }, + mockJudgeUser, + ); expect( applicationContext.getPersistenceGateway().getTrialSessionById, diff --git a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts index a0efd4b796a..bbd551e7f2b 100644 --- a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts @@ -13,6 +13,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { padStart } from 'lodash'; import sanitize from 'sanitize-filename'; @@ -27,10 +28,11 @@ import sanitize from 'sanitize-filename'; const batchDownloadTrialSessionInteractorHelper = async ( applicationContext: ServerApplicationContext, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.BATCH_DOWNLOAD_TRIAL_SESSION)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.BATCH_DOWNLOAD_TRIAL_SESSION) + ) { throw new UnauthorizedError('Unauthorized'); } @@ -116,7 +118,7 @@ const batchDownloadTrialSessionInteractorHelper = async ( numberOfDocketRecordsToGenerate, numberOfFilesToBatch, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -156,7 +158,7 @@ const batchDownloadTrialSessionInteractorHelper = async ( numberOfDocketRecordsToGenerate, numberOfFilesToBatch, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -168,7 +170,7 @@ const batchDownloadTrialSessionInteractorHelper = async ( action: 'batch_download_error', error, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -181,7 +183,7 @@ const batchDownloadTrialSessionInteractorHelper = async ( numberOfDocketRecordsToGenerate, numberOfFilesToBatch, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -193,7 +195,7 @@ const batchDownloadTrialSessionInteractorHelper = async ( numberOfDocketRecordsToGenerate, numberOfFilesToBatch, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -224,7 +226,7 @@ const batchDownloadTrialSessionInteractorHelper = async ( action: 'batch_download_ready', url, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -256,13 +258,18 @@ export const generateValidDocketEntryFilename = ({ export const batchDownloadTrialSessionInteractor = async ( applicationContext: ServerApplicationContext, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ) => { try { - await batchDownloadTrialSessionInteractorHelper(applicationContext, { - trialSessionId, - }); + await batchDownloadTrialSessionInteractorHelper( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); } catch (error) { - const { userId } = applicationContext.getCurrentUser(); + const { userId } = authorizedUser; const erMsg = error.message || 'unknown error'; applicationContext.logger.error( diff --git a/web-api/src/lambdas/trialSessions/batchDownloadTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/batchDownloadTrialSessionLambda.ts index 60f11d90b4b..fe9408b39e6 100644 --- a/web-api/src/lambdas/trialSessions/batchDownloadTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/batchDownloadTrialSessionLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { batchDownloadTrialSessionInteractor } from '@web-api/business/useCases/trialSessions/batchDownloadTrialSessionInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +8,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const batchDownloadTrialSessionLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { trialSessionId } = event.pathParameters || event.path; +export const batchDownloadTrialSessionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { trialSessionId } = event.pathParameters || event.path; - return await applicationContext - .getUseCases() - .batchDownloadTrialSessionInteractor(applicationContext, { - trialSessionId, - }); - }); + return await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 94cace056318227253a12e937cbcb1ef472e7304 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:33:52 -0700 Subject: [PATCH 052/523] devex: refactor to authUser --- ...tchDownloadDocketEntriesInteractor.test.ts | 32 ++++++++----------- .../batchDownloadDocketEntriesInteractor.ts | 25 +++++++++------ .../batchDownloadDocketEntriesLambda.ts | 20 ++++++++---- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.test.ts b/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.test.ts index 54f424d3e98..1a6f544611b 100644 --- a/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.test.ts +++ b/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.test.ts @@ -5,13 +5,14 @@ import { STANDING_PRETRIAL_ORDER_ENTRY, } from '@shared/test/mockDocketEntry'; import { MOCK_CASE } from '@shared/test/mockCase'; -import { ROLES } from '@shared/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { batchDownloadDocketEntriesInteractor } from '@web-api/business/useCases/document/batchDownloadDocketEntriesInteractor'; +import { + mockDocketClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('batchDownloadDocketEntriesInteractor', () => { - let user; - const MOCK_URL = 'document_url_containing_id'; const mockClientConnectionId = '987654'; const PETITION_DOCKET_ENTRY = MOCK_DOCUMENTS[0]; @@ -37,18 +38,11 @@ describe('batchDownloadDocketEntriesInteractor', () => { }; beforeEach(() => { - user = { - role: ROLES.docketClerk, - userId: 'abc-123', - }; - requestParams = { clientConnectionId: mockClientConnectionId, docketNumber: MOCK_CASE.docketNumber, documentsSelectedForDownload: mockDocumentsSelectedForDownload, }; - applicationContext.getCurrentUser.mockImplementation(() => user); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue({ @@ -68,13 +62,10 @@ describe('batchDownloadDocketEntriesInteractor', () => { }); it('throws an Unauthorized error if the user role is not allowed to access the method', async () => { - user = { - role: ROLES.privatePractitioner, - userId: 'abc-456', - }; await batchDownloadDocketEntriesInteractor( applicationContext, requestParams, + mockPrivatePractitionerUser, ); expect(applicationContext.logger.error).toHaveBeenCalledWith( @@ -90,7 +81,7 @@ describe('batchDownloadDocketEntriesInteractor', () => { action: 'batch_download_error', error: expect.anything(), }, - userId: 'abc-456', + userId: mockPrivatePractitionerUser.userId, }); }); @@ -104,6 +95,7 @@ describe('batchDownloadDocketEntriesInteractor', () => { await batchDownloadDocketEntriesInteractor( applicationContext, requestParams, + mockDocketClerkUser, ); expect(applicationContext.logger.error).toHaveBeenCalledWith( 'Error batch-downloading documents from case: 101-18 - unknown error', @@ -118,7 +110,7 @@ describe('batchDownloadDocketEntriesInteractor', () => { action: 'batch_download_error', error: expect.anything(), }, - userId: 'abc-123', + userId: mockDocketClerkUser.userId, }); }); @@ -130,6 +122,7 @@ describe('batchDownloadDocketEntriesInteractor', () => { await batchDownloadDocketEntriesInteractor( applicationContext, requestParams, + mockDocketClerkUser, ); expect(applicationContext.logger.error).toHaveBeenCalledWith( @@ -145,7 +138,7 @@ describe('batchDownloadDocketEntriesInteractor', () => { action: 'batch_download_error', error: expect.anything(), }, - userId: 'abc-123', + userId: mockDocketClerkUser.userId, }); }); @@ -153,6 +146,7 @@ describe('batchDownloadDocketEntriesInteractor', () => { await batchDownloadDocketEntriesInteractor( applicationContext, requestParams, + mockDocketClerkUser, ); expect( @@ -181,6 +175,7 @@ describe('batchDownloadDocketEntriesInteractor', () => { await batchDownloadDocketEntriesInteractor( applicationContext, requestParams, + mockDocketClerkUser, ); expect( @@ -207,6 +202,7 @@ describe('batchDownloadDocketEntriesInteractor', () => { await batchDownloadDocketEntriesInteractor( applicationContext, requestParams, + mockDocketClerkUser, ); expect( @@ -218,7 +214,7 @@ describe('batchDownloadDocketEntriesInteractor', () => { action: 'batch_download_ready', url: MOCK_URL, }, - userId: user.userId, + userId: mockDocketClerkUser.userId, }); }); }); diff --git a/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts b/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts index b70411c2cb5..d179bdc68d5 100644 --- a/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts +++ b/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts @@ -6,6 +6,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { generateValidDocketEntryFilename } from '@web-api/business/useCases/trialSessions/batchDownloadTrialSessionInteractor'; export type DownloadDocketEntryRequestType = { @@ -23,10 +24,14 @@ const batchDownloadDocketEntriesHelper = async ( documentsSelectedForDownload, printableDocketRecordFileId, }: DownloadDocketEntryRequestType, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.BATCH_DOWNLOAD_CASE_DOCUMENTS)) { + if ( + !isAuthorized( + authorizedUser, + ROLE_PERMISSIONS.BATCH_DOWNLOAD_CASE_DOCUMENTS, + ) + ) { throw new UnauthorizedError('Unauthorized'); } @@ -100,7 +105,7 @@ const batchDownloadDocketEntriesHelper = async ( numberOfDocketRecordsToGenerate: 0, numberOfFilesToBatch: s3Ids.length + extraFiles.length, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -113,7 +118,7 @@ const batchDownloadDocketEntriesHelper = async ( action: 'batch_download_error', error, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -127,7 +132,7 @@ const batchDownloadDocketEntriesHelper = async ( numberOfDocketRecordsToGenerate: 0, numberOfFilesToBatch: s3Ids.length + extraFiles.length, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -140,7 +145,7 @@ const batchDownloadDocketEntriesHelper = async ( numberOfDocketRecordsToGenerate: 0, numberOfFilesToBatch: s3Ids.length + extraFiles.length, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -172,21 +177,23 @@ const batchDownloadDocketEntriesHelper = async ( action: 'batch_download_ready', url, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; export const batchDownloadDocketEntriesInteractor = async ( applicationContext: ServerApplicationContext, downloadDocketEntryRequestInfo: DownloadDocketEntryRequestType, + authorizedUser: UnknownAuthUser, ) => { try { await batchDownloadDocketEntriesHelper( applicationContext, downloadDocketEntryRequestInfo, + authorizedUser, ); } catch (error) { - const { userId } = applicationContext.getCurrentUser(); + const { userId } = authorizedUser; const { clientConnectionId, docketNumber } = downloadDocketEntryRequestInfo; const erMsg = error.message || 'unknown error'; diff --git a/web-api/src/lambdas/documents/batchDownloadDocketEntriesLambda.ts b/web-api/src/lambdas/documents/batchDownloadDocketEntriesLambda.ts index 7cfc3635940..f4027295e3a 100644 --- a/web-api/src/lambdas/documents/batchDownloadDocketEntriesLambda.ts +++ b/web-api/src/lambdas/documents/batchDownloadDocketEntriesLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { batchDownloadDocketEntriesInteractor } from '@web-api/business/useCases/document/batchDownloadDocketEntriesInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const batchDownloadDocketEntriesLambda = event => - genericHandler(event, async ({ applicationContext }) => { - await applicationContext - .getUseCases() - .batchDownloadDocketEntriesInteractor( +export const batchDownloadDocketEntriesLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + await batchDownloadDocketEntriesInteractor( applicationContext, JSON.parse(event.body), + authorizedUser, ); - }); + }, + authorizedUser, + ); From 5c13be237e4c031a846454977cc8f00d022f0201 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:39:47 -0700 Subject: [PATCH 053/523] 10417: refactor to authUser --- .../updatePractitionerUserInteractor.test.ts | 357 ++++++++++-------- .../updatePractitionerUserInteractor.ts | 17 +- .../updatePractitionerUserLambda.ts | 33 +- 3 files changed, 239 insertions(+), 168 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.test.ts b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.test.ts index 6b606ea066d..a9b29981577 100644 --- a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.test.ts @@ -1,29 +1,24 @@ import { MOCK_PRACTITIONER } from '../../../../../shared/src/test/mockUsers'; import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors'; -import { - ROLES, - SERVICE_INDICATOR_TYPES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { SERVICE_INDICATOR_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generateChangeOfAddress } from '@web-api/business/useCases/user/generateChangeOfAddress'; +import { + mockAdmissionsClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { updatePractitionerUserInteractor } from './updatePractitionerUserInteractor'; jest.mock('@web-api/business/useCases/user/generateChangeOfAddress'); describe('updatePractitionerUserInteractor', () => { - let testUser; let mockPractitioner = MOCK_PRACTITIONER; beforeEach(() => { - testUser = { - role: ROLES.admissionsClerk, - userId: 'admissionsclerk', - }; mockPractitioner = { ...MOCK_PRACTITIONER }; applicationContext .getPersistenceGateway() .getDocketNumbersByUser.mockReturnValue(['123-23']); - applicationContext.getCurrentUser.mockImplementation(() => testUser); applicationContext .getPersistenceGateway() .getPractitionerByBarNumber.mockImplementation(() => mockPractitioner); @@ -39,16 +34,15 @@ describe('updatePractitionerUserInteractor', () => { }); it('should throw an unauthorized error when the user does not have permission to update the practitioner user', async () => { - testUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( - updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: mockPractitioner, - }), + updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: mockPractitioner, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -58,16 +52,20 @@ describe('updatePractitionerUserInteractor', () => { .getPractitionerByBarNumber.mockResolvedValue(undefined); await expect( - updatePractitionerUserInteractor(applicationContext, { - barNumber: 'AB1111', - bypassDocketEntry: false, - user: { - ...mockPractitioner, + updatePractitionerUserInteractor( + applicationContext, + { barNumber: 'AB1111', - updatedEmail: 'bc@example.com', - userId: '9ea9732c-9751-4159-9619-bd27556eb9bc', + bypassDocketEntry: false, + user: { + ...mockPractitioner, + barNumber: 'AB1111', + updatedEmail: 'bc@example.com', + userId: '9ea9732c-9751-4159-9619-bd27556eb9bc', + }, }, - }), + mockAdmissionsClerkUser, + ), ).rejects.toThrow(NotFoundError); }); @@ -80,16 +78,20 @@ describe('updatePractitionerUserInteractor', () => { }); await expect( - updatePractitionerUserInteractor(applicationContext, { - barNumber: 'AB1111', - bypassDocketEntry: false, - user: { - ...mockPractitioner, + updatePractitionerUserInteractor( + applicationContext, + { barNumber: 'AB1111', - updatedEmail: 'bc@example.com', - userId: '9ea9732c-9751-4159-9619-bd27556eb9bc', + bypassDocketEntry: false, + user: { + ...mockPractitioner, + barNumber: 'AB1111', + updatedEmail: 'bc@example.com', + userId: '9ea9732c-9751-4159-9619-bd27556eb9bc', + }, }, - }), + mockAdmissionsClerkUser, + ), ).rejects.toThrow('Bar number does not match user data.'); }); @@ -100,15 +102,19 @@ describe('updatePractitionerUserInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'AB1111', - user: { - ...mockPractitioner, - barNumber: 'AB2222', - confirmEmail: 'bc@example.com', - updatedEmail: 'bc@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'AB1111', + user: { + ...mockPractitioner, + barNumber: 'AB2222', + confirmEmail: 'bc@example.com', + updatedEmail: 'bc@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createNewPractitionerUser.mock @@ -119,15 +125,19 @@ describe('updatePractitionerUserInteractor', () => { }); it('updates the practitioner user and does NOT override a bar number or email when the original user had an email', async () => { - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'AB1111', - user: { - ...mockPractitioner, - barNumber: 'AB2222', - confirmEmail: 'bc@example.com', - updatedEmail: 'bc@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'AB1111', + user: { + ...mockPractitioner, + barNumber: 'AB2222', + confirmEmail: 'bc@example.com', + updatedEmail: 'bc@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updatePractitionerUser, @@ -142,15 +152,19 @@ describe('updatePractitionerUserInteractor', () => { mockPractitioner.email = undefined; mockPractitioner.pendingEmail = 'pendingEmail@example.com'; - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'AB1111', - user: { - ...mockPractitioner, - barNumber: 'AB2222', - confirmEmail: 'bc@example.com', - updatedEmail: 'bc@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'AB1111', + user: { + ...mockPractitioner, + barNumber: 'AB2222', + confirmEmail: 'bc@example.com', + updatedEmail: 'bc@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updatePractitionerUser, @@ -169,14 +183,18 @@ describe('updatePractitionerUserInteractor', () => { email: undefined, }); - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'AB1111', - user: { - ...mockPractitioner, - confirmEmail: 'admissionsclerk@example.com', - updatedEmail: 'admissionsclerk@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'AB1111', + user: { + ...mockPractitioner, + confirmEmail: 'admissionsclerk@example.com', + updatedEmail: 'admissionsclerk@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createNewPractitionerUser, @@ -195,14 +213,18 @@ describe('updatePractitionerUserInteractor', () => { email: undefined, }); - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'AB1111', - user: { - ...mockPractitioner, - email: undefined, - firstName: 'Donna', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'AB1111', + user: { + ...mockPractitioner, + email: undefined, + firstName: 'Donna', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateUserRecords.mock @@ -219,16 +241,15 @@ describe('updatePractitionerUserInteractor', () => { describe('updating email', () => { it('should throw unauthorized error when the logged in user does not have permission to manage emails', async () => { - testUser = { - role: ROLES.petitioner, - userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', - }; - await expect( - updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: mockPractitioner, - }), + updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: mockPractitioner, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for updating practitioner user'); }); @@ -238,26 +259,34 @@ describe('updatePractitionerUserInteractor', () => { .isEmailAvailable.mockReturnValue(false); await expect( - updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: { - ...mockPractitioner, - confirmEmail: 'exists@example.com', - updatedEmail: 'exists@example.com', + updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: { + ...mockPractitioner, + confirmEmail: 'exists@example.com', + updatedEmail: 'exists@example.com', + }, }, - }), + mockAdmissionsClerkUser, + ), ).rejects.toThrow('Email is not available'); }); it('should update the user with the new user.updatedEmail value', async () => { - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: { - ...mockPractitioner, - confirmEmail: 'free-email-to-use@example.com', - updatedEmail: 'free-email-to-use@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: { + ...mockPractitioner, + confirmEmail: 'free-email-to-use@example.com', + updatedEmail: 'free-email-to-use@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updatePractitionerUser.mock @@ -269,14 +298,18 @@ describe('updatePractitionerUserInteractor', () => { }); it("should send the verification email when the user's email is being changed", async () => { - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: { - ...mockPractitioner, - confirmEmail: 'free-email-to-use@example.com', - updatedEmail: 'free-email-to-use@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: { + ...mockPractitioner, + confirmEmail: 'free-email-to-use@example.com', + updatedEmail: 'free-email-to-use@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().sendEmailVerificationLink.mock @@ -289,14 +322,18 @@ describe('updatePractitionerUserInteractor', () => { it("should NOT send the verification email when the user's email is being added for the first time", async () => { mockPractitioner.email = undefined; - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: { - ...mockPractitioner, - confirmEmail: 'free-email-to-use@example.com', - updatedEmail: 'free-email-to-use@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: { + ...mockPractitioner, + confirmEmail: 'free-email-to-use@example.com', + updatedEmail: 'free-email-to-use@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().sendEmailVerificationLink, @@ -304,72 +341,92 @@ describe('updatePractitionerUserInteractor', () => { }); it('should NOT call generateChangeOfAddress if ONLY the email is being updated', async () => { - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: { - ...mockPractitioner, - confirmEmail: 'free-email-to-use@example.com', - updatedEmail: 'free-email-to-use@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: { + ...mockPractitioner, + confirmEmail: 'free-email-to-use@example.com', + updatedEmail: 'free-email-to-use@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect(generateChangeOfAddress).not.toHaveBeenCalled(); }); it('should NOT call generateChangeOfAddress if ONLY the notes are being updated', async () => { - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: { - ...mockPractitioner, - practitionerNotes: 'wow, real good notes', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: { + ...mockPractitioner, + practitionerNotes: 'wow, real good notes', + }, }, - }); + mockAdmissionsClerkUser, + ); expect(generateChangeOfAddress).not.toHaveBeenCalled(); }); it('should NOT call generateChangeOfAddress if ONLY the notes and email are being updated', async () => { - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: { - ...mockPractitioner, - confirmEmail: 'free-email-to-use@example.com', - practitionerNotes: 'wow, real good notes', - updatedEmail: 'free-email-to-use@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: { + ...mockPractitioner, + confirmEmail: 'free-email-to-use@example.com', + practitionerNotes: 'wow, real good notes', + updatedEmail: 'free-email-to-use@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect(generateChangeOfAddress).not.toHaveBeenCalled(); }); it('should call generateChangeOfAddress if the email is being updated along with the address1', async () => { - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: { - ...mockPractitioner, - confirmEmail: 'free-email-to-use@example.com', - contact: { - ...mockPractitioner.contact!, - address1: 'yeahhhhh', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: { + ...mockPractitioner, + confirmEmail: 'free-email-to-use@example.com', + contact: { + ...mockPractitioner.contact!, + address1: 'yeahhhhh', + }, + updatedEmail: 'free-email-to-use@example.com', }, - updatedEmail: 'free-email-to-use@example.com', }, - }); + mockAdmissionsClerkUser, + ); expect(generateChangeOfAddress).toHaveBeenCalled(); }); it('should call generateChangeOfAddress if the email is being updated along with the practitioner name', async () => { - await updatePractitionerUserInteractor(applicationContext, { - barNumber: 'pt101', - user: { - ...mockPractitioner, - confirmEmail: 'free-email-to-use@example.com', - firstName: 'Helen', - lastName: 'Hunt', - updatedEmail: 'free-email-to-use@example.com', + await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: 'pt101', + user: { + ...mockPractitioner, + confirmEmail: 'free-email-to-use@example.com', + firstName: 'Helen', + lastName: 'Hunt', + updatedEmail: 'free-email-to-use@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect(generateChangeOfAddress).toHaveBeenCalled(); }); diff --git a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts index 5c330b1e317..1e0c58385d5 100644 --- a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts +++ b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts @@ -8,6 +8,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { generateChangeOfAddress } from '../user/generateChangeOfAddress'; import { omit, union } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -19,12 +20,14 @@ export const updatePractitionerUser = async ( bypassDocketEntry = false, user, }: { barNumber: string; bypassDocketEntry?: boolean; user: RawPractitioner }, + authorizedUser: UnknownAuthUser, ): Promise => { - const requestUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(requestUser, ROLE_PERMISSIONS.ADD_EDIT_PRACTITIONER_USER) || - !isAuthorized(requestUser, ROLE_PERMISSIONS.EMAIL_MANAGEMENT) + !isAuthorized( + authorizedUser, + ROLE_PERMISSIONS.ADD_EDIT_PRACTITIONER_USER, + ) || + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.EMAIL_MANAGEMENT) ) { throw new UnauthorizedError('Unauthorized for updating practitioner user'); } @@ -95,7 +98,7 @@ export const updatePractitionerUser = async ( message: { action: 'admin_contact_initial_update_complete', }, - userId: requestUser.userId, + userId: authorizedUser.userId, }); if (userHasAccount && userIsUpdatingEmail) { @@ -128,7 +131,7 @@ export const updatePractitionerUser = async ( bypassDocketEntry, contactInfo: validatedUserData.contact, firmName: validatedUserData.firmName, - requestUserId: requestUser.userId, + requestUserId: authorizedUser.userId, updatedEmail: validatedUserData.email, updatedName: validatedUserData.name, user: oldUser, @@ -140,7 +143,7 @@ export const updatePractitionerUser = async ( message: { action: 'admin_contact_full_update_complete', }, - userId: requestUser.userId, + userId: authorizedUser.userId, }); } }; diff --git a/web-api/src/lambdas/practitioners/updatePractitionerUserLambda.ts b/web-api/src/lambdas/practitioners/updatePractitionerUserLambda.ts index 1b8baf5c5ea..92f93ff2213 100644 --- a/web-api/src/lambdas/practitioners/updatePractitionerUserLambda.ts +++ b/web-api/src/lambdas/practitioners/updatePractitionerUserLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updatePractitionerUserInteractor } from '@web-api/business/useCases/practitioner/updatePractitionerUserInteractor'; /** * updates a privatePractitioner or irsPractitioner user @@ -6,15 +8,24 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updatePractitionerUserLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { bypassDocketEntry = false, user } = JSON.parse(event.body); +export const updatePractitionerUserLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { bypassDocketEntry = false, user } = JSON.parse(event.body); - return await applicationContext - .getUseCases() - .updatePractitionerUserInteractor(applicationContext, { - barNumber: event.pathParameters.barNumber, - bypassDocketEntry: bypassDocketEntry || false, - user, - }); - }); + return await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + bypassDocketEntry: bypassDocketEntry || false, + user, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 37850904c69c45a3c89e5eccb0fcbe28298f739a Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:47:33 -0700 Subject: [PATCH 054/523] 10417: refactor to authUser --- ...tableCaseInventoryReportInteractor.test.ts | 36 +++++++++---------- ...ePrintableCaseInventoryReportInteractor.ts | 4 +-- ...eratePrintableCaseInventoryReportLambda.ts | 18 +++++++--- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.test.ts b/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.test.ts index e5a9d95add6..4d91778b073 100644 --- a/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.test.ts +++ b/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.test.ts @@ -1,13 +1,12 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generatePrintableCaseInventoryReportInteractor } from './generatePrintableCaseInventoryReportInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('generatePrintableCaseInventoryReportInteractor', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); applicationContext .getUseCaseHelpers() .generateCaseInventoryReportPdf.mockReturnValue('https://example.com'); @@ -22,6 +21,7 @@ describe('generatePrintableCaseInventoryReportInteractor', () => { { associatedJudge: 'Judge Colvin', }, + mockPetitionsClerkUser, ); expect( @@ -31,26 +31,24 @@ describe('generatePrintableCaseInventoryReportInteractor', () => { }); it('should throw an unauthorized error if the user does not have access', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'petitioner', - }); - await expect( - generatePrintableCaseInventoryReportInteractor(applicationContext, { - associatedJudge: 'Judge Colvin', - }), + generatePrintableCaseInventoryReportInteractor( + applicationContext, + { + associatedJudge: 'Judge Colvin', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should throw an error if associatedJudge and status are not passed in', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); - await expect( - generatePrintableCaseInventoryReportInteractor(applicationContext, {}), + generatePrintableCaseInventoryReportInteractor( + applicationContext, + {}, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Either judge or status must be provided'); }); }); diff --git a/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.ts b/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.ts index 57c6cc03e00..6722d28cb08 100644 --- a/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.ts +++ b/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.ts @@ -4,13 +4,13 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const generatePrintableCaseInventoryReportInteractor = async ( applicationContext: ServerApplicationContext, { associatedJudge, status }: { associatedJudge?: string; status?: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_INVENTORY_REPORT)) { throw new UnauthorizedError('Unauthorized for case inventory report'); } diff --git a/web-api/src/lambdas/reports/generatePrintableCaseInventoryReportLambda.ts b/web-api/src/lambdas/reports/generatePrintableCaseInventoryReportLambda.ts index 4e1aa51cb84..da01072c8e0 100644 --- a/web-api/src/lambdas/reports/generatePrintableCaseInventoryReportLambda.ts +++ b/web-api/src/lambdas/reports/generatePrintableCaseInventoryReportLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generatePrintableCaseInventoryReportInteractor } from '@web-api/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,15 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const generatePrintableCaseInventoryReportLambda = event => +export const generatePrintableCaseInventoryReportLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .generatePrintableCaseInventoryReportInteractor(applicationContext, { + return await generatePrintableCaseInventoryReportInteractor( + applicationContext, + { ...event.queryStringParameters, - }); + }, + authorizedUser, + ); }, + authorizedUser, { logResults: false }, ); From 3a12196fcbba4a490aa54099059fb8f88bb9252a Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:50:22 -0700 Subject: [PATCH 055/523] 10417: refactor to authUser --- .../unsealDocketEntryInteractor.test.ts | 41 ++++++++++--------- .../unsealDocketEntryInteractor.ts | 4 +- .../documents/unsealDocketEntryLambda.ts | 35 ++++++++++------ 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.test.ts b/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.test.ts index 5f93eb31c30..2cb6e29fa3b 100644 --- a/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.test.ts @@ -1,41 +1,41 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { unsealDocketEntryInteractor } from './unsealDocketEntryInteractor'; describe('unsealDocketEntryInteractor', () => { const answerDocketEntryId = 'e6b81f4d-1e47-423a-8caf-6d2fdc3d3859'; it('should only allow docket clerks to unseal a docket entry', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - }); - await expect( - unsealDocketEntryInteractor(applicationContext, { - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - docketNumber: '101-20', - }), + unsealDocketEntryInteractor( + applicationContext, + { + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + docketNumber: '101-20', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should throw an error when the docket entry is not found', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); - await expect( - unsealDocketEntryInteractor(applicationContext, { - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - docketNumber: '101-20', - }), + unsealDocketEntryInteractor( + applicationContext, + { + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + docketNumber: '101-20', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry not found'); }); it('should mark the docket entry as unsealed and save', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); @@ -45,6 +45,7 @@ describe('unsealDocketEntryInteractor', () => { docketEntryId: answerDocketEntryId, docketNumber: MOCK_CASE.docketNumber, }, + mockDocketClerkUser, ); expect(unsealedDocketEntry).toBeDefined(); expect(unsealedDocketEntry.isSealed).toEqual(false); diff --git a/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.ts index f61f81a9af5..b7ac244a246 100644 --- a/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.ts @@ -5,6 +5,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * unseals a given docket entry on a case @@ -21,9 +22,8 @@ export const unsealDocketEntryInteractor = async ( docketEntryId, docketNumber, }: { docketEntryId: string; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - const hasPermission = isAuthorized( authorizedUser, ROLE_PERMISSIONS.SEAL_DOCKET_ENTRY, diff --git a/web-api/src/lambdas/documents/unsealDocketEntryLambda.ts b/web-api/src/lambdas/documents/unsealDocketEntryLambda.ts index 81113efa5a3..38b9244a886 100644 --- a/web-api/src/lambdas/documents/unsealDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/unsealDocketEntryLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { unsealDocketEntryInteractor } from '@web-api/business/useCases/docketEntry/unsealDocketEntryInteractor'; /** * used for unsealing docket entries @@ -6,16 +8,25 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const unsealDocketEntryLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { - pathParameters: { docketEntryId, docketNumber }, - } = event; +export const unsealDocketEntryLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { + pathParameters: { docketEntryId, docketNumber }, + } = event; - return await applicationContext - .getUseCases() - .unsealDocketEntryInteractor(applicationContext, { - docketEntryId, - docketNumber, - }); - }); + return await unsealDocketEntryInteractor( + applicationContext, + { + docketEntryId, + docketNumber, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 7665d58a463b298ea495dff4b7c09187b189adca Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:55:01 -0700 Subject: [PATCH 056/523] 10417: refactor to authUser --- shared/src/test/mockAuthUsers.ts | 7 +++ .../getUsersPendingEmailInteractor.test.ts | 63 ++++++++++--------- .../user/getUsersPendingEmailInteractor.ts | 4 +- .../users/getUsersPendingEmailLambda.ts | 29 ++++++--- 4 files changed, 61 insertions(+), 42 deletions(-) diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index 64750d385a3..e028592672d 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -48,3 +48,10 @@ export const mockTrialClerkUser: AuthUser = { role: ROLES.trialClerk, userId: '474492fc-5aaf-4fe8-829d-b80a9c933e93', }; + +export const mockAdminUser: AuthUser = { + email: 'mockAdmin@example.com', + name: 'Admiral Admin', + role: ROLES.admin, + userId: 'f56424f2-e071-4b3c-97b9-708f660a0ea7', +}; diff --git a/web-api/src/business/useCases/user/getUsersPendingEmailInteractor.test.ts b/web-api/src/business/useCases/user/getUsersPendingEmailInteractor.test.ts index 9f640ef199b..62df62831eb 100644 --- a/web-api/src/business/useCases/user/getUsersPendingEmailInteractor.test.ts +++ b/web-api/src/business/useCases/user/getUsersPendingEmailInteractor.test.ts @@ -1,38 +1,27 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getUsersPendingEmailInteractor } from './getUsersPendingEmailInteractor'; +import { + mockAdminUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getUsersPendingEmailInteractor', () => { - let currentLoggedInUser; const PENDING_EMAIL = 'pending@example.com'; const USER_IDS = [ 'a8024d79-1cd0-4864-bdd9-60325bd6d6b9', 'f8024d79-1cd0-4864-bdd9-60325bd6d6b1', ]; - beforeEach(() => { - currentLoggedInUser = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - - applicationContext.getCurrentUser.mockImplementation( - () => currentLoggedInUser, - ); - }); - it('should throw an error when not authorized', async () => { - currentLoggedInUser = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.admin, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - await expect( - getUsersPendingEmailInteractor(applicationContext, { - userIds: USER_IDS, - }), + getUsersPendingEmailInteractor( + applicationContext, + { + userIds: USER_IDS, + }, + mockAdminUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -52,9 +41,13 @@ describe('getUsersPendingEmailInteractor', () => { }, ]); - const result = await getUsersPendingEmailInteractor(applicationContext, { - userIds: USER_IDS, - }); + const result = await getUsersPendingEmailInteractor( + applicationContext, + { + userIds: USER_IDS, + }, + mockPetitionsClerkUser, + ); expect(result).toEqual({ [USER_IDS[0]]: PENDING_EMAIL, @@ -76,9 +69,13 @@ describe('getUsersPendingEmailInteractor', () => { }, ]); - const result = await getUsersPendingEmailInteractor(applicationContext, { - userIds: USER_IDS, - }); + const result = await getUsersPendingEmailInteractor( + applicationContext, + { + userIds: USER_IDS, + }, + mockPetitionsClerkUser, + ); expect(result).toEqual({ [USER_IDS[0]]: undefined, @@ -91,9 +88,13 @@ describe('getUsersPendingEmailInteractor', () => { .getPersistenceGateway() .getUsersById.mockResolvedValue([]); - const result = await getUsersPendingEmailInteractor(applicationContext, { - userIds: USER_IDS, - }); + const result = await getUsersPendingEmailInteractor( + applicationContext, + { + userIds: USER_IDS, + }, + mockPetitionsClerkUser, + ); expect(result).toBeUndefined(); }); diff --git a/web-api/src/business/useCases/user/getUsersPendingEmailInteractor.ts b/web-api/src/business/useCases/user/getUsersPendingEmailInteractor.ts index e9a3d8dee72..09893414ddb 100644 --- a/web-api/src/business/useCases/user/getUsersPendingEmailInteractor.ts +++ b/web-api/src/business/useCases/user/getUsersPendingEmailInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; /** @@ -17,9 +18,8 @@ import { User } from '../../../../../shared/src/business/entities/User'; export const getUsersPendingEmailInteractor = async ( applicationContext: ServerApplicationContext, { userIds }: { userIds: string[] }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if ( !isAuthorized( authorizedUser, diff --git a/web-api/src/lambdas/users/getUsersPendingEmailLambda.ts b/web-api/src/lambdas/users/getUsersPendingEmailLambda.ts index da1cd8d647f..cd4f3839111 100644 --- a/web-api/src/lambdas/users/getUsersPendingEmailLambda.ts +++ b/web-api/src/lambdas/users/getUsersPendingEmailLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getUsersPendingEmailInteractor } from '@web-api/business/useCases/user/getUsersPendingEmailInteractor'; /** * calls the interactor for obtaining a mapping of a given array of userIds and @@ -7,13 +9,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getUsersPendingEmailLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const userIds = event.queryStringParameters.userIds?.split(',') || []; +export const getUsersPendingEmailLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const userIds = event.queryStringParameters.userIds?.split(',') || []; - return await applicationContext - .getUseCases() - .getUsersPendingEmailInteractor(applicationContext, { - userIds, - }); - }); + return await getUsersPendingEmailInteractor( + applicationContext, + { + userIds, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 78ea3da1c1808b4c4bf4a09f545758d34444ec84 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 13:58:58 -0700 Subject: [PATCH 057/523] 10417: refactor to authUser --- shared/src/test/mockAuthUsers.ts | 7 ++++ ...eIrsPractitionerWithCaseInteractor.test.ts | 40 +++++++++---------- ...ociateIrsPractitionerWithCaseInteractor.ts | 6 +-- .../associateIrsPractitionerWithCaseLambda.ts | 27 +++++++++---- 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index e028592672d..7402c30512d 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -55,3 +55,10 @@ export const mockAdminUser: AuthUser = { role: ROLES.admin, userId: 'f56424f2-e071-4b3c-97b9-708f660a0ea7', }; + +export const mockAdcUser: AuthUser = { + email: 'mockAdc@example.com', + name: 'Antony Aardvark', + role: ROLES.adc, + userId: '9f357f78-a8fa-40bf-83db-8144ddf14047', +}; diff --git a/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.test.ts b/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.test.ts index 013fc79fe69..df72bc6206e 100644 --- a/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.test.ts +++ b/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.test.ts @@ -9,6 +9,7 @@ import { import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { associateIrsPractitionerWithCaseInteractor } from './associateIrsPractitionerWithCaseInteractor'; +import { mockAdcUser, mockPetitionerUser } from '@shared/test/mockAuthUsers'; describe('associateIrsPractitionerWithCaseInteractor', () => { let caseRecord = { @@ -36,12 +37,9 @@ describe('associateIrsPractitionerWithCaseInteractor', () => { userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', }; - let mockCurrentUser; let mockUserById; beforeAll(() => { - applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser); - applicationContext .getPersistenceGateway() .getUserById.mockImplementation(() => mockUserById); @@ -52,24 +50,20 @@ describe('associateIrsPractitionerWithCaseInteractor', () => { }); it('should throw an error when not authorized', async () => { - mockCurrentUser = {}; - await expect( - associateIrsPractitionerWithCaseInteractor(applicationContext, { - docketNumber: caseRecord.docketNumber, - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + associateIrsPractitionerWithCaseInteractor( + applicationContext, + { + docketNumber: caseRecord.docketNumber, + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should add mapping for an irsPractitioner', async () => { - mockCurrentUser = { - barNumber: 'BN1234', - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.adc, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; mockUserById = { barNumber: 'BN1234', name: 'Emmett Lathrop "Doc" Brown, Ph.D.', @@ -80,11 +74,15 @@ describe('associateIrsPractitionerWithCaseInteractor', () => { .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(false); - await associateIrsPractitionerWithCaseInteractor(applicationContext, { - docketNumber: caseRecord.docketNumber, - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await associateIrsPractitionerWithCaseInteractor( + applicationContext, + { + docketNumber: caseRecord.docketNumber, + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockAdcUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, diff --git a/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.ts b/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.ts index 0efe4a8cd49..1be714fdda7 100644 --- a/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.ts +++ b/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { associateIrsPractitionerToCase } from '../../useCaseHelper/caseAssociation/associateIrsPractitionerToCase'; /** @@ -23,11 +24,10 @@ export const associateIrsPractitionerWithCaseInteractor = async ( serviceIndicator, userId, }: { docketNumber: string; serviceIndicator: string; userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authenticatedUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(authenticatedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) ) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/manualAssociation/associateIrsPractitionerWithCaseLambda.ts b/web-api/src/lambdas/manualAssociation/associateIrsPractitionerWithCaseLambda.ts index 8880fea03a1..56888ae7b04 100644 --- a/web-api/src/lambdas/manualAssociation/associateIrsPractitionerWithCaseLambda.ts +++ b/web-api/src/lambdas/manualAssociation/associateIrsPractitionerWithCaseLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { associateIrsPractitionerWithCaseInteractor } from '@web-api/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const associateIrsPractitionerWithCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .associateIrsPractitionerWithCaseInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const associateIrsPractitionerWithCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await associateIrsPractitionerWithCaseInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 173b74840b9e2a55a58c9f2267fa812fde2d43d9 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 14:31:38 -0700 Subject: [PATCH 058/523] 10417: docs --- docs/remove-get-current-user.md | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 docs/remove-get-current-user.md diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md new file mode 100644 index 00000000000..2b264e2e5ef --- /dev/null +++ b/docs/remove-get-current-user.md @@ -0,0 +1,70 @@ +# Web-Client +Steps to transition getCurrentUser() in web-client +1. Find applicationContext.getCurrentUser() and replace with get(state.user); +1. Update test to use state to set the user instead of mocking calls to getCurrentUser() + +# Shared(DocketEntry, Case, PublicCase) +For Interactors that are still in shared follow the steps in the `Web-Api` section + +For DocketEntry, Case, PublicCase + +# Web-Api +Steps To transition an interactor away from getCurrentUser() +1. Make Interactor accept a 3rd paramater called authorizedUser: UnknownAuthUser +1. Remove applicationContext.getCurrentUser() and replace with the authorizedUser input. +1. Update test to pass in user instead of mocking getCurrentUser. Test users can be found in `shared/src/test/mockAuthUsers.ts` +1. Update everywhere the interactor is being called to pass in an authorizedUser. Most likely this will be in the lambda file of the same name, in which case you will make the lambda accept a second argument of the authorizedUser. Example below: + + +## Before +```typescript +import { genericHandler } from '../../genericHandler'; + +/** + * lambda which is used for adding a petitioner to a case + * + * @param {object} event the AWS event object + * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers + */ +export const addPetitionerToCaseLambda = event => + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .addPetitionerToCaseInteractor(applicationContext, { + ...event.pathParameters, + ...JSON.parse(event.body), + }); + }); +``` + +## After +```typescript +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { addPetitionerToCaseInteractor } from '@shared/business/useCases/addPetitionerToCaseInteractor'; +import { genericHandler } from '../../genericHandler'; + +/** + * lambda which is used for adding a petitioner to a case + * + * @param {object} event the AWS event object + * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers + */ +export const addPetitionerToCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await addPetitionerToCaseInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); +``` \ No newline at end of file From c6aa9bab9201751d2eb5cd0bf796f57b5c61336c Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 14:59:33 -0700 Subject: [PATCH 059/523] 10417: Transition Public case to authUser --- .../entities/cases/PublicCase.test.ts | 72 ++++++++----------- .../src/business/entities/cases/PublicCase.ts | 13 ++-- .../business/useCases/getCaseInteractor.ts | 6 +- shared/src/test/mockAuthUsers.ts | 7 ++ .../formatPublicCase.test.ts | 6 -- .../consolidatedCases/formatPublicCase.ts | 6 +- .../getCaseForPublicDocketSearchInteractor.ts | 2 +- .../public/getPublicCaseInteractor.ts | 2 +- 8 files changed, 47 insertions(+), 67 deletions(-) diff --git a/shared/src/business/entities/cases/PublicCase.test.ts b/shared/src/business/entities/cases/PublicCase.test.ts index c603d1fd419..362a7e289e4 100644 --- a/shared/src/business/entities/cases/PublicCase.test.ts +++ b/shared/src/business/entities/cases/PublicCase.test.ts @@ -10,19 +10,17 @@ import { } from '../EntityConstants'; import { MOCK_CASE } from '../../../test/mockCase'; import { MOCK_COMPLEX_CASE } from '../../../test/mockComplexCase'; -import { MOCK_USERS } from '../../../test/mockUsers'; import { PublicCase } from './PublicCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { getContactSecondary } from './Case'; +import { + mockIrsPractitionerUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('PublicCase', () => { const mockContactId = 'b430f7f9-06f3-4a25-915d-5f51adab2f29'; const mockContactIdSecond = '39a359e9-dde3-409e-b40e-77a4959b6f2c'; - it('should throw an error when applicationContext is not provided to the constructor', () => { - expect(() => new PublicCase({}, {} as any)).toThrow(TypeError); - }); - describe('validation', () => { it('should validate when all information is provided and case is not sealed', () => { const entity = new PublicCase( @@ -44,7 +42,7 @@ describe('PublicCase', () => { receivedAt: '2020-01-05T03:30:45.007Z', status: CASE_STATUS_TYPES.calendared, }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(entity.getFormattedValidationErrors()).toBe(null); @@ -62,7 +60,7 @@ describe('PublicCase', () => { receivedAt: '2020-01-05T03:30:45.007Z', sealedDate: '2020-01-05T03:30:45.007Z', }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(entity.getFormattedValidationErrors()).toMatchObject({ @@ -105,7 +103,7 @@ describe('PublicCase', () => { receivedAt: 'testing', status: CASE_STATUS_TYPES.new, }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(entity.toRawObject()).toEqual({ @@ -162,7 +160,7 @@ describe('PublicCase', () => { receivedAt: 'testing', status: CASE_STATUS_TYPES.calendared, }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(entity.toRawObject()).toEqual({ @@ -206,7 +204,7 @@ describe('PublicCase', () => { { docketEntryId: '987', eventCode: TRANSCRIPT_EVENT_CODE }, ], }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(entity.toRawObject().docketEntries).toMatchObject([ @@ -242,7 +240,7 @@ describe('PublicCase', () => { ...MOCK_CASE, docketEntries: [docketEntry1, docketEntry2, docketEntry3], }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(entity.docketEntries).toMatchObject([ @@ -260,7 +258,7 @@ describe('PublicCase', () => { docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL_LIEN_LEVY, docketNumberWithSuffix: null, }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(entity.docketNumberWithSuffix).toBe('102-20SL'); }); @@ -273,13 +271,15 @@ describe('PublicCase', () => { docketNumberSuffix: null, docketNumberWithSuffix: null, }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(entity.docketNumberWithSuffix).toBe('102-20'); }); it('should correctly ingest a complex case', () => { - const entity = new PublicCase(MOCK_COMPLEX_CASE, { applicationContext }); + const entity = new PublicCase(MOCK_COMPLEX_CASE, { + authorizedUser: undefined, + }); expect(() => entity.validate()).not.toThrow(); expect(() => entity.validateForMigration()).not.toThrow(); @@ -293,7 +293,7 @@ describe('PublicCase', () => { petitioners: [{ contactType: CONTACT_TYPES.primary }], sealedDate: 'some date', }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(entity.isSealed).toBe(true); @@ -303,10 +303,6 @@ describe('PublicCase', () => { }); it('should not show leadDocketNumber if user is does not have IRS Practitioner role', () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: ROLES.privatePractitioner, - }); - const rawCase = { ...MOCK_CASE, irsPractitioners: [ @@ -335,7 +331,9 @@ describe('PublicCase', () => { }, ], }; - const entity = new PublicCase(rawCase, { applicationContext }); + const entity = new PublicCase(rawCase, { + authorizedUser: mockPrivatePractitionerUser, + }); expect(entity.irsPractitioners).toBeUndefined(); expect(entity.privatePractitioners).toBeUndefined(); @@ -343,12 +341,6 @@ describe('PublicCase', () => { }); describe('irsPractitioner', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue( - MOCK_USERS['f7d90c05-f6cd-442c-a168-202db587f16f'], - ); - }); - it('an irsPractitioner should be able to see otherPetitioners and otherFilers', () => { const mockOtherFiler = { address1: '42 Lamb Sauce Blvd', @@ -386,7 +378,7 @@ describe('PublicCase', () => { mockOtherPetitioner, ], }, - { applicationContext }, + { authorizedUser: mockIrsPractitionerUser }, ); expect(entity.petitioners).toEqual( @@ -399,10 +391,6 @@ describe('PublicCase', () => { }); it('should show all contact and practitioner information if user has IRS Practitioner role', () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: ROLES.irsPractitioner, - }); - const rawContactPrimary = { address1: '907 West Rocky Cowley Parkway', address2: '104 West 120th Street', @@ -494,7 +482,9 @@ describe('PublicCase', () => { ], receivedAt: 'testing', }; - const entity = new PublicCase(rawCase, { applicationContext }); + const entity = new PublicCase(rawCase, { + authorizedUser: mockIrsPractitionerUser, + }); expect(entity.toRawObject()).toMatchObject({ caseCaption: 'testing', @@ -511,10 +501,6 @@ describe('PublicCase', () => { }); it('should not show practitioner and other filer information if user has IRS Practitioner role and the case is sealed', () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: ROLES.irsPractitioner, - }); - const rawCase = { ...MOCK_CASE, irsPractitioners: [ @@ -542,7 +528,9 @@ describe('PublicCase', () => { }, ], }; - const entity = new PublicCase(rawCase, { applicationContext }); + const entity = new PublicCase(rawCase, { + authorizedUser: mockIrsPractitionerUser, + }); expect(entity.irsPractitioners).toBeUndefined(); expect(entity.privatePractitioners).toBeUndefined(); @@ -550,10 +538,6 @@ describe('PublicCase', () => { }); it('should show leadDocketNumber if user is has IRS Practitioner role', () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: ROLES.irsPractitioner, - }); - const rawCase = { ...MOCK_CASE, irsPractitioners: [ @@ -582,7 +566,9 @@ describe('PublicCase', () => { }, ], }; - const entity = new PublicCase(rawCase, { applicationContext }); + const entity = new PublicCase(rawCase, { + authorizedUser: mockIrsPractitionerUser, + }); expect(entity.irsPractitioners).toBeDefined(); expect(entity.privatePractitioners).toBeDefined(); diff --git a/shared/src/business/entities/cases/PublicCase.ts b/shared/src/business/entities/cases/PublicCase.ts index 294d3e22228..168f3d725d5 100644 --- a/shared/src/business/entities/cases/PublicCase.ts +++ b/shared/src/business/entities/cases/PublicCase.ts @@ -6,6 +6,7 @@ import { JoiValidationEntity } from '../JoiValidationEntity'; import { PrivatePractitioner } from '../PrivatePractitioner'; import { PublicContact } from './PublicContact'; import { PublicDocketEntry } from './PublicDocketEntry'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { compareStrings } from '../../utilities/sortFunctions'; import { isSealedCase } from './Case'; import joi from 'joi'; @@ -36,17 +37,13 @@ export class PublicCase extends JoiValidationEntity { constructor( rawCase: any, { - applicationContext, + authorizedUser, }: { - applicationContext: IApplicationContext; + authorizedUser: UnknownAuthUser; }, ) { super('PublicCase'); - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } - this.entityName = 'PublicCase'; this.canAllowDocumentService = rawCase.canAllowDocumentService; this.canAllowPrintableDocketRecord = rawCase.canAllowPrintableDocketRecord; @@ -67,9 +64,7 @@ export class PublicCase extends JoiValidationEntity { this.isSealed = isSealedCase(rawCase); - const currentUser = applicationContext.getCurrentUser(); - - if (currentUser.role === ROLES.irsPractitioner && !this.isSealed) { + if (authorizedUser?.role === ROLES.irsPractitioner && !this.isSealed) { this.petitioners = rawCase.petitioners; this.irsPractitioners = (rawCase.irsPractitioners || []).map( diff --git a/shared/src/business/useCases/getCaseInteractor.ts b/shared/src/business/useCases/getCaseInteractor.ts index dbcc099ff8e..bd2c98ce06f 100644 --- a/shared/src/business/useCases/getCaseInteractor.ts +++ b/shared/src/business/useCases/getCaseInteractor.ts @@ -58,7 +58,7 @@ const getSealedCase = ({ caseRecord = caseSealedFormatter(caseRecord); return new PublicCase(caseRecord, { - applicationContext, + authorizedUser, }) .validate() .toRawObject(); @@ -67,6 +67,7 @@ const getSealedCase = ({ const getCaseForExternalUser = ({ applicationContext, + authorizedUser, caseRecord, isAssociatedWithCase, isAuthorizedToGetCase, @@ -77,7 +78,7 @@ const getCaseForExternalUser = ({ .toRawObject(); } else { return new PublicCase(caseRecord, { - applicationContext, + authorizedUser, }) .validate() .toRawObject(); @@ -193,6 +194,7 @@ export const getCaseInteractor = async ( } else { caseDetailRaw = await getCaseForExternalUser({ applicationContext, + authorizedUser, caseRecord, isAssociatedWithCase, isAuthorizedToGetCase, diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index 7402c30512d..9e2ca83d150 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -62,3 +62,10 @@ export const mockAdcUser: AuthUser = { role: ROLES.adc, userId: '9f357f78-a8fa-40bf-83db-8144ddf14047', }; + +export const mockIrsPractitionerUser: AuthUser = { + email: 'mockIrsPractitioner@example.com', + name: 'Ida Igloo', + role: ROLES.irsPractitioner, + userId: '4eb0a70d-ed4c-4715-a95f-261cb1441db9', +}; diff --git a/web-api/src/business/useCaseHelper/consolidatedCases/formatPublicCase.test.ts b/web-api/src/business/useCaseHelper/consolidatedCases/formatPublicCase.test.ts index bb470ee371c..c9cf4ea9ef7 100644 --- a/web-api/src/business/useCaseHelper/consolidatedCases/formatPublicCase.test.ts +++ b/web-api/src/business/useCaseHelper/consolidatedCases/formatPublicCase.test.ts @@ -1,6 +1,5 @@ import { DOCKET_ENTRY_SEALED_TO_TYPES } from '@shared/business/entities/EntityConstants'; import { MOCK_CASE } from '@shared/test/mockCase'; -import { applicationContext } from '@shared/business/test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; import { formatPublicCase } from '@web-api/business/useCaseHelper/consolidatedCases/formatPublicCase'; import { getContactPrimary } from '@shared/business/entities/cases/Case'; @@ -36,7 +35,6 @@ describe('getPublicCaseInteractor', () => { }; let result = await formatPublicCase({ - applicationContext, rawCaseRecord: sealedCase, }); @@ -46,7 +44,6 @@ describe('getPublicCaseInteractor', () => { delete sealedCase.isSealed; result = await formatPublicCase({ - applicationContext, rawCaseRecord: sealedCase, }); @@ -61,7 +58,6 @@ describe('getPublicCaseInteractor', () => { }; let result = await formatPublicCase({ - applicationContext, rawCaseRecord: { ...mockCase, docketEntries: sealedDocketEntries, @@ -87,7 +83,6 @@ describe('getPublicCaseInteractor', () => { }; let result = await formatPublicCase({ - applicationContext, rawCaseRecord: { ...mockCase, petitioners: [sealedContactPrimary] }, }); @@ -110,7 +105,6 @@ describe('getPublicCaseInteractor', () => { }; let result = await formatPublicCase({ - applicationContext, rawCaseRecord: mockCase, }); diff --git a/web-api/src/business/useCaseHelper/consolidatedCases/formatPublicCase.ts b/web-api/src/business/useCaseHelper/consolidatedCases/formatPublicCase.ts index 84989a29451..4a58fea6990 100644 --- a/web-api/src/business/useCaseHelper/consolidatedCases/formatPublicCase.ts +++ b/web-api/src/business/useCaseHelper/consolidatedCases/formatPublicCase.ts @@ -1,6 +1,5 @@ import { Case, isSealedCase } from '@shared/business/entities/cases/Case'; import { PublicCase } from '@shared/business/entities/cases/PublicCase'; -import { ServerApplicationContext } from '@web-api/applicationContext'; import { caseContactAddressSealedFormatter, caseSealedFormatter, @@ -15,12 +14,9 @@ import { decorateForCaseStatus } from '@shared/business/useCases/getCaseInteract * @param {object} providers.rawCaseRecord the rawCaseRecord * @returns {object} the validated public case data */ - export const formatPublicCase = ({ - applicationContext, rawCaseRecord, }: { - applicationContext: ServerApplicationContext; rawCaseRecord?: Case; }) => { if (isSealedCase(rawCaseRecord)) { @@ -34,7 +30,7 @@ export const formatPublicCase = ({ rawCaseRecord = decorateForCaseStatus(rawCaseRecord); const publicCaseDetail = new PublicCase(rawCaseRecord, { - applicationContext, + authorizedUser: undefined, }); return publicCaseDetail.validate().toRawObject(); diff --git a/web-api/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.ts b/web-api/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.ts index a4942cf199a..7b7e4c54f4c 100644 --- a/web-api/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.ts +++ b/web-api/src/business/useCases/public/getCaseForPublicDocketSearchInteractor.ts @@ -39,7 +39,7 @@ export const getCaseForPublicDocketSearchInteractor = async ( throw error; } else { caseDetailRaw = new PublicCase(caseRecord, { - applicationContext, + authorizedUser: undefined, }) .validate() .toRawObject(); diff --git a/web-api/src/business/useCases/public/getPublicCaseInteractor.ts b/web-api/src/business/useCases/public/getPublicCaseInteractor.ts index 7ed3f47aadb..3cd11196916 100644 --- a/web-api/src/business/useCases/public/getPublicCaseInteractor.ts +++ b/web-api/src/business/useCases/public/getPublicCaseInteractor.ts @@ -28,5 +28,5 @@ export const getPublicCaseInteractor = async ( throw error; } - return formatPublicCase({ applicationContext, rawCaseRecord }); + return formatPublicCase({ rawCaseRecord }); }; From 313bcbdb4733f9aa88a3b9f412d1731fa3e11f4e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 15:10:32 -0700 Subject: [PATCH 060/523] 10417: Transition Work Item away from appContext --- .../entities/DocketEntry.setWorkItem.test.ts | 25 +- shared/src/business/entities/DocketEntry.ts | 8 +- shared/src/business/entities/WorkItem.test.ts | 299 ++++++++---------- shared/src/business/entities/WorkItem.ts | 10 +- .../saveCaseDetailInternalEditInteractor.ts | 1 - .../useCases/updateContactInteractor.ts | 1 - .../fileAndServeDocumentOnOneCase.ts | 1 - .../service/createChangeItems.ts | 1 - .../useCases/createCaseFromPaperInteractor.ts | 5 +- .../business/useCases/createCaseInteractor.ts | 3 - .../docketEntry/addPaperFilingInteractor.ts | 1 - .../fileCourtIssuedDocketEntryInteractor.ts | 1 - .../fileExternalDocumentInteractor.ts | 43 ++- .../workItems/assignWorkItemsInteractor.ts | 4 +- .../workItems/completeWorkItemInteractor.ts | 8 +- .../workItems/getWorkItemInteractor.ts | 4 +- 16 files changed, 174 insertions(+), 241 deletions(-) diff --git a/shared/src/business/entities/DocketEntry.setWorkItem.test.ts b/shared/src/business/entities/DocketEntry.setWorkItem.test.ts index e8d0316644e..52394c4c507 100644 --- a/shared/src/business/entities/DocketEntry.setWorkItem.test.ts +++ b/shared/src/business/entities/DocketEntry.setWorkItem.test.ts @@ -12,25 +12,22 @@ describe('setWorkItem', () => { }, { applicationContext, petitioners: MOCK_PETITIONERS }, ); - const workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.new, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: A_VALID_DOCKET_ENTRY, - docketNumber: '101-18', - section: PETITIONS_SECTION, - sentBy: 'bob', - }, - { applicationContext }, - ); + const workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.new, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: A_VALID_DOCKET_ENTRY, + docketNumber: '101-18', + section: PETITIONS_SECTION, + sentBy: 'bob', + }); myDoc.setWorkItem(workItem); expect(myDoc.isValid()).toBeTruthy(); - myDoc.setWorkItem(new WorkItem({}, { applicationContext })); + myDoc.setWorkItem(new WorkItem({})); expect(myDoc.isValid()).toBeFalsy(); }); diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index 87ab0827dcc..498d69004c2 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -179,9 +179,7 @@ export class DocketEntry extends JoiValidationEntity { !filtered || User.isInternalUser(applicationContext.getCurrentUser().role) ) { - this.initForUnfilteredForInternalUsers(rawDocketEntry, { - applicationContext, - }); + this.initForUnfilteredForInternalUsers(rawDocketEntry); } this.action = rawDocketEntry.action; @@ -282,7 +280,7 @@ export class DocketEntry extends JoiValidationEntity { this.generateFiledBy(petitioners); } - initForUnfilteredForInternalUsers(rawDocketEntry, { applicationContext }) { + private initForUnfilteredForInternalUsers(rawDocketEntry) { this.editState = rawDocketEntry.editState; this.draftOrderState = rawDocketEntry.draftOrderState; this.stampData = rawDocketEntry.stampData || {}; @@ -310,7 +308,7 @@ export class DocketEntry extends JoiValidationEntity { this.strickenByUserId = rawDocketEntry.strickenByUserId; this.userId = rawDocketEntry.userId; this.workItem = rawDocketEntry.workItem - ? new WorkItem(rawDocketEntry.workItem, { applicationContext }) + ? new WorkItem(rawDocketEntry.workItem) : undefined; } diff --git a/shared/src/business/entities/WorkItem.test.ts b/shared/src/business/entities/WorkItem.test.ts index a54b062aa2c..095cfff1354 100644 --- a/shared/src/business/entities/WorkItem.test.ts +++ b/shared/src/business/entities/WorkItem.test.ts @@ -5,7 +5,6 @@ import { } from './EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; import { WorkItem } from './WorkItem'; -import { applicationContext } from '../test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; describe('WorkItem', () => { @@ -27,87 +26,75 @@ describe('WorkItem', () => { }); it('Creates a valid workitem', () => { - const workItem = new WorkItem(aValidWorkItem, { applicationContext }); + const workItem = new WorkItem(aValidWorkItem); expect(workItem.isValid()).toBeTruthy(); }); it('Creates a valid workitem when using setStatus', () => { - const workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseTitle: 'Johnny Joe Jacobson', - docketEntry: {}, - docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - section: DOCKET_SECTION, - sentBy: 'bob', - }, - { applicationContext }, - ); + const workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseTitle: 'Johnny Joe Jacobson', + docketEntry: {}, + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + section: DOCKET_SECTION, + sentBy: 'bob', + }); workItem.setStatus(CASE_STATUS_TYPES.new); expect(workItem.caseStatus).toEqual(CASE_STATUS_TYPES.new); expect(workItem.isValid()).toBeTruthy(); }); it('Update a valid workitem with a workItemId', () => { - const workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.new, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: {}, - docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - section: DOCKET_SECTION, - sentBy: 'bob', - workItemId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - }, - { applicationContext }, - ); + const workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.new, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: {}, + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + section: DOCKET_SECTION, + sentBy: 'bob', + workItemId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + }); expect(workItem.isValid()).toBeTruthy(); }); it('Update a valid workitem with a isRead', () => { - const workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.new, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: {}, - docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - isRead: true, - section: DOCKET_SECTION, - sentBy: 'bob', - workItemId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - }, - { applicationContext }, - ); + const workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.new, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: {}, + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + isRead: true, + section: DOCKET_SECTION, + sentBy: 'bob', + workItemId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + }); expect(workItem.isValid()).toBeTruthy(); }); it('should create a valid workitem when caseStatus is calendared', () => { - const workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.calendared, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: {}, - docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - isRead: true, - section: DOCKET_SECTION, - sentBy: 'bob', - trialDate: '2018-11-21T20:49:28.192Z', - trialLocation: 'Fairbanks, Alaska', - workItemId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - }, - { applicationContext }, - ); + const workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.calendared, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: {}, + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + isRead: true, + section: DOCKET_SECTION, + sentBy: 'bob', + trialDate: '2018-11-21T20:49:28.192Z', + trialLocation: 'Fairbanks, Alaska', + workItemId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + }); expect(workItem.isValid()).toBe(true); }); @@ -128,11 +115,7 @@ describe('WorkItem', () => { mockCase.trialDate = '2018-11-21T20:49:28.192Z'; mockCase.trialLocation = 'Seattle, WA'; - const workItem = new WorkItem( - aValidWorkItem, - { applicationContext }, - mockCase, - ); + const workItem = new WorkItem(aValidWorkItem, mockCase); expect(workItem.isValid()).toBeTruthy(); expect(workItem.associatedJudge).toBe(mockCase.associatedJudge); @@ -148,19 +131,16 @@ describe('WorkItem', () => { }); it('assigns user provided to `assignUser`', () => { - const workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.new, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: {}, - docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - sentBy: 'bob', - }, - { applicationContext }, - ); + const workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.new, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: {}, + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + sentBy: 'bob', + }); const assignment = { assigneeId: '111cd447-6278-461b-b62b-d9e357eea62c', @@ -175,87 +155,75 @@ describe('WorkItem', () => { }); it('is set high priority if case is calendared or overridden', () => { - let workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.new, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: {}, - docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - section: DOCKET_SECTION, - sentBy: 'bob', - }, - { applicationContext }, - ); + let workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.new, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: {}, + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + section: DOCKET_SECTION, + sentBy: 'bob', + }); expect(workItem.highPriority).toBe(false); - workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.calendared, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: {}, - docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - section: DOCKET_SECTION, - sentBy: 'bob', - }, - { applicationContext }, - ); + workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.calendared, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: {}, + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + section: DOCKET_SECTION, + sentBy: 'bob', + }); expect(workItem.highPriority).toBe(true); - workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.new, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: {}, - docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - highPriority: true, - section: DOCKET_SECTION, - sentBy: 'bob', - }, - { applicationContext }, - ); + workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.new, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: {}, + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + highPriority: true, + section: DOCKET_SECTION, + sentBy: 'bob', + }); expect(workItem.highPriority).toBe(true); }); it('creates a workItem containing a docketEntry with only the picked fields', () => { - const workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.new, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: { - createdAt: '2018-11-21T20:49:28.192Z', - docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', - docketNumber: '101-18', - documentTitle: 'Proposed Stipulated Decision', - documentType: 'Proposed Stipulated Decision', - editState: {}, - eventCode: 'PSDE', - filedBy: 'Test Petitioner', - filingDate: '2018-03-01T00:01:00.000Z', - index: 5, - isFileAttached: true, - processingStatus: 'pending', - receivedAt: '2018-03-01T00:01:00.000Z', - servedAt: '2019-08-25T05:00:00.000Z', - }, + const workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.new, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: { + createdAt: '2018-11-21T20:49:28.192Z', + docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - leadDocketNumber: '101-18', - section: DOCKET_SECTION, - sentBy: 'bob', + documentTitle: 'Proposed Stipulated Decision', + documentType: 'Proposed Stipulated Decision', + editState: {}, + eventCode: 'PSDE', + filedBy: 'Test Petitioner', + filingDate: '2018-03-01T00:01:00.000Z', + index: 5, + isFileAttached: true, + processingStatus: 'pending', + receivedAt: '2018-03-01T00:01:00.000Z', + servedAt: '2019-08-25T05:00:00.000Z', }, - { applicationContext }, - ); + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + leadDocketNumber: '101-18', + section: DOCKET_SECTION, + sentBy: 'bob', + }); expect(workItem.docketEntry.docketNumber).toBeUndefined(); expect(workItem.docketEntry.editState).toBeUndefined(); expect(workItem.docketEntry.processingStatus).toBeUndefined(); @@ -266,20 +234,17 @@ describe('WorkItem', () => { describe('markAsRead', () => { it('should set isRead to true', () => { - const workItem = new WorkItem( - { - assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', - assigneeName: 'bob', - caseStatus: CASE_STATUS_TYPES.new, - caseTitle: 'Johnny Joe Jacobson', - docketEntry: {}, - docketNumber: '101-18', - docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, - section: DOCKET_SECTION, - sentBy: 'bob', - }, - { applicationContext }, - ); + const workItem = new WorkItem({ + assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', + assigneeName: 'bob', + caseStatus: CASE_STATUS_TYPES.new, + caseTitle: 'Johnny Joe Jacobson', + docketEntry: {}, + docketNumber: '101-18', + docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.SMALL, + section: DOCKET_SECTION, + sentBy: 'bob', + }); expect(workItem.isRead).toBeFalsy(); diff --git a/shared/src/business/entities/WorkItem.ts b/shared/src/business/entities/WorkItem.ts index 68255c99389..e38935bcca1 100644 --- a/shared/src/business/entities/WorkItem.ts +++ b/shared/src/business/entities/WorkItem.ts @@ -3,6 +3,7 @@ import { Case } from '@shared/business/entities/cases/Case'; import { JoiValidationEntity } from '@shared/business/entities/JoiValidationEntity'; import { WORK_ITEM_VALIDATION_RULES } from './EntityValidationConstants'; import { createISODateString } from '../utilities/DateHandler'; +import { getUniqueId } from '@shared/sharedAppContext'; import { pick } from 'lodash'; export class WorkItem extends JoiValidationEntity { @@ -36,13 +37,9 @@ export class WorkItem extends JoiValidationEntity { public updatedAt: string; public workItemId: string; - constructor(rawWorkItem, { applicationContext }, caseEntity?: Case) { + constructor(rawWorkItem, caseEntity?: Case) { super('WorkItem'); - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } - this.assigneeId = rawWorkItem.assigneeId; this.assigneeName = rawWorkItem.assigneeName; this.associatedJudge = @@ -104,8 +101,7 @@ export class WorkItem extends JoiValidationEntity { ? caseEntity.trialLocation : rawWorkItem.trialLocation; this.updatedAt = rawWorkItem.updatedAt || createISODateString(); - this.workItemId = - rawWorkItem.workItemId || applicationContext.getUniqueId(); + this.workItemId = rawWorkItem.workItemId || getUniqueId(); } assignToUser({ diff --git a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts index cf1d8d4b197..fbcd8483f8e 100644 --- a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts +++ b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts @@ -149,7 +149,6 @@ export const saveCaseDetailInternalEdit = async ( trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - { applicationContext }, caseEntity, ); diff --git a/shared/src/business/useCases/updateContactInteractor.ts b/shared/src/business/useCases/updateContactInteractor.ts index 5f6e384ce88..f9adb0cd3a7 100644 --- a/shared/src/business/useCases/updateContactInteractor.ts +++ b/shared/src/business/useCases/updateContactInteractor.ts @@ -175,7 +175,6 @@ export const updateContact = async ( trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - { applicationContext }, caseEntity, ); diff --git a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts index 7fa756546c4..740bb99287e 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts @@ -40,7 +40,6 @@ export const fileAndServeDocumentOnOneCase = async ({ trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - { applicationContext }, caseEntity, ); } diff --git a/web-api/src/business/useCaseHelper/service/createChangeItems.ts b/web-api/src/business/useCaseHelper/service/createChangeItems.ts index eab0f6551ad..7c9552e0470 100644 --- a/web-api/src/business/useCaseHelper/service/createChangeItems.ts +++ b/web-api/src/business/useCaseHelper/service/createChangeItems.ts @@ -147,7 +147,6 @@ const createWorkItemForChange = async ({ trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - { applicationContext }, caseEntity, ); diff --git a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts index 7febed2dfe3..b2d89135799 100644 --- a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts +++ b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts @@ -12,16 +12,15 @@ import { import { RawUser } from '@shared/business/entities/User'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '../../errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../../../../shared/src/business/entities/WorkItem'; import { replaceBracketed } from '../../../../shared/src/business/utilities/replaceBracketed'; const addPetitionDocketEntryWithWorkItemToCase = ({ - applicationContext, caseToAdd, docketEntryEntity, user, }: { - applicationContext: ServerApplicationContext; caseToAdd: Case; docketEntryEntity: DocketEntry; user: RawUser; @@ -51,7 +50,6 @@ const addPetitionDocketEntryWithWorkItemToCase = ({ trialDate: caseToAdd.trialDate, trialLocation: caseToAdd.trialLocation, }, - { applicationContext }, caseToAdd, ); @@ -148,7 +146,6 @@ export const createCaseFromPaperInteractor = async ( petitionDocketEntryEntity.setFiledBy(user); const { workItem: newWorkItem } = addPetitionDocketEntryWithWorkItemToCase({ - applicationContext, caseToAdd, docketEntryEntity: petitionDocketEntryEntity, user, diff --git a/web-api/src/business/useCases/createCaseInteractor.ts b/web-api/src/business/useCases/createCaseInteractor.ts index 89f617a744c..ca2281ce839 100644 --- a/web-api/src/business/useCases/createCaseInteractor.ts +++ b/web-api/src/business/useCases/createCaseInteractor.ts @@ -21,7 +21,6 @@ import { setServiceIndicatorsForCase } from '../../../../shared/src/business/uti export type ElectronicCreatedCaseType = Omit; const addPetitionDocketEntryToCase = ({ - applicationContext, caseToAdd, docketEntryEntity, user, @@ -47,7 +46,6 @@ const addPetitionDocketEntryToCase = ({ trialDate: caseToAdd.trialDate, trialLocation: caseToAdd.trialLocation, }, - { applicationContext }, caseToAdd, ); @@ -183,7 +181,6 @@ export const createCaseInteractor = async ( petitionDocketEntryEntity.setFiledBy(user); const newWorkItem = addPetitionDocketEntryToCase({ - applicationContext, caseToAdd, docketEntryEntity: petitionDocketEntryEntity, user, diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts index 6f2ba296240..96fdf567165 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts @@ -144,7 +144,6 @@ export const addPaperFiling = async ( trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - { applicationContext }, caseEntity, ); diff --git a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts index 51224cf11f2..bc77aa43e3e 100644 --- a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts @@ -135,7 +135,6 @@ export const fileCourtIssuedDocketEntry = async ( trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - { applicationContext }, caseEntity, ); diff --git a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts index c2cfef8e7da..61fa4b7e9eb 100644 --- a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts +++ b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts @@ -160,30 +160,27 @@ export const fileExternalDocument = async ( const highPriorityWorkItem = caseEntity.status === CASE_STATUS_TYPES.calendared; - const workItem = new WorkItem( - { - assigneeId: null, - assigneeName: null, - associatedJudge: caseToUpdate.associatedJudge, - associatedJudgeId: caseToUpdate.associatedJudgeId, - caseStatus: caseToUpdate.status, - caseTitle: Case.getCaseTitle(caseEntity.caseCaption), - docketEntry: { - ...docketEntryEntity.toRawObject(), - createdAt: docketEntryEntity.createdAt, - }, - docketNumber: caseToUpdate.docketNumber, - docketNumberWithSuffix: caseToUpdate.docketNumberWithSuffix, - highPriority: highPriorityWorkItem, - leadDocketNumber: caseToUpdate.leadDocketNumber, - section: DOCKET_SECTION, - sentBy: user.name, - sentByUserId: user.userId, - trialDate: caseEntity.trialDate, - trialLocation: caseEntity.trialLocation, + const workItem = new WorkItem({ + assigneeId: null, + assigneeName: null, + associatedJudge: caseToUpdate.associatedJudge, + associatedJudgeId: caseToUpdate.associatedJudgeId, + caseStatus: caseToUpdate.status, + caseTitle: Case.getCaseTitle(caseEntity.caseCaption), + docketEntry: { + ...docketEntryEntity.toRawObject(), + createdAt: docketEntryEntity.createdAt, }, - { applicationContext }, - ).validate(); + docketNumber: caseToUpdate.docketNumber, + docketNumberWithSuffix: caseToUpdate.docketNumberWithSuffix, + highPriority: highPriorityWorkItem, + leadDocketNumber: caseToUpdate.leadDocketNumber, + section: DOCKET_SECTION, + sentBy: user.name, + sentByUserId: user.userId, + trialDate: caseEntity.trialDate, + trialLocation: caseEntity.trialLocation, + }).validate(); docketEntryEntity.setWorkItem(workItem); diff --git a/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.ts b/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.ts index 8117d5d89e0..c1431786ec9 100644 --- a/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.ts +++ b/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.ts @@ -52,9 +52,7 @@ export const assignWorkItemsInteractor = async ( workItemId, }); - const workItemEntity = new WorkItem(workItemRecord, { - applicationContext, - }); + const workItemEntity = new WorkItem(workItemRecord); const userIsCaseServices = User.isCaseServicesUser({ section: user.section }); const userBeingAssignedIsCaseServices = User.isCaseServicesUser({ section: userBeingAssigned.section, diff --git a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts index 76952b14810..2b24e50123a 100644 --- a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts +++ b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts @@ -40,9 +40,7 @@ export const completeWorkItem = async ( applicationContext, workItemId, }); - const originalWorkItemEntity = new WorkItem(originalWorkItem, { - applicationContext, - }); + const originalWorkItemEntity = new WorkItem(originalWorkItem); const completedWorkItem = originalWorkItemEntity .setAsCompleted({ @@ -74,9 +72,7 @@ export const completeWorkItem = async ( const caseToUpdate = new Case(caseObject, { applicationContext }); - const workItemEntity = new WorkItem(completedWorkItem, { - applicationContext, - }); + const workItemEntity = new WorkItem(completedWorkItem); caseToUpdate.docketEntries.forEach(doc => { if (doc.workItem && doc.workItem.workItemId === workItemEntity.workItemId) { diff --git a/web-api/src/business/useCases/workItems/getWorkItemInteractor.ts b/web-api/src/business/useCases/workItems/getWorkItemInteractor.ts index a97e59ffa0a..ded74818da2 100644 --- a/web-api/src/business/useCases/workItems/getWorkItemInteractor.ts +++ b/web-api/src/business/useCases/workItems/getWorkItemInteractor.ts @@ -41,7 +41,5 @@ export const getWorkItemInteractor = async ( throw new UnauthorizedError('Unauthorized'); } - return new WorkItem(workItem, { applicationContext }) - .validate() - .toRawObject(); + return new WorkItem(workItem).validate().toRawObject(); }; From 88282471a0f67b91513bb22b03ef119a2ab251ff Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 15:58:36 -0700 Subject: [PATCH 061/523] 10417: WIP Transition DocketEntry away from appContext --- .../fix-race-condition-served-in-drafts.ts | 2 +- .../entities/DocketEntry.archive.test.ts | 3 +- .../DocketEntry.generateFiledBy.test.ts | 37 ++++++----- .../entities/DocketEntry.isAutoServed.test.ts | 11 ++-- .../DocketEntry.isCourtIssued.test.ts | 11 +++- .../DocketEntry.isMinuteEntry.test.ts | 9 ++- .../DocketEntry.isPendingOnCreation.test.ts | 17 +++-- .../entities/DocketEntry.isServed.test.ts | 7 +-- .../entities/DocketEntry.isUnservable.test.ts | 5 +- .../entities/DocketEntry.sealEntry.test.ts | 5 +- ...y.setAsProcessingStatusAsCompleted.test.ts | 3 +- .../entities/DocketEntry.setAsServed.test.ts | 7 +-- .../DocketEntry.setNumberOfPages.test.ts | 3 +- .../entities/DocketEntry.setQCed.test.ts | 3 +- .../entities/DocketEntry.setWorkItem.test.ts | 3 +- ...etEntry.shouldAutoGenerateDeadline.test.ts | 5 +- .../entities/DocketEntry.strikeEntry.test.ts | 5 +- .../src/business/entities/DocketEntry.test.ts | 62 +++++++++---------- shared/src/business/entities/DocketEntry.ts | 19 +++--- .../entities/DocketEntry.unsealEntry.test.ts | 7 +-- .../DocketEntry.unsignDocument.test.ts | 3 +- .../entities/DocketEntry.validate.test.ts | 6 +- shared/src/business/entities/User.ts | 2 +- .../cases/Case.archiveDocketEntry.test.ts | 2 +- 24 files changed, 110 insertions(+), 127 deletions(-) diff --git a/scripts/dynamo/fix-race-condition-served-in-drafts.ts b/scripts/dynamo/fix-race-condition-served-in-drafts.ts index 93ee15220fe..ac2ed118c6d 100644 --- a/scripts/dynamo/fix-race-condition-served-in-drafts.ts +++ b/scripts/dynamo/fix-race-condition-served-in-drafts.ts @@ -140,7 +140,7 @@ export const fixRaceConditionServedInDrafts = async ( // TODO: figure out index const docketEntry = new DocketEntry(rawDocketEntry, { - applicationContext, + authorizedUser: undefined, }).validate(); docketEntry.setAsServed(servedParties.all); diff --git a/shared/src/business/entities/DocketEntry.archive.test.ts b/shared/src/business/entities/DocketEntry.archive.test.ts index cc99e7d6298..d66e4ca6a94 100644 --- a/shared/src/business/entities/DocketEntry.archive.test.ts +++ b/shared/src/business/entities/DocketEntry.archive.test.ts @@ -1,11 +1,10 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('archive', () => { it('archives the document', () => { const docketEntry = new DocketEntry(A_VALID_DOCKET_ENTRY, { - applicationContext, + authorizedUser: undefined, petitioners: [ { contactId: '7111b30b-ad38-42c8-9db0-d938cb2cb16b', diff --git a/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts b/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts index d9189a0ea78..467dc45986c 100644 --- a/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts +++ b/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts @@ -1,7 +1,6 @@ import { DocketEntry } from './DocketEntry'; import { MOCK_DOCUMENTS } from '../../test/mockDocketEntry'; import { NOTICE_OF_CHANGE_CONTACT_INFORMATION_MAP } from './EntityConstants'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('generateFiledBy', () => { let mockDocketEntry; @@ -24,7 +23,7 @@ describe('generateFiledBy', () => { ...mockDocketEntry, filers: [mockPrimaryContactId], }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual('Petr. Bob'); @@ -37,7 +36,7 @@ describe('generateFiledBy', () => { filers: [mockPrimaryContactId], otherFilingParty: mockOtherFilingParty, }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual(`Petr. Bob, ${mockOtherFilingParty}`); @@ -49,7 +48,7 @@ describe('generateFiledBy', () => { ...mockDocketEntry, filers: [mockSecondaryContactId], }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual('Petr. Bill'); @@ -62,7 +61,7 @@ describe('generateFiledBy', () => { filers: [mockPrimaryContactId], partyIrsPractitioner: true, }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual('Resp. & Petr. Bob'); @@ -76,7 +75,7 @@ describe('generateFiledBy', () => { otherFilingParty: mockOtherFilingParty, partyIrsPractitioner: true, }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual( @@ -90,7 +89,7 @@ describe('generateFiledBy', () => { ...mockDocketEntry, otherFilingParty: mockOtherFilingParty, }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual(mockOtherFilingParty); @@ -102,7 +101,7 @@ describe('generateFiledBy', () => { ...mockDocketEntry, filers: [mockPrimaryContactId, mockSecondaryContactId], }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual('Petrs. Bob & Bill'); @@ -118,7 +117,7 @@ describe('generateFiledBy', () => { name: 'Test Practitioner', }, }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual('Resp.'); @@ -137,7 +136,7 @@ describe('generateFiledBy', () => { }, ], }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual('Resp.'); @@ -150,7 +149,7 @@ describe('generateFiledBy', () => { filers: [mockPrimaryContactId], partyIrsPractitioner: true, }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual('Resp. & Petr. Bob'); @@ -162,7 +161,7 @@ describe('generateFiledBy', () => { ...mockDocketEntry, filers: [mockPrimaryContactId, mockSecondaryContactId], }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual('Petrs. Bob & Bill'); @@ -178,7 +177,7 @@ describe('generateFiledBy', () => { ...mockDocketEntry, filers: [mockPrimaryContactId], }, - { applicationContext, petitioners: mockIntervenors }, + { authorizedUser: undefined, petitioners: mockIntervenors }, ); expect(docketEntry.filedBy).toEqual('Intv. Bob'); }); @@ -193,7 +192,7 @@ describe('generateFiledBy', () => { ...mockDocketEntry, filers: [mockPrimaryContactId, mockSecondaryContactId], }, - { applicationContext, petitioners: mockIntervenors }, + { authorizedUser: undefined, petitioners: mockIntervenors }, ); expect(docketEntry.filedBy).toEqual('Intvs. Bob & Bill'); }); @@ -211,7 +210,7 @@ describe('generateFiledBy', () => { }, ], }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toEqual('Resp.'); @@ -227,7 +226,7 @@ describe('generateFiledBy', () => { filers: [mockPrimaryContactId], isAutoGenerated: true, }, - { applicationContext, petitioners: mockPetitioners }, + { authorizedUser: undefined, petitioners: mockPetitioners }, ); expect(docketEntry.filedBy).toBeUndefined(); @@ -244,7 +243,7 @@ describe('generateFiledBy', () => { servedAt: undefined, }, { - applicationContext, + authorizedUser: undefined, petitioners: mockPetitioners, }, ); @@ -265,7 +264,7 @@ describe('generateFiledBy', () => { ], }, { - applicationContext, + authorizedUser: undefined, petitioners: mockPetitioners, }, ); @@ -285,7 +284,7 @@ describe('generateFiledBy', () => { servedParties: 'Test Petitioner', }, { - applicationContext, + authorizedUser: undefined, petitioners: mockPetitioners, }, ); diff --git a/shared/src/business/entities/DocketEntry.isAutoServed.test.ts b/shared/src/business/entities/DocketEntry.isAutoServed.test.ts index 2b3eee9437c..ee42750fc34 100644 --- a/shared/src/business/entities/DocketEntry.isAutoServed.test.ts +++ b/shared/src/business/entities/DocketEntry.isAutoServed.test.ts @@ -4,7 +4,6 @@ import { EXTERNAL_DOCUMENT_TYPES, SIMULTANEOUS_DOCUMENT_EVENT_CODES, } from './EntityConstants'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('isAutoServed', () => { it('should return true if the documentType is an external document and the document is not a Simultaneous Document', () => { @@ -14,7 +13,7 @@ describe('isAutoServed', () => { documentTitle: 'Answer to Second Amendment to Petition', documentType: 'Answer to Second Amendment to Petition', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isAutoServed()).toBeTruthy(); @@ -27,7 +26,7 @@ describe('isAutoServed', () => { documentTitle: 'Notice of Election to Participate', documentType: 'Notice of Election to Participate', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isAutoServed()).toBeTruthy(); @@ -57,7 +56,7 @@ describe('isAutoServed', () => { documentType: EXTERNAL_DOCUMENT_TYPES[0], eventCode: 'AMAT', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isAutoServed()).toBeFalsy(); @@ -70,7 +69,7 @@ describe('isAutoServed', () => { documentType: SIMULTANEOUS_DOCUMENT_EVENT_CODES[0], eventCode: 'SIAB', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isAutoServed()).toBeFalsy(); @@ -83,7 +82,7 @@ describe('isAutoServed', () => { documentTitle: 'Application for Examination Pursuant to Rule 73', documentType: 'Application for Examination Pursuant to Rule 73', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isAutoServed()).toBeFalsy(); diff --git a/shared/src/business/entities/DocketEntry.isCourtIssued.test.ts b/shared/src/business/entities/DocketEntry.isCourtIssued.test.ts index b5476dad2b7..b5cbe34ba72 100644 --- a/shared/src/business/entities/DocketEntry.isCourtIssued.test.ts +++ b/shared/src/business/entities/DocketEntry.isCourtIssued.test.ts @@ -1,15 +1,20 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('isCourtIssued', () => { it('should return false when the docketEntry.eventCode is NOT in the list of court issued documents', () => { - const doc1 = new DocketEntry({ eventCode: 'PMT' }, { applicationContext }); + const doc1 = new DocketEntry( + { eventCode: 'PMT' }, + { authorizedUser: undefined }, + ); expect(doc1.isCourtIssued()).toBeFalsy(); }); it('should return true when the docketEntry.eventCode is in the list of court issued documents', () => { - const doc1 = new DocketEntry({ eventCode: 'O' }, { applicationContext }); + const doc1 = new DocketEntry( + { eventCode: 'O' }, + { authorizedUser: undefined }, + ); expect(doc1.isCourtIssued()).toBeTruthy(); }); diff --git a/shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts b/shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts index eac084fa798..a6e5af456e7 100644 --- a/shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts @@ -1,6 +1,5 @@ import { DocketEntry } from './DocketEntry'; import { MINUTE_ENTRIES_MAP } from './EntityConstants'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('isMinuteEntry', () => { describe('non RQT event codes', () => { @@ -13,7 +12,7 @@ describe('isMinuteEntry', () => { eventCode => { const minuteEntry = new DocketEntry( { eventCode }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(DocketEntry.isMinuteEntry(minuteEntry)).toBe(true); @@ -23,7 +22,7 @@ describe('isMinuteEntry', () => { it('should return false when the docketEntry eventCode is NOT in the list of minute entries', () => { const orderDocketEntry = new DocketEntry( { eventCode: 'O', isFileAttached: true }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(DocketEntry.isMinuteEntry(orderDocketEntry)).toBe(false); @@ -34,7 +33,7 @@ describe('isMinuteEntry', () => { it('should return false when there is a file attached', () => { const orderDocketEntry = new DocketEntry( { eventCode: 'RQT', isFileAttached: true }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(DocketEntry.isMinuteEntry(orderDocketEntry)).toBe(false); @@ -43,7 +42,7 @@ describe('isMinuteEntry', () => { it('should return true when there is a not file attached', () => { const orderDocketEntry = new DocketEntry( { eventCode: 'RQT', isFileAttached: false }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(DocketEntry.isMinuteEntry(orderDocketEntry)).toBe(true); diff --git a/shared/src/business/entities/DocketEntry.isPendingOnCreation.test.ts b/shared/src/business/entities/DocketEntry.isPendingOnCreation.test.ts index 5e0230f145e..8d2d72d6714 100644 --- a/shared/src/business/entities/DocketEntry.isPendingOnCreation.test.ts +++ b/shared/src/business/entities/DocketEntry.isPendingOnCreation.test.ts @@ -1,5 +1,4 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('isPendingOnCreation', () => { beforeAll(() => { @@ -12,11 +11,11 @@ describe('isPendingOnCreation', () => { it('respects any defined "pending" value', () => { const raw1 = { eventCode: 'FOO', pending: true }; - const doc1 = new DocketEntry(raw1, { applicationContext }); + const doc1 = new DocketEntry(raw1, { authorizedUser: undefined }); expect(doc1.pending).toBeTruthy(); const raw2 = { eventCode: 'FOO', pending: false }; - const doc2 = new DocketEntry(raw2, { applicationContext }); + const doc2 = new DocketEntry(raw2, { authorizedUser: undefined }); expect(doc2.pending).toBeFalsy(); expect(DocketEntry.isPendingOnCreation).not.toHaveBeenCalled(); @@ -24,13 +23,13 @@ describe('isPendingOnCreation', () => { it('sets pending to false for non-matching event code', () => { const raw1 = { eventCode: 'ABC' }; - const doc1 = new DocketEntry(raw1, { applicationContext }); + const doc1 = new DocketEntry(raw1, { authorizedUser: undefined }); expect(doc1.pending).toBe(false); expect(DocketEntry.isPendingOnCreation).toHaveBeenCalled(); const raw2 = { color: 'blue', sport: 'Ice Hockey' }; - const doc2 = new DocketEntry(raw2, { applicationContext }); + const doc2 = new DocketEntry(raw2, { authorizedUser: undefined }); expect(doc2.pending).toBe(false); expect(DocketEntry.isPendingOnCreation).toHaveBeenCalled(); @@ -42,21 +41,21 @@ describe('isPendingOnCreation', () => { documentType: 'some kind of motion', eventCode: 'M006', }; - const doc1 = new DocketEntry(raw1, { applicationContext }); + const doc1 = new DocketEntry(raw1, { authorizedUser: undefined }); expect(doc1.pending).toBeTruthy(); const raw2 = { documentType: 'it is a proposed stipulated decision', eventCode: 'PSDE', }; - const doc2 = new DocketEntry(raw2, { applicationContext }); + const doc2 = new DocketEntry(raw2, { authorizedUser: undefined }); expect(doc2.pending).toBeTruthy(); const raw3 = { documentType: 'it is an order to show cause', eventCode: 'OSC', }; - const doc3 = new DocketEntry(raw3, { applicationContext }); + const doc3 = new DocketEntry(raw3, { authorizedUser: undefined }); expect(doc3.pending).toBeTruthy(); const raw4 = { @@ -64,7 +63,7 @@ describe('isPendingOnCreation', () => { documentType: 'Application for Waiver of Filing Fee', eventCode: 'APW', }; - const doc4 = new DocketEntry(raw4, { applicationContext }); + const doc4 = new DocketEntry(raw4, { authorizedUser: undefined }); expect(doc4.pending).toBeTruthy(); }); }); diff --git a/shared/src/business/entities/DocketEntry.isServed.test.ts b/shared/src/business/entities/DocketEntry.isServed.test.ts index 9012e6415f1..23e4cfc8cc5 100644 --- a/shared/src/business/entities/DocketEntry.isServed.test.ts +++ b/shared/src/business/entities/DocketEntry.isServed.test.ts @@ -1,11 +1,10 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('isServed', () => { it('should return false when servedAt is undefined and isLegacyServed is false', () => { const doc1 = new DocketEntry( { isLegacyServed: undefined, servedAt: undefined }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(DocketEntry.isServed(doc1)).toBeFalsy(); @@ -14,7 +13,7 @@ describe('isServed', () => { it('should return true when servedAt is defined', () => { const doc1 = new DocketEntry( { isLegacyServed: undefined, servedAt: '2020-07-17T19:28:29.675Z' }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(DocketEntry.isServed(doc1)).toBeTruthy(); @@ -23,7 +22,7 @@ describe('isServed', () => { it('should return true when servedAt is undefined and isLegacyServed is true', () => { const doc1 = new DocketEntry( { isLegacyServed: true, servedAt: undefined }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(DocketEntry.isServed(doc1)).toBeTruthy(); diff --git a/shared/src/business/entities/DocketEntry.isUnservable.test.ts b/shared/src/business/entities/DocketEntry.isUnservable.test.ts index e422b8b9b78..9be233c3f7b 100644 --- a/shared/src/business/entities/DocketEntry.isUnservable.test.ts +++ b/shared/src/business/entities/DocketEntry.isUnservable.test.ts @@ -1,13 +1,12 @@ import { DocketEntry } from './DocketEntry'; import { UNSERVABLE_EVENT_CODES } from './EntityConstants'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('isUnservable', () => { UNSERVABLE_EVENT_CODES.forEach(eventCode => { it(`returns true when the docketEntry event code is in the list of unservable event codes (${eventCode})`, () => { const unservableDocketEntry = new DocketEntry( { eventCode }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(DocketEntry.isUnservable(unservableDocketEntry)).toBe(true); @@ -17,7 +16,7 @@ describe('isUnservable', () => { it('should return false when the docketEntry event code is NOT in the list of unservable event codes', () => { const servableDocketEntry = new DocketEntry( { eventCode: 'O' }, // O is the Order event code, Orders are servable - { applicationContext }, + { authorizedUser: undefined }, ); expect(DocketEntry.isUnservable(servableDocketEntry)).toBe(false); diff --git a/shared/src/business/entities/DocketEntry.sealEntry.test.ts b/shared/src/business/entities/DocketEntry.sealEntry.test.ts index 4f6a13566f1..100d077b053 100644 --- a/shared/src/business/entities/DocketEntry.sealEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.sealEntry.test.ts @@ -1,12 +1,11 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; import { DOCKET_ENTRY_SEALED_TO_TYPES } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('sealEntry', () => { it('should set the sealedTo property of the docket entry', () => { const docketEntry = new DocketEntry(A_VALID_DOCKET_ENTRY, { - applicationContext, + authorizedUser: undefined, }); docketEntry.sealEntry({ sealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC }); expect(docketEntry.sealedTo).toEqual(DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC); @@ -16,7 +15,7 @@ describe('sealEntry', () => { const docketEntry = new DocketEntry( { ...A_VALID_DOCKET_ENTRY, isSealed: undefined }, { - applicationContext, + authorizedUser: undefined, }, ); docketEntry.sealEntry({ sealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC }); diff --git a/shared/src/business/entities/DocketEntry.setAsProcessingStatusAsCompleted.test.ts b/shared/src/business/entities/DocketEntry.setAsProcessingStatusAsCompleted.test.ts index 523a01fb485..c962f25c774 100644 --- a/shared/src/business/entities/DocketEntry.setAsProcessingStatusAsCompleted.test.ts +++ b/shared/src/business/entities/DocketEntry.setAsProcessingStatusAsCompleted.test.ts @@ -1,7 +1,6 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; import { DOCUMENT_PROCESSING_STATUS_OPTIONS } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('setAsProcessingStatusAsCompleted', () => { it('sets the docket entry processing status as completed', () => { @@ -11,7 +10,7 @@ describe('setAsProcessingStatusAsCompleted', () => { processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, }, { - applicationContext, + authorizedUser: undefined, petitioners: [ { contactId: '7111b30b-ad38-42c8-9db0-d938cb2cb16b', diff --git a/shared/src/business/entities/DocketEntry.setAsServed.test.ts b/shared/src/business/entities/DocketEntry.setAsServed.test.ts index 08861c7f366..d35c74fbd58 100644 --- a/shared/src/business/entities/DocketEntry.setAsServed.test.ts +++ b/shared/src/business/entities/DocketEntry.setAsServed.test.ts @@ -4,7 +4,6 @@ import { PARTIES_CODES, ROLES, } from '@shared/business/entities/EntityConstants'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('setAsServed', () => { it('sets the Document as served', () => { @@ -15,7 +14,7 @@ describe('setAsServed', () => { documentContents: 'Yee to the haw', }, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); docketEntry.setAsServed(); @@ -28,7 +27,7 @@ describe('setAsServed', () => { { ...A_VALID_DOCKET_ENTRY, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); docketEntry.setAsServed([ @@ -47,7 +46,7 @@ describe('setAsServed', () => { ...A_VALID_DOCKET_ENTRY, eventCode: 'ATP', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); docketEntry.setAsServed([ diff --git a/shared/src/business/entities/DocketEntry.setNumberOfPages.test.ts b/shared/src/business/entities/DocketEntry.setNumberOfPages.test.ts index e13a3a5f938..a7ee16f72b3 100644 --- a/shared/src/business/entities/DocketEntry.setNumberOfPages.test.ts +++ b/shared/src/business/entities/DocketEntry.setNumberOfPages.test.ts @@ -1,5 +1,4 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('setNumberOfPages', () => { it('sets the number of pages', () => { @@ -11,7 +10,7 @@ describe('setNumberOfPages', () => { filingDate: '9000-01-01T00:00:00.000Z', index: 1, }, - { applicationContext }, + { authorizedUser: undefined }, ); docketEntry.setNumberOfPages(13); expect(docketEntry.numberOfPages).toEqual(13); diff --git a/shared/src/business/entities/DocketEntry.setQCed.test.ts b/shared/src/business/entities/DocketEntry.setQCed.test.ts index e29c888729b..5acd967e213 100644 --- a/shared/src/business/entities/DocketEntry.setQCed.test.ts +++ b/shared/src/business/entities/DocketEntry.setQCed.test.ts @@ -1,11 +1,10 @@ import { A_VALID_DOCKET_ENTRY, MOCK_PETITIONERS } from './DocketEntry.test'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('setQCed', () => { it('updates the document QC information with user name, id, and date', () => { const docketEntry = new DocketEntry(A_VALID_DOCKET_ENTRY, { - applicationContext, + authorizedUser: undefined, petitioners: MOCK_PETITIONERS, }); const user = { diff --git a/shared/src/business/entities/DocketEntry.setWorkItem.test.ts b/shared/src/business/entities/DocketEntry.setWorkItem.test.ts index 52394c4c507..df4f32acee9 100644 --- a/shared/src/business/entities/DocketEntry.setWorkItem.test.ts +++ b/shared/src/business/entities/DocketEntry.setWorkItem.test.ts @@ -2,7 +2,6 @@ import { A_VALID_DOCKET_ENTRY, MOCK_PETITIONERS } from './DocketEntry.test'; import { CASE_STATUS_TYPES, PETITIONS_SECTION } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; import { WorkItem } from './WorkItem'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('setWorkItem', () => { it('should set work item on docket entry to the passed in work item and validate the nested work item', () => { @@ -10,7 +9,7 @@ describe('setWorkItem', () => { { ...A_VALID_DOCKET_ENTRY, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); const workItem = new WorkItem({ assigneeId: '8b4cd447-6278-461b-b62b-d9e357eea62c', diff --git a/shared/src/business/entities/DocketEntry.shouldAutoGenerateDeadline.test.ts b/shared/src/business/entities/DocketEntry.shouldAutoGenerateDeadline.test.ts index 59aae802596..753fe74c94f 100644 --- a/shared/src/business/entities/DocketEntry.shouldAutoGenerateDeadline.test.ts +++ b/shared/src/business/entities/DocketEntry.shouldAutoGenerateDeadline.test.ts @@ -1,6 +1,5 @@ import { AUTO_GENERATED_DEADLINE_DOCUMENT_TYPES } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('shouldAutoGenerateDeadline', () => { AUTO_GENERATED_DEADLINE_DOCUMENT_TYPES.forEach(item => { @@ -9,7 +8,7 @@ describe('shouldAutoGenerateDeadline', () => { { eventCode: item.eventCode, }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(mockDocketEntry.shouldAutoGenerateDeadline()).toBe(true); @@ -21,7 +20,7 @@ describe('shouldAutoGenerateDeadline', () => { { eventCode: 'O', }, - { applicationContext }, + { authorizedUser: undefined }, ); expect(mockDocketEntry.shouldAutoGenerateDeadline()).toBe(false); diff --git a/shared/src/business/entities/DocketEntry.strikeEntry.test.ts b/shared/src/business/entities/DocketEntry.strikeEntry.test.ts index 4610f39a4bf..e112cd65da2 100644 --- a/shared/src/business/entities/DocketEntry.strikeEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.strikeEntry.test.ts @@ -1,5 +1,4 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('strikeEntry', () => { it('strikes a document if isOnDocketRecord is true', () => { @@ -12,7 +11,7 @@ describe('strikeEntry', () => { index: 1, isOnDocketRecord: true, }, - { applicationContext }, + { authorizedUser: undefined }, ); docketEntry.strikeEntry({ name: 'Test User', @@ -36,7 +35,7 @@ describe('strikeEntry', () => { index: 1, isOnDocketRecord: false, }, - { applicationContext }, + { authorizedUser: undefined }, ); let error; try { diff --git a/shared/src/business/entities/DocketEntry.test.ts b/shared/src/business/entities/DocketEntry.test.ts index e745de277d1..8bdd1c36dc8 100644 --- a/shared/src/business/entities/DocketEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.test.ts @@ -32,7 +32,7 @@ describe('DocketEntry entity', () => { const entry = new DocketEntry( { ...A_VALID_DOCKET_ENTRY, stampData: undefined }, { - applicationContext, + authorizedUser: undefined, petitioners: MOCK_PETITIONERS, }, ); @@ -48,7 +48,7 @@ describe('DocketEntry entity', () => { eventCode: 'NOT', signedAt: null, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(myDoc.signedAt).toBeTruthy(); @@ -61,7 +61,7 @@ describe('DocketEntry entity', () => { eventCode: 'NOT', signedAt: '2019-08-25T05:00:00.000Z', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(myDoc.signedAt).toEqual('2019-08-25T05:00:00.000Z'); @@ -74,7 +74,7 @@ describe('DocketEntry entity', () => { eventCode: 'O', signedAt: null, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(myDoc.signedAt).toEqual(null); @@ -89,7 +89,7 @@ describe('DocketEntry entity', () => { eventCode: 'NOT', signedAt: null, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(myDoc.isDraft).toBe(false); @@ -99,7 +99,7 @@ describe('DocketEntry entity', () => { describe('isValid', () => { it('Creates a valid docket entry', () => { const myDoc = new DocketEntry(A_VALID_DOCKET_ENTRY, { - applicationContext, + authorizedUser: undefined, petitioners: MOCK_PETITIONERS, }); myDoc.docketEntryId = 'a6b81f4d-1e47-423a-8caf-6d2fdc3d3859'; @@ -112,7 +112,7 @@ describe('DocketEntry entity', () => { { userId: '02323349-87fe-4d29-91fe-8dd6916d2fda', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(myDoc.isValid()).toBeFalsy(); }); @@ -122,7 +122,7 @@ describe('DocketEntry entity', () => { { documentType: 'Petition', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(myDoc.isValid()).toBeFalsy(); }); @@ -132,7 +132,7 @@ describe('DocketEntry entity', () => { { serviceDate: 'undefined-undefined-undefined', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(myDoc.isValid()).toBeFalsy(); }); @@ -141,7 +141,7 @@ describe('DocketEntry entity', () => { describe('unsignDocument', () => { it('signs and unsigns the document', () => { const docketEntry = new DocketEntry(A_VALID_DOCKET_ENTRY, { - applicationContext, + authorizedUser: undefined, petitioners: MOCK_PETITIONERS, }); docketEntry.setSigned('abc-123', 'Joe Exotic'); @@ -174,7 +174,7 @@ describe('DocketEntry entity', () => { }, ], }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.isValid()).toEqual(true); @@ -191,7 +191,7 @@ describe('DocketEntry entity', () => { servedAt: undefined, servedParties: undefined, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.isValid()).toEqual(true); @@ -205,7 +205,7 @@ describe('DocketEntry entity', () => { servedAt: undefined, servedParties: undefined, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.getFormattedValidationErrors()).toEqual({ @@ -222,7 +222,7 @@ describe('DocketEntry entity', () => { scenario: 'Standard', secondaryDocument: {}, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.secondaryDocument).toBeUndefined(); expect(createdDocketEntry.isValid()).toEqual(true); @@ -234,7 +234,7 @@ describe('DocketEntry entity', () => { ...A_VALID_DOCKET_ENTRY, scenario: 'Standard', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); createdDocketEntry.secondaryDocument = { secondaryDocumentInfo: 'was set by accessor rather than init', @@ -252,7 +252,7 @@ describe('DocketEntry entity', () => { scenario: 'Standard', secondaryDocument: undefined, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.isValid()).toEqual(true); }); @@ -264,7 +264,7 @@ describe('DocketEntry entity', () => { scenario: 'Nonstandard H', secondaryDocument: undefined, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.isValid()).toEqual(true); @@ -281,7 +281,7 @@ describe('DocketEntry entity', () => { eventCode: 'P', }, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.isValid()).toEqual(true); }); @@ -293,7 +293,7 @@ describe('DocketEntry entity', () => { scenario: 'Nonstandard H', secondaryDocument: {}, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.isValid()).toEqual(false); expect( @@ -318,7 +318,7 @@ describe('DocketEntry entity', () => { }, ], }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.isValid()).toEqual(true); expect(createdDocketEntry.servedParties).toEqual([ @@ -343,7 +343,7 @@ describe('DocketEntry entity', () => { role: 'irsSuperuser', }, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(createdDocketEntry.isValid()).toEqual(false); expect(createdDocketEntry.getFormattedValidationErrors()).toEqual({ @@ -364,7 +364,7 @@ describe('DocketEntry entity', () => { isOnDocketRecord: true, userId: '02323349-87fe-4d29-91fe-8dd6916d2fda', }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isValid()).toBe(true); @@ -380,7 +380,7 @@ describe('DocketEntry entity', () => { ...A_VALID_DOCKET_ENTRY, judgeUserId: mockJudgeUserId, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry).toMatchObject({ @@ -395,7 +395,7 @@ describe('DocketEntry entity', () => { ...A_VALID_DOCKET_ENTRY, judgeUserId: undefined, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.judgeUserId).toBeUndefined(); expect(docketEntry.isValid()).toBeTruthy(); @@ -412,7 +412,7 @@ describe('DocketEntry entity', () => { isDraft: true, judgeUserId: mockJudgeUserId, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isValid()).toBeTruthy(); @@ -427,7 +427,7 @@ describe('DocketEntry entity', () => { isDraft: true, judgeUserId: mockJudgeUserId, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isValid()).toBeTruthy(); @@ -442,7 +442,7 @@ describe('DocketEntry entity', () => { isDraft: false, judgeUserId: mockJudgeUserId, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isValid()).toBeFalsy(); @@ -459,7 +459,7 @@ describe('DocketEntry entity', () => { isDraft: true, judgeUserId: mockJudgeUserId, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isValid()).toBeTruthy(); @@ -474,7 +474,7 @@ describe('DocketEntry entity', () => { isDraft: true, judgeUserId: mockJudgeUserId, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isValid()).toBeTruthy(); @@ -489,7 +489,7 @@ describe('DocketEntry entity', () => { isDraft: false, judgeUserId: mockJudgeUserId, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isValid()).toBeFalsy(); @@ -507,7 +507,7 @@ describe('DocketEntry entity', () => { isDraft: true, judgeUserId: mockJudgeUserId, }, - { applicationContext, petitioners: MOCK_PETITIONERS }, + { authorizedUser: undefined, petitioners: MOCK_PETITIONERS }, ); expect(docketEntry.isValid()).toBeTruthy(); }); diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index 498d69004c2..8102d16b8c3 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -34,12 +34,14 @@ import { import { DOCKET_ENTRY_VALIDATION_RULES } from './EntityValidationConstants'; import { JoiValidationEntity } from '@shared/business/entities/JoiValidationEntity'; import { RawUser, User } from './User'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from './WorkItem'; import { calculateISODate, createISODateAtStartOfDayEST, createISODateString, } from '../utilities/DateHandler'; +import { getUniqueId } from '@shared/sharedAppContext'; /* eslint-disable max-lines */ const canDownloadSTIN = ( @@ -161,24 +163,18 @@ export class DocketEntry extends JoiValidationEntity { constructor( rawDocketEntry, { - applicationContext, + authorizedUser, filtered = false, petitioners = [], }: { - applicationContext: IApplicationContext; + authorizedUser: UnknownAuthUser; petitioners?: any[]; filtered?: boolean; }, ) { super('DocketEntry'); - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } - if ( - !filtered || - User.isInternalUser(applicationContext.getCurrentUser().role) - ) { + if (!filtered || User.isInternalUser(authorizedUser?.role)) { this.initForUnfilteredForInternalUsers(rawDocketEntry); } @@ -192,8 +188,7 @@ export class DocketEntry extends JoiValidationEntity { this.certificateOfServiceDate = rawDocketEntry.certificateOfServiceDate; this.createdAt = rawDocketEntry.createdAt || createISODateString(); this.date = rawDocketEntry.date; - this.docketEntryId = - rawDocketEntry.docketEntryId || applicationContext.getUniqueId(); + this.docketEntryId = rawDocketEntry.docketEntryId || getUniqueId(); this.docketNumber = rawDocketEntry.docketNumber; this.docketNumbers = rawDocketEntry.docketNumbers; this.documentContentsId = rawDocketEntry.documentContentsId; @@ -245,7 +240,7 @@ export class DocketEntry extends JoiValidationEntity { this.supportingDocument = rawDocketEntry.supportingDocument; this.trialLocation = rawDocketEntry.trialLocation; // only share the userId with an external user if it is the logged in user - if (applicationContext.getCurrentUser().userId === rawDocketEntry.userId) { + if (authorizedUser?.userId === rawDocketEntry.userId) { this.userId = rawDocketEntry.userId; } diff --git a/shared/src/business/entities/DocketEntry.unsealEntry.test.ts b/shared/src/business/entities/DocketEntry.unsealEntry.test.ts index e88c1ba7a18..6d75f427148 100644 --- a/shared/src/business/entities/DocketEntry.unsealEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.unsealEntry.test.ts @@ -1,7 +1,6 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; import { DOCKET_ENTRY_SEALED_TO_TYPES } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('unsealEntry', () => { it('should clear the sealedTo property from the docket entry', () => { @@ -11,7 +10,7 @@ describe('unsealEntry', () => { sealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.EXTERNAL, }, { - applicationContext, + authorizedUser: undefined, }, ); docketEntry.unsealEntry(); @@ -22,7 +21,7 @@ describe('unsealEntry', () => { const docketEntry = new DocketEntry( { ...A_VALID_DOCKET_ENTRY, isSealed: undefined }, { - applicationContext, + authorizedUser: undefined, }, ); docketEntry.unsealEntry(); @@ -34,7 +33,7 @@ describe('unsealEntry', () => { const docketEntry = new DocketEntry( { ...A_VALID_DOCKET_ENTRY, isLegacySealed: true }, { - applicationContext, + authorizedUser: undefined, }, ); docketEntry.unsealEntry(); diff --git a/shared/src/business/entities/DocketEntry.unsignDocument.test.ts b/shared/src/business/entities/DocketEntry.unsignDocument.test.ts index 1d774a14eb2..ec5b2e0c013 100644 --- a/shared/src/business/entities/DocketEntry.unsignDocument.test.ts +++ b/shared/src/business/entities/DocketEntry.unsignDocument.test.ts @@ -1,11 +1,10 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('unsignDocument', () => { it('signs and unsigns the document', () => { const docketEntry = new DocketEntry(A_VALID_DOCKET_ENTRY, { - applicationContext, + authorizedUser: undefined, petitioners: [ { contactId: '7111b30b-ad38-42c8-9db0-d938cb2cb16b', diff --git a/shared/src/business/entities/DocketEntry.validate.test.ts b/shared/src/business/entities/DocketEntry.validate.test.ts index ef0a5631d08..70b5b5ed198 100644 --- a/shared/src/business/entities/DocketEntry.validate.test.ts +++ b/shared/src/business/entities/DocketEntry.validate.test.ts @@ -258,7 +258,7 @@ describe('validate', () => { const docketEntry = new DocketEntry( { ...A_VALID_DOCKET_ENTRY, ...item.docketEntry }, { - applicationContext, + authorizedUser: undefined, petitioners: MOCK_PETITIONERS, }, ).validate(); @@ -457,7 +457,7 @@ describe('validate', () => { const docketEntry = new DocketEntry( { ...A_VALID_DOCKET_ENTRY, ...item.docketEntry }, { - applicationContext, + authorizedUser: undefined, petitioners: MOCK_PETITIONERS, }, ); @@ -473,7 +473,7 @@ describe('validate', () => { it('should throw an error on invalid docket entries', () => { expect(() => { - new DocketEntry({}, { applicationContext }).validate(); + new DocketEntry({}, { authorizedUser: undefined }).validate(); }).toThrow('The DocketEntry entity was invalid'); }); }); diff --git a/shared/src/business/entities/User.ts b/shared/src/business/entities/User.ts index 04d4ae99767..91da0353c7a 100644 --- a/shared/src/business/entities/User.ts +++ b/shared/src/business/entities/User.ts @@ -176,7 +176,7 @@ export class User extends JoiValidationEntity { return externalRoles.includes(role); } - static isInternalUser(role: Role): boolean { + static isInternalUser(role?: Role): boolean { const internalRoles: Role[] = [ ROLES.adc, ROLES.admissionsClerk, diff --git a/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts b/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts index a0da852f6a7..68338703696 100644 --- a/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts +++ b/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts @@ -11,7 +11,7 @@ describe('archiveDocketEntry', () => { beforeEach(() => { docketEntryToArchive = new DocketEntry(cloneDeep(PENDING_DOCKET_ENTRY), { - applicationContext, + authorizedUser: undefined, }); docketEntryToArchive.servedAt = undefined; From 4797ae2435fba79bfb66fe6d47261d2c728d7129 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 16:32:37 -0700 Subject: [PATCH 062/523] 10417: WIP Transition DocketEntry away from appContext --- shared/src/business/entities/cases/Case.ts | 36 ++++++++++++++----- .../business/entities/cases/PaperPetition.ts | 5 ++- ...eneratePrintableFilingReceiptInteractor.ts | 2 +- .../useCases/saveSignedDocumentInteractor.ts | 4 +-- .../useCases/updateCaseDetailsInteractor.ts | 4 +-- .../useCases/updateContactInteractor.ts | 2 +- .../useCases/validateDocumentInteractor.ts | 2 +- .../addDocketEntryForSystemGeneratedOrder.ts | 2 +- .../createAndServeNoticeDocketEntry.ts | 2 +- .../fileAndServeDocumentOnOneCase.test.ts | 20 +++++------ .../updateInitialFilingDocuments.ts | 10 +++--- .../service/createChangeItems.ts | 2 +- ...addDraftStampOrderDocketEntryInteractor.ts | 2 +- .../serveGeneratedNoticesOnCase.test.ts | 2 +- .../createCaseFromPaperInteractor.test.ts | 32 +++++++++++------ .../useCases/createCaseFromPaperInteractor.ts | 12 +++---- 16 files changed, 86 insertions(+), 53 deletions(-) diff --git a/shared/src/business/entities/cases/Case.ts b/shared/src/business/entities/cases/Case.ts index c504f414a94..ea062761bb0 100644 --- a/shared/src/business/entities/cases/Case.ts +++ b/shared/src/business/entities/cases/Case.ts @@ -64,6 +64,7 @@ import { PrivatePractitioner } from '../PrivatePractitioner'; import { PublicCase } from '@shared/business/entities/cases/PublicCase'; import { Statistic } from '../Statistic'; import { TrialSession } from '../trialSessions/TrialSession'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { UnprocessableEntityError } from '../../../../../web-api/src/errors/errors'; import { User } from '../User'; import { clone, compact, includes, isEmpty, startCase } from 'lodash'; @@ -173,7 +174,12 @@ export class Case extends JoiValidationEntity { }); } - const params = { applicationContext, filtered, rawCase }; + const params = { + applicationContext, + authorizedUser: currentUser, + filtered, + rawCase, + }; // assignContacts needs to come first before assignDocketEntries this.assignConsolidatedCases({ rawCase }); @@ -318,7 +324,10 @@ export class Case extends JoiValidationEntity { this.orderForRatification = rawCase.orderForRatification || false; this.orderToShowCause = rawCase.orderToShowCause || false; - this.assignArchivedDocketEntries({ applicationContext, rawCase }); + this.assignArchivedDocketEntries({ + authorizedUser: applicationContext.getCurrentUser(), + rawCase, + }); this.assignStatistics({ applicationContext, rawCase }); this.assignCorrespondences({ rawCase }); } @@ -763,12 +772,18 @@ export class Case extends JoiValidationEntity { this.canAllowPrintableDocketRecord = rawCase.canAllowPrintableDocketRecord; } - assignArchivedDocketEntries({ applicationContext, rawCase }) { + private assignArchivedDocketEntries({ + authorizedUser, + rawCase, + }: { + authorizedUser: UnknownAuthUser; + rawCase: any; + }) { if (Array.isArray(rawCase.archivedDocketEntries)) { this.archivedDocketEntries = rawCase.archivedDocketEntries.map( docketEntry => new DocketEntry(docketEntry, { - applicationContext, + authorizedUser, petitioners: this.petitioners, }), ); @@ -777,13 +792,18 @@ export class Case extends JoiValidationEntity { } } - assignDocketEntries({ applicationContext, filtered, rawCase }) { + private assignDocketEntries({ + applicationContext, + authorizedUser, + filtered, + rawCase, + }) { if (Array.isArray(rawCase.docketEntries)) { this.docketEntries = rawCase.docketEntries .map( docketEntry => new DocketEntry(docketEntry, { - applicationContext, + authorizedUser, filtered, petitioners: this.petitioners, }), @@ -1135,7 +1155,7 @@ export class Case extends JoiValidationEntity { isOnDocketRecord: true, processingStatus: 'complete', }, - { applicationContext, petitioners: this.petitioners }, + { authorizedUser: user, petitioners: this.petitioners }, ); mincDocketEntry.setFiledBy(user); @@ -1185,7 +1205,7 @@ export class Case extends JoiValidationEntity { isOnDocketRecord: true, processingStatus: 'complete', }, - { applicationContext, petitioners: this.petitioners }, + { authorizedUser: user, petitioners: this.petitioners }, ); mindDocketEntry.setFiledBy(user); diff --git a/shared/src/business/entities/cases/PaperPetition.ts b/shared/src/business/entities/cases/PaperPetition.ts index fca876aa1a5..4de112fe843 100644 --- a/shared/src/business/entities/cases/PaperPetition.ts +++ b/shared/src/business/entities/cases/PaperPetition.ts @@ -123,7 +123,10 @@ export class PaperPetition extends JoiValidationEntity { this.archivedDocketEntries = Array.isArray(rawProps.archivedDocketEntries) ? rawProps.archivedDocketEntries.map( - doc => new DocketEntry(doc, { applicationContext }), + doc => + new DocketEntry(doc, { + authorizedUser: applicationContext.getCurrentUser(), + }), ) : []; diff --git a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts index 20e71e2000d..9c489620b5e 100644 --- a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts +++ b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts @@ -12,7 +12,7 @@ const getDocumentInfo = ({ petitioners?: any[]; }) => { const doc = new DocketEntry(documentData, { - applicationContext, + authorizedUser: applicationContext.getCurrentUser(), petitioners, }); diff --git a/shared/src/business/useCases/saveSignedDocumentInteractor.ts b/shared/src/business/useCases/saveSignedDocumentInteractor.ts index bc180cbd688..67d7f9fc98e 100644 --- a/shared/src/business/useCases/saveSignedDocumentInteractor.ts +++ b/shared/src/business/useCases/saveSignedDocumentInteractor.ts @@ -103,7 +103,7 @@ export const saveSignedDocumentInteractor = async ( isPaper: false, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { applicationContext }, + { authorizedUser: user }, ); signedDocketEntryEntity.setFiledBy(user); @@ -155,7 +155,7 @@ export const saveSignedDocumentInteractor = async ( isFileAttached: true, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { applicationContext }, + { authorizedUser: user }, ); signedDocketEntryEntity.setFiledBy(user); diff --git a/shared/src/business/useCases/updateCaseDetailsInteractor.ts b/shared/src/business/useCases/updateCaseDetailsInteractor.ts index 2a869e9b915..e13aa0a8eee 100644 --- a/shared/src/business/useCases/updateCaseDetailsInteractor.ts +++ b/shared/src/business/useCases/updateCaseDetailsInteractor.ts @@ -81,7 +81,7 @@ export const updateCaseDetails = async ( isOnDocketRecord: true, processingStatus: 'complete', }, - { applicationContext }, + { authorizedUser: user }, ); filingFeePaidEntry.setFiledBy(user); @@ -98,7 +98,7 @@ export const updateCaseDetails = async ( isOnDocketRecord: true, processingStatus: 'complete', }, - { applicationContext }, + { authorizedUser: user }, ); filingFeeWaivedEntry.setFiledBy(user); diff --git a/shared/src/business/useCases/updateContactInteractor.ts b/shared/src/business/useCases/updateContactInteractor.ts index f9adb0cd3a7..ec8d9b8f421 100644 --- a/shared/src/business/useCases/updateContactInteractor.ts +++ b/shared/src/business/useCases/updateContactInteractor.ts @@ -136,7 +136,7 @@ export const updateContact = async ( partyPrimary: true, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { applicationContext, petitioners: caseEntity.petitioners }, + { authorizedUser: user, petitioners: caseEntity.petitioners }, ); changeOfAddressDocketEntry.setFiledBy(user); diff --git a/shared/src/business/useCases/validateDocumentInteractor.ts b/shared/src/business/useCases/validateDocumentInteractor.ts index 38140753c2a..19bf5233e43 100644 --- a/shared/src/business/useCases/validateDocumentInteractor.ts +++ b/shared/src/business/useCases/validateDocumentInteractor.ts @@ -13,7 +13,7 @@ export const validateDocumentInteractor = ( { document }: { document: any }, ) => { const errors = new DocketEntry(document, { - applicationContext, + authorizedUser: applicationContext.getCurrentser(), }).getFormattedValidationErrors(); return errors || null; diff --git a/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.ts b/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.ts index 5b2cdafb858..db920022870 100644 --- a/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.ts +++ b/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.ts @@ -40,7 +40,7 @@ export const addDocketEntryForSystemGeneratedOrder = async ({ isDraft: true, isFileAttached: true, }, - { applicationContext }, + { authorizedUser: user }, ); newDocketEntry.setFiledBy(user); diff --git a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts index 95772a2790b..030b2415275 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts @@ -73,7 +73,7 @@ export const createAndServeNoticeDocketEntry = async ( : getServedPartiesCode(servedParties.all), ...additionalDocketEntryInfo, }, - { applicationContext }, + { authorizedUser: applicationContext.getCurrentUser() }, ); noticeDocketEntry.setFiledBy(user); diff --git a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts index 49a04474f36..f9e63fe9e8b 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts @@ -54,7 +54,7 @@ describe('fileAndServeDocumentOnOneCase', () => { workItemId: 'b4c7337f-9ca0-45d9-9396-75e003f81e32', }, }, - { applicationContext }, + { authorizedUser: undefined }, ); }); @@ -97,7 +97,7 @@ describe('fileAndServeDocumentOnOneCase', () => { signedJudgeName: judgeUser.name, workItem: mockWorkItem, }, - { applicationContext }, + { authorizedUser: undefined }, ); }); @@ -116,7 +116,7 @@ describe('fileAndServeDocumentOnOneCase', () => { signedJudgeName: judgeUser.name, workItem: undefined, }, - { applicationContext }, + { authorizedUser: undefined }, ); await fileAndServeDocumentOnOneCase({ @@ -132,7 +132,7 @@ describe('fileAndServeDocumentOnOneCase', () => { it('should not add a new docket entry when it already exists on the case', async () => { const docketEntryOnCase = new DocketEntry(mockCaseEntity.docketEntries[0], { - applicationContext, + authorizedUser: undefined, }); await fileAndServeDocumentOnOneCase({ @@ -161,7 +161,7 @@ describe('fileAndServeDocumentOnOneCase', () => { signedJudgeName: judgeUser.name, workItem: undefined, }, - { applicationContext }, + { authorizedUser: undefined }, ); await fileAndServeDocumentOnOneCase({ @@ -202,7 +202,7 @@ describe('fileAndServeDocumentOnOneCase', () => { signedJudgeName: judgeUser.name, workItem: mockWorkItem, }, - { applicationContext }, + { authorizedUser: undefined }, ); await fileAndServeDocumentOnOneCase({ @@ -310,7 +310,7 @@ describe('fileAndServeDocumentOnOneCase', () => { index: undefined, isOnDocketRecord: true, }, - { applicationContext }, + { authorizedUser: undefined }, ), subjectCaseDocketNumber: mockCaseEntity.docketNumber, user: docketClerkUser, @@ -403,7 +403,7 @@ describe('fileAndServeDocumentOnOneCase', () => { signedJudgeName: judgeUser.name, workItem: undefined, }, - { applicationContext }, + { authorizedUser: undefined }, ); await fileAndServeDocumentOnOneCase({ @@ -438,7 +438,7 @@ describe('fileAndServeDocumentOnOneCase', () => { signedByUserId: judgeUser.userId, signedJudgeName: judgeUser.name, }, - { applicationContext }, + { authorizedUser: undefined }, ); await fileAndServeDocumentOnOneCase({ @@ -491,7 +491,7 @@ describe('fileAndServeDocumentOnOneCase', () => { docketEntryId: mockDocketEntryId, pending: true, }, - { applicationContext }, + { authorizedUser: undefined }, ); applicationContext diff --git a/web-api/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.ts b/web-api/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.ts index 06bd22f6098..15dfbd15efe 100644 --- a/web-api/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.ts +++ b/web-api/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.ts @@ -6,7 +6,6 @@ import { import { omit } from 'lodash'; const addNewInitialFilingToCase = ({ - applicationContext, authorizedUser, caseEntity, currentCaseDocument, @@ -22,7 +21,7 @@ const addNewInitialFilingToCase = ({ ...currentCaseDocument, }, { - applicationContext, + authorizedUser, petitioners: caseEntity.petitioners, }, ); @@ -52,7 +51,7 @@ const addNewInitialFilingToCase = ({ receivedAt: caseEntity.receivedAt, }, { - applicationContext, + authorizedUser, petitioners: caseEntity.petitioners, }, ); @@ -120,9 +119,10 @@ export const updateInitialFilingDocuments = async ({ originalCaseDocument.docketEntryId !== currentCaseDocument.docketEntryId ) { addNewInitialFilingToCase({ - applicationContext, + authorizedUser, caseEntity, currentCaseDocument, + documentType, originalCaseDocument, }); await deleteInitialFilingFromCase({ @@ -133,11 +133,11 @@ export const updateInitialFilingDocuments = async ({ } } else if (!originalCaseDocument && currentCaseDocument) { addNewInitialFilingToCase({ - applicationContext, authorizedUser, caseEntity, currentCaseDocument, documentType, + originalCaseDocument, }); } else if (originalCaseDocument && !currentCaseDocument) { await deleteInitialFilingFromCase({ diff --git a/web-api/src/business/useCaseHelper/service/createChangeItems.ts b/web-api/src/business/useCaseHelper/service/createChangeItems.ts index 7c9552e0470..aeea3dc9f73 100644 --- a/web-api/src/business/useCaseHelper/service/createChangeItems.ts +++ b/web-api/src/business/useCaseHelper/service/createChangeItems.ts @@ -79,7 +79,7 @@ const createDocketEntryForChange = async ({ processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, ...docketMeta, }, - { applicationContext }, + { authorizedUser: applicationContext.getCurrentUser() }, ); changeOfAddressDocketEntry.setFiledBy(user); diff --git a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts index 34effbd6f52..66f63525a66 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts @@ -93,7 +93,7 @@ export const addDraftStampOrderDocketEntry = async ( processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, stampData: validatedStampData, }, - { applicationContext }, + { authorizedUser: user }, ); stampedDocketEntryEntity.setFiledBy(user); diff --git a/web-api/src/business/useCaseHelper/trialSessions/serveGeneratedNoticesOnCase.test.ts b/web-api/src/business/useCaseHelper/trialSessions/serveGeneratedNoticesOnCase.test.ts index 07d8e33c367..c1181620342 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/serveGeneratedNoticesOnCase.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/serveGeneratedNoticesOnCase.test.ts @@ -16,7 +16,7 @@ describe('serveGeneratedNoticesOnCase', () => { { ...MOCK_CASE.docketEntries[0], }, - { applicationContext }, + { authorizedUser: undefined }, ); it('should sendServedPartiesEmails and append the paper service info to the docket entry on the case when the case has parties with paper service', async () => { diff --git a/web-api/src/business/useCases/createCaseFromPaperInteractor.test.ts b/web-api/src/business/useCases/createCaseFromPaperInteractor.test.ts index aa75a280cfc..9f6f07b6c8a 100644 --- a/web-api/src/business/useCases/createCaseFromPaperInteractor.test.ts +++ b/web-api/src/business/useCases/createCaseFromPaperInteractor.test.ts @@ -10,10 +10,13 @@ import { ROLES, } from '../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; -import { User } from '../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { createCaseFromPaperInteractor } from './createCaseFromPaperInteractor'; import { createISODateString } from '@shared/business/utilities/DateHandler'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; jest.mock('@shared/business/utilities/DateHandler', () => { const originalModule = jest.requireActual( @@ -28,11 +31,7 @@ jest.mock('@shared/business/utilities/DateHandler', () => { describe('createCaseFromPaperInteractor', () => { const date = '2018-11-21T20:49:28.192Z'; - let user = new User({ - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + const mockCreateIsoDateString = createISODateString as jest.Mock; mockCreateIsoDateString.mockReturnValue(date); beforeEach(() => { @@ -40,7 +39,6 @@ describe('createCaseFromPaperInteractor', () => { '00101-00', ); applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockReturnValue(user); applicationContext .getUseCaseHelpers() @@ -65,13 +63,17 @@ describe('createCaseFromPaperInteractor', () => { name: 'john doe', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); + + applicationContext.getCurrentUser.mockReturnValue(mockPetitionsClerkUser); }); it('throws an error if the user is not valid or authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - createCaseFromPaperInteractor(applicationContext, {} as any), + createCaseFromPaperInteractor( + applicationContext, + {} as any, + mockPetitionerUser, + ), ).rejects.toThrow(new UnauthorizedError('Unauthorized')); }); @@ -120,10 +122,11 @@ describe('createCaseFromPaperInteractor', () => { }, requestForPlaceOfTrialFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', } as any, + mockPetitionsClerkUser, ); const expectedCaseStatus = { - changedBy: user.name, + changedBy: mockPetitionsClerkUser.name, date: createISODateString(), updatedCaseStatus: CASE_STATUS_TYPES.new, }; @@ -172,6 +175,7 @@ describe('createCaseFromPaperInteractor', () => { receivedAt: applicationContext.getUtilities().createISODateString(), }, } as any, + mockPetitionsClerkUser, ); const applicationForWaiverOfFilingFeeDocketEntry = @@ -235,6 +239,7 @@ describe('createCaseFromPaperInteractor', () => { receivedAt: applicationContext.getUtilities().createISODateString(), }, } as any, + mockPetitionsClerkUser, ); const corporateDisclosureDocketEntry = caseFromPaper.docketEntries.find( @@ -292,6 +297,7 @@ describe('createCaseFromPaperInteractor', () => { }, stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', } as any, + mockPetitionsClerkUser, ); const stinDocketEntry = caseFromPaper.docketEntries.find( @@ -352,6 +358,7 @@ describe('createCaseFromPaperInteractor', () => { }, requestForPlaceOfTrialFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', } as any, + mockPetitionsClerkUser, ); const rqtDocketEntry = caseFromPaper.docketEntries.find( @@ -408,6 +415,7 @@ describe('createCaseFromPaperInteractor', () => { receivedAt: applicationContext.getUtilities().createISODateString(), }, } as any, + mockPetitionsClerkUser, ); const atpDocketEntry = caseFromPaper.docketEntries.find( @@ -484,6 +492,7 @@ describe('createCaseFromPaperInteractor', () => { requestForPlaceOfTrialFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', } as any, + mockPetitionsClerkUser, ); expect(caseFromPaper).toBeDefined(); @@ -535,6 +544,7 @@ describe('createCaseFromPaperInteractor', () => { }, requestForPlaceOfTrialFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', } as any, + mockPetitionsClerkUser, ); const reqForPlaceOfTrialDocketEntry = caseFromPaper.docketEntries.find( diff --git a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts index b2d89135799..626ef02b810 100644 --- a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts +++ b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts @@ -140,7 +140,7 @@ export const createCaseFromPaperInteractor = async ( mailingDate: petitionEntity.mailingDate, receivedAt: caseToAdd.receivedAt, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); petitionDocketEntryEntity.setFiledBy(user); @@ -171,7 +171,7 @@ export const createCaseFromPaperInteractor = async ( mailingDate: petitionEntity.mailingDate, receivedAt: caseToAdd.receivedAt, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); applicationForWaiverOfFilingFeeDocketEntryEntity.setFiledBy(user); @@ -204,7 +204,7 @@ export const createCaseFromPaperInteractor = async ( mailingDate: petitionEntity.mailingDate, receivedAt: caseToAdd.receivedAt, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); requestForPlaceOfTrialDocketEntryEntity.setFiledBy(user); @@ -228,7 +228,7 @@ export const createCaseFromPaperInteractor = async ( mailingDate: petitionEntity.mailingDate, receivedAt: caseToAdd.receivedAt, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); stinDocketEntryEntity.setFiledBy(user); @@ -251,7 +251,7 @@ export const createCaseFromPaperInteractor = async ( mailingDate: petitionEntity.mailingDate, receivedAt: caseToAdd.receivedAt, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); cdsDocketEntryEntity.setFiledBy(user); @@ -275,7 +275,7 @@ export const createCaseFromPaperInteractor = async ( mailingDate: petitionEntity.mailingDate, receivedAt: caseToAdd.receivedAt, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); atpDocketEntryEntity.setFiledBy(user); From 6a43fdd7078654a017927ffeb0ee032d0b7ec965 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 2 Jul 2024 22:32:58 -0700 Subject: [PATCH 063/523] 10417: WIP Transition DocketEntry away from appContext --- .../fileAndServeCourtIssuedDocumentInteractor.ts | 2 +- .../serveCourtIssuedDocumentInteractor.ts | 2 +- .../courtIssuedOrder/fileCourtIssuedOrderInteractor.ts | 2 +- .../updateCourtIssuedOrderInteractor.ts | 2 +- .../useCases/docketEntry/addPaperFilingInteractor.ts | 2 +- ...eDocketEntryQCInteractor.needsNewCoversheet.test.ts | 4 ++-- .../docketEntry/completeDocketEntryQCInteractor.ts | 4 ++-- .../useCases/docketEntry/editPaperFilingInteractor.ts | 7 +++++-- .../fileCourtIssuedDocketEntryInteractor.ts | 2 +- .../updateCourtIssuedDocketEntryInteractor.ts | 2 +- ...ctor.shouldGenerateCoversheetForDocketEntry.test.ts | 3 +-- .../docketEntry/updateDocketEntryMetaInteractor.ts | 2 +- .../document/serveExternallyFiledDocumentInteractor.ts | 2 +- .../externalDocument/fileExternalDocumentInteractor.ts | 2 +- .../getPublicDownloadPolicyUrlInteractor.test.ts | 10 +++++----- .../serveCaseToIrs/serveCaseToIrsInteractor.ts | 9 ++++++--- ...rateNoticesForCaseTrialSessionCalendarInteractor.ts | 4 ++-- .../user/updatePetitionerInformationInteractor.test.ts | 2 +- web-client/integration-tests/v2ApiJourney.test.ts | 3 +-- 19 files changed, 35 insertions(+), 31 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts index ba9f27d5098..95ee0b24f93 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts @@ -170,7 +170,7 @@ export const fileAndServeCourtIssuedDocument = async ( serviceStamp: form.serviceStamp, trialLocation: form.trialLocation, }, - { applicationContext }, + { authorizedUser }, ); docketEntryEntity.setFiledBy(user); diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts index fc097e16250..24c847163e1 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts @@ -144,7 +144,7 @@ export const serveCourtIssuedDocument = async ( isOnDocketRecord: true, }, { - applicationContext, + authorizedUser, }, ); diff --git a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts index 2c89b57135a..544c278ecc4 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts @@ -113,7 +113,7 @@ export const fileCourtIssuedOrder = async ( isFileAttached: true, relationship: DOCUMENT_RELATIONSHIPS.PRIMARY, }, - { applicationContext }, + { authorizedUser }, ); docketEntryEntity.setFiledBy(user); diff --git a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts index 2f39fe87cdf..3c073ac03d2 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts @@ -114,7 +114,7 @@ export const updateCourtIssuedOrder = async ( numberOfPages, relationship: DOCUMENT_RELATIONSHIPS.PRIMARY, }, - { applicationContext }, + { authorizedUser }, ); docketEntryEntity.setFiledBy(user); diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts index 96fdf567165..4aff505b950 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts @@ -106,7 +106,7 @@ export const addPaperFiling = async ( mailingDate: documentMetadata.mailingDate, relationship: DOCUMENT_RELATIONSHIPS.PRIMARY, }, - { applicationContext, petitioners: caseEntity.petitioners }, + { authorizedUser, petitioners: caseEntity.petitioners }, ); docketEntryEntity.setFiledBy(user); diff --git a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.needsNewCoversheet.test.ts b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.needsNewCoversheet.test.ts index f656e387889..e2ff44d58ef 100644 --- a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.needsNewCoversheet.test.ts +++ b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.needsNewCoversheet.test.ts @@ -13,7 +13,7 @@ describe('completeDocketEntryQCInteractor needsNewCoversheet', () => { filedBy: 'petitioner.high', receivedAt: '2019-08-25T05:00:00.000Z', }, - { applicationContext }, + { authorizedUser: undefined }, ); updatedDocketEntry = new DocketEntry( @@ -23,7 +23,7 @@ describe('completeDocketEntryQCInteractor needsNewCoversheet', () => { filedBy: 'petitioner.high', receivedAt: '2019-08-25T05:00:00.000Z', }, - { applicationContext }, + { authorizedUser: undefined }, ); }); it('should return true when receivedAt is updated', () => { diff --git a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts index e80f7395e61..5af74de9f72 100644 --- a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts @@ -147,7 +147,7 @@ const completeDocketEntryQC = async ( trialLocation: caseEntity.trialLocation, }, }, - { applicationContext, petitioners: caseToUpdate.petitioners }, + { authorizedUser, petitioners: caseToUpdate.petitioners }, ).validate(); updatedDocketEntry.setQCed(user); @@ -314,7 +314,7 @@ const completeDocketEntryQC = async ( isOnDocketRecord: true, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { applicationContext, petitioners: caseToUpdate.petitioners }, + { authorizedUser, petitioners: caseToUpdate.petitioners }, ); noticeUpdatedDocketEntry.setFiledBy(user); diff --git a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts index 349721d5279..4a188c045c8 100644 --- a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts @@ -267,7 +267,7 @@ const serveDocketEntry = async ({ applicationContext, caseEntity: aCase, docketEntryEntity: new DocketEntry(cloneDeep(updatedDocketEntry), { - applicationContext, + authorizedUser: applicationContext.getCurrentUser(), }), subjectCaseDocketNumber: subjectCaseEntity.docketNumber, user, @@ -427,7 +427,10 @@ const updateDocketEntry = async ({ relationship: DOCUMENT_RELATIONSHIPS.PRIMARY, userId, }, - { applicationContext, petitioners: caseEntity.petitioners }, + { + authorizedUser: applicationContext.getCurrentUser(), + petitioners: caseEntity.petitioners, + }, ); if (editableFields.isFileAttached) { diff --git a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts index bc77aa43e3e..83cbbf4bae8 100644 --- a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts @@ -108,7 +108,7 @@ export const fileCourtIssuedDocketEntry = async ( serviceStamp: documentMeta.serviceStamp, trialLocation: documentMeta.trialLocation, }, - { applicationContext }, + { authorizedUser }, ); docketEntryEntity.setFiledBy(user); diff --git a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts index 942ef654892..0983d77f9a6 100644 --- a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts @@ -74,7 +74,7 @@ export const updateCourtIssuedDocketEntry = async ( editState: JSON.stringify(editableFields), isOnDocketRecord: true, }, - { applicationContext }, + { authorizedUser }, ); docketEntryEntity.setFiledBy(user); diff --git a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.shouldGenerateCoversheetForDocketEntry.test.ts b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.shouldGenerateCoversheetForDocketEntry.test.ts index 2830600ceda..ce3a2233360 100644 --- a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.shouldGenerateCoversheetForDocketEntry.test.ts +++ b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.shouldGenerateCoversheetForDocketEntry.test.ts @@ -1,5 +1,4 @@ import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; -import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { shouldGenerateCoversheetForDocketEntry } from './updateDocketEntryMetaInteractor'; describe('updateDocketEntryMetaInteractor shouldGenerateCoversheetForDocketEntry', () => { @@ -14,7 +13,7 @@ describe('updateDocketEntryMetaInteractor shouldGenerateCoversheetForDocketEntry judge: 'Buch', userId: '38c36925-c936-44c5-b219-e13039f7d235', }, - { applicationContext }, + { authorizedUser: undefined }, ); let entryRequiresCoverSheet = false; diff --git a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts index fa633c8222e..f5c266cd1d8 100644 --- a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts @@ -147,7 +147,7 @@ export const updateDocketEntryMeta = async ( ...originalDocketEntry, ...editableFields, }, - { applicationContext, petitioners: caseEntity.petitioners }, + { authorizedUser: user, petitioners: caseEntity.petitioners }, ).validate(); caseEntity.updateDocketEntry(docketEntryEntity); diff --git a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts index e7fc047e30f..e78051a7bad 100644 --- a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts +++ b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts @@ -151,7 +151,7 @@ export const serveExternallyFiledDocument = async ( numberOfPages: numberOfPages + coversheetLength, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { applicationContext }, + { authorizedUser }, ); return applicationContext diff --git a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts index 61fa4b7e9eb..ca085244e59 100644 --- a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts +++ b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts @@ -148,7 +148,7 @@ export const fileExternalDocument = async ( relationship, }, { - applicationContext, + authorizedUser, petitioners: currentCaseEntity.petitioners, }, ); diff --git a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts index c6944a213e9..19ba155d84f 100644 --- a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts +++ b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts @@ -91,7 +91,7 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { isOnDocketRecord: true, servedAt: '2019-03-01T21:40:46.415Z', }, - { applicationContext }, + { authorizedUser: undefined }, ), ); await expect( @@ -122,7 +122,7 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, servedAt: '2019-03-01T21:40:46.415Z', }, - { applicationContext }, + { authorizedUser: undefined }, ), ); const result = await getPublicDownloadPolicyUrlInteractor( @@ -148,7 +148,7 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, servedAt: '2019-03-01T21:40:46.415Z', }, - { applicationContext }, + { authorizedUser: undefined }, ), ); @@ -185,7 +185,7 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { eventCode: 'RQT', isFileAttached: false, }, - { applicationContext }, + { authorizedUser: undefined }, ), ); @@ -214,7 +214,7 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { isSealed: true, sealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, }, - { applicationContext }, + { authorizedUser: undefined }, ), ); diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts index b2ba4cfa781..afb48077f21 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts @@ -45,7 +45,7 @@ export const addDocketEntryForPaymentStatus = ({ isOnDocketRecord: true, processingStatus: 'complete', }, - { applicationContext }, + { authorizedUser: applicationContext.getCurrentUser() }, ); paymentStatusDocketEntry.setFiledBy(user); @@ -62,7 +62,7 @@ export const addDocketEntryForPaymentStatus = ({ isOnDocketRecord: true, processingStatus: 'complete', }, - { applicationContext }, + { authorizedUser: applicationContext.getCurrentUser() }, ); petitionPaymentStatusDocketEntry.setFiledBy(user); @@ -336,7 +336,10 @@ const generateNoticeOfReceipt = async ({ isFileAttached: true, isOnDocketRecord: true, }, - { applicationContext, petitioners: caseEntity.petitioners }, + { + authorizedUser: applicationContext.getCurrentUser, + petitioners: caseEntity.petitioners, + }, ); notrDocketEntry.setFiledBy(userServingPetition); diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index 3dd9dab755d..e34211ed9b1 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -199,7 +199,7 @@ const setNoticeForCase = async ({ signedAt: applicationContext.getUtilities().createISODateString(), // The signature is in the template of the document being generated trialLocation: trialSessionEntity.trialLocation, }, - { applicationContext }, + { authorizedUser: applicationContext.getCurrentUser() }, ); noticeOfTrialDocketEntry.setFiledBy(user); @@ -267,7 +267,7 @@ const setNoticeForCase = async ({ judge: trialSessionEntity.judge.name, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { applicationContext }, + { authorizedUser: applicationContext.getCurrentUser() }, ); standingPretrialDocketEntry.setFiledBy(user); diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts index 8761eca7b04..dac48e49409 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts @@ -646,7 +646,7 @@ describe('updatePetitionerInformationInteractor', () => { receivedAt: '2018-03-01T05:00:00.000Z', userId: '7805d1ab-18d0-43ec-bafb-654e83405416', }, - { applicationContext }, + { authorizedUser: undefined }, ), }); diff --git a/web-client/integration-tests/v2ApiJourney.test.ts b/web-client/integration-tests/v2ApiJourney.test.ts index 34bff835698..1b4949e5787 100644 --- a/web-client/integration-tests/v2ApiJourney.test.ts +++ b/web-client/integration-tests/v2ApiJourney.test.ts @@ -5,7 +5,6 @@ import { USTC_TZ, } from '../../shared/src/business/utilities/DateHandler'; import { PARTIES_CODES } from '../../shared/src/business/entities/EntityConstants'; -import { applicationContext } from '../../shared/src/business/test/createTestApplicationContext'; import { loginAs, setupTest } from './helpers'; import { petitionsClerkCreatesNewCase } from './journey/petitionsClerkCreatesNewCase'; import { seedEntries } from '../../web-api/storage/fixtures/seed'; @@ -201,7 +200,7 @@ describe('View and manage the deadlines of a case', () => { const docketEntries = new Array(); for (const item of seedEntries) { if (item.entityName === 'DocketEntry') { - const de = new DocketEntry(item, { applicationContext }); + const de = new DocketEntry(item, { authorizedUser: undefined }); if ( [PARTIES_CODES.BOTH, PARTIES_CODES.RESPONDENT].includes( de.servedPartiesCode ?? '', From 2c01a94c6885aa4dfd1c9a592449bba6e4d9588e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 3 Jul 2024 08:07:08 -0700 Subject: [PATCH 064/523] 10417: Transition DocketEntry away from appContext --- web-api/src/business/useCases/createCaseInteractor.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web-api/src/business/useCases/createCaseInteractor.ts b/web-api/src/business/useCases/createCaseInteractor.ts index ca2281ce839..6368805b671 100644 --- a/web-api/src/business/useCases/createCaseInteractor.ts +++ b/web-api/src/business/useCases/createCaseInteractor.ts @@ -175,7 +175,7 @@ export const createCaseInteractor = async ( isOnDocketRecord: true, privatePractitioners, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); petitionDocketEntryEntity.setFiledBy(user); @@ -197,7 +197,7 @@ export const createCaseInteractor = async ( processingStatus: 'complete', }, { - applicationContext, + authorizedUser, petitioners: caseToAdd.petitioners, }, ); @@ -220,7 +220,7 @@ export const createCaseInteractor = async ( isFileAttached: true, privatePractitioners, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); stinDocketEntryEntity.setFiledBy(user); @@ -242,7 +242,7 @@ export const createCaseInteractor = async ( isOnDocketRecord: true, privatePractitioners, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); cdsDocketEntryEntity.setFiledBy(user); @@ -265,7 +265,7 @@ export const createCaseInteractor = async ( isOnDocketRecord: true, privatePractitioners, }, - { applicationContext, petitioners: caseToAdd.petitioners }, + { authorizedUser, petitioners: caseToAdd.petitioners }, ); atpDocketEntryEntity.setFiledBy(user); From 14a4d13e23230430f55d203e9cbbdf7b0efe7958 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 3 Jul 2024 09:22:30 -0700 Subject: [PATCH 065/523] 10417: WIP Transition Statistic, Penalty, ContactFactory, Contact, PaperPetition, ElectronicPetition, Petitioner away from appContext --- shared/src/business/entities/Penalty.test.ts | 119 ++--- shared/src/business/entities/Penalty.ts | 9 +- .../src/business/entities/Statistic.test.ts | 384 +++++++-------- shared/src/business/entities/Statistic.ts | 27 +- .../entities/cases/Case.addPetitioner.test.ts | 27 +- .../entities/cases/Case.addStatistic.test.ts | 38 +- .../cases/Case.updateStatistic.test.ts | 42 +- .../entities/cases/ElectronicPetition.test.ts | 423 +++++++--------- .../entities/cases/ElectronicPetition.ts | 3 +- ...onicPetitionForCorporationContacts.test.ts | 132 +++-- ...onForEstateWithoutExecutorContacts.test.ts | 136 +++--- ...icPetitionForInternationalContacts.test.ts | 117 +++-- ...ionForMinorWithoutGuardianContacts.test.ts | 85 ++-- ...rtnershipTaxMattersPartnerContacts.test.ts | 85 ++-- ...etitionerAndDeceasedSpouseContacts.test.ts | 101 ++-- ...tionForPetitionerAndSpouseContacts.test.ts | 103 ++-- ...ectronicPetitionInformationFactory.test.ts | 456 +++++++----------- .../ElectronicPetitionInformationFactory.ts | 3 +- .../business/entities/cases/PaperPetition.ts | 5 +- .../entities/contacts/Contact.test.ts | 3 - .../src/business/entities/contacts/Contact.ts | 12 +- .../entities/contacts/ContactFactory.test.ts | 314 +++++------- .../entities/contacts/ContactFactory.ts | 146 +++--- .../NextFriendForIncompetentPersonContact.ts | 9 +- .../contacts/NextFriendForMinorContact.ts | 9 +- .../PartnershipAsTaxMattersPartnerContact.ts | 9 +- .../contacts/PartnershipBBAContact.ts | 9 +- .../PartnershipOtherThanTaxMattersContact.ts | 9 +- .../entities/contacts/Petitioner.test.ts | 88 ++-- .../business/entities/contacts/Petitioner.ts | 12 +- .../contacts/PetitionerConservatorContact.ts | 9 +- .../contacts/PetitionerCorporationContact.ts | 9 +- .../contacts/PetitionerCustodianContact.ts | 9 +- .../PetitionerDeceasedSpouseContact.ts | 9 +- ...itionerEstateWithExecutorPrimaryContact.ts | 9 +- .../contacts/PetitionerGuardianContact.ts | 9 +- .../contacts/PetitionerIntermediaryContact.ts | 9 +- .../contacts/PetitionerPrimaryContact.test.ts | 29 +- .../contacts/PetitionerPrimaryContact.ts | 9 +- .../contacts/PetitionerSpouseContact.ts | 9 +- .../contacts/PetitionerTrustContact.ts | 9 +- .../contacts/SurvivingSpouseContact.ts | 9 +- .../validateStartCaseWizardInteractor.ts | 6 +- ...lidateAddDeficiencyStatisticsInteractor.ts | 4 +- .../validateAddPetitionerInteractor.ts | 6 +- .../useCases/validatePenaltiesInteractor.ts | 4 +- .../useCases/validatePetitionInteractor.ts | 4 +- ...datePetitionerInformationFormInteractor.ts | 1 - .../useCases/validatePetitionerInteractor.ts | 6 +- .../useCases/addPetitionerToCaseInteractor.ts | 4 +- .../addDeficiencyStatisticInteractor.ts | 23 +- .../updateDeficiencyStatisticInteractor.ts | 25 +- .../business/useCases/createCaseInteractor.ts | 4 +- 53 files changed, 1287 insertions(+), 1843 deletions(-) diff --git a/shared/src/business/entities/Penalty.test.ts b/shared/src/business/entities/Penalty.test.ts index 7a9854e4b3d..88784baa823 100644 --- a/shared/src/business/entities/Penalty.test.ts +++ b/shared/src/business/entities/Penalty.test.ts @@ -1,20 +1,16 @@ import { PENALTY_TYPES } from './EntityConstants'; import { Penalty } from './Penalty'; -import { applicationContext } from '../test/createTestApplicationContext'; describe('Penalty', () => { describe('validation', () => { let mockStatisticId = '5666ad04-4814-4b0c-8090-ba01683917ac'; it('should fail if name is undefined', () => { - const penalty = new Penalty( - { - irsPenaltyAmount: 100.0, - name: undefined, - statisticId: mockStatisticId, - }, - { applicationContext }, - ); + const penalty = new Penalty({ + irsPenaltyAmount: 100.0, + name: undefined, + statisticId: mockStatisticId, + }); expect(penalty.isValid()).toBeFalsy(); expect(Object.keys(penalty.getFormattedValidationErrors()!)).toContain( @@ -23,15 +19,12 @@ describe('Penalty', () => { }); it('should fail if penaltyAmount is undefined', () => { - const penalty = new Penalty( - { - name: 'Penalty 1 (IRS)', - penaltyAmount: undefined, - penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, - statisticId: mockStatisticId, - }, - { applicationContext }, - ); + const penalty = new Penalty({ + name: 'Penalty 1 (IRS)', + penaltyAmount: undefined, + penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, + statisticId: mockStatisticId, + }); expect(penalty.isValid()).toBe(false); expect(Object.keys(penalty.getFormattedValidationErrors()!)).toContain( @@ -40,15 +33,12 @@ describe('Penalty', () => { }); it('should fail if penaltyAmount is not a number', () => { - const penalty = new Penalty( - { - name: 'Penalty 1 (IRS)', - penaltyAmount: 'something', - penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, - statisticId: mockStatisticId, - }, - { applicationContext }, - ); + const penalty = new Penalty({ + name: 'Penalty 1 (IRS)', + penaltyAmount: 'something', + penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, + statisticId: mockStatisticId, + }); expect(penalty.isValid()).toBe(false); expect(Object.keys(penalty.getFormattedValidationErrors()!)).toContain( @@ -57,15 +47,12 @@ describe('Penalty', () => { }); it('should fail if penaltyType is undefined', () => { - const penalty = new Penalty( - { - name: 'Penalty 1 (IRS)', - penaltyAmount: 100.0, - penaltyType: undefined, - statisticId: mockStatisticId, - }, - { applicationContext }, - ); + const penalty = new Penalty({ + name: 'Penalty 1 (IRS)', + penaltyAmount: 100.0, + penaltyType: undefined, + statisticId: mockStatisticId, + }); expect(penalty.isValid()).toBe(false); expect(Object.keys(penalty.getFormattedValidationErrors()!)).toContain( @@ -74,15 +61,12 @@ describe('Penalty', () => { }); it('should fail with statisticId undefined', () => { - const penalty = new Penalty( - { - name: 'Penalty 1 (IRS)', - penaltyAmount: 100.0, - penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, - statisticId: undefined, - }, - { applicationContext }, - ); + const penalty = new Penalty({ + name: 'Penalty 1 (IRS)', + penaltyAmount: 100.0, + penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, + statisticId: undefined, + }); expect(penalty.isValid()).toBe(false); expect(Object.keys(penalty.getFormattedValidationErrors()!)).toContain( @@ -91,43 +75,34 @@ describe('Penalty', () => { }); it('should pass with valid values and irsPenaltyAmount type', () => { - const penalty = new Penalty( - { - name: 'Penalty 1 (IRS)', - penaltyAmount: 100.0, - penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, - statisticId: mockStatisticId, - }, - { applicationContext }, - ); + const penalty = new Penalty({ + name: 'Penalty 1 (IRS)', + penaltyAmount: 100.0, + penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, + statisticId: mockStatisticId, + }); expect(penalty.isValid()).toBe(true); }); it('should pass with valid values and determinationPenaltyAmount type', () => { - const penalty = new Penalty( - { - name: 'Penalty 1 (Court)', - penaltyAmount: 100.0, - penaltyType: PENALTY_TYPES.DETERMINATION_PENALTY_AMOUNT, - statisticId: mockStatisticId, - }, - { applicationContext }, - ); + const penalty = new Penalty({ + name: 'Penalty 1 (Court)', + penaltyAmount: 100.0, + penaltyType: PENALTY_TYPES.DETERMINATION_PENALTY_AMOUNT, + statisticId: mockStatisticId, + }); expect(penalty.isValid()).toBe(true); }); it('should pass if penaltyAmount is a negative number', () => { - const penalty = new Penalty( - { - name: 'Penalty 1 (IRS)', - penaltyAmount: -422.68, - penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, - statisticId: mockStatisticId, - }, - { applicationContext }, - ); + const penalty = new Penalty({ + name: 'Penalty 1 (IRS)', + penaltyAmount: -422.68, + penaltyType: PENALTY_TYPES.IRS_PENALTY_AMOUNT, + statisticId: mockStatisticId, + }); expect(penalty.isValid()).toBe(true); }); diff --git a/shared/src/business/entities/Penalty.ts b/shared/src/business/entities/Penalty.ts index 43574275a3f..e6b0262ee26 100644 --- a/shared/src/business/entities/Penalty.ts +++ b/shared/src/business/entities/Penalty.ts @@ -1,6 +1,7 @@ import { JoiValidationConstants } from './JoiValidationConstants'; import { JoiValidationEntity } from '@shared/business/entities/JoiValidationEntity'; import { PENALTY_TYPES } from './EntityConstants'; +import { getUniqueId } from '@shared/sharedAppContext'; import joi from 'joi'; export class Penalty extends JoiValidationEntity { @@ -10,17 +11,13 @@ export class Penalty extends JoiValidationEntity { public penaltyType: string; public statisticId: string; - constructor(rawProps, { applicationContext }) { + constructor(rawProps) { super('Penalty'); - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } - this.name = rawProps.name; this.penaltyType = rawProps.penaltyType; this.penaltyAmount = rawProps.penaltyAmount; - this.penaltyId = rawProps.penaltyId || applicationContext.getUniqueId(); + this.penaltyId = rawProps.penaltyId || getUniqueId(); this.statisticId = rawProps.statisticId; } diff --git a/shared/src/business/entities/Statistic.test.ts b/shared/src/business/entities/Statistic.test.ts index ab9cf9da900..a5eef767595 100644 --- a/shared/src/business/entities/Statistic.test.ts +++ b/shared/src/business/entities/Statistic.test.ts @@ -1,22 +1,13 @@ import { Statistic } from './Statistic'; -import { applicationContext } from '../test/createTestApplicationContext'; +import { getUniqueId } from '@shared/sharedAppContext'; describe('Statistic', () => { - it('throws an error if applicationContext is not provided on construction', () => { - expect(() => new Statistic({}, {} as any)).toThrow( - 'applicationContext must be defined', - ); - }); - describe('validation', () => { it("fails validation if a yearOrPeriod is not 'year' or 'period'", () => { - const statistic = new Statistic( - { - penalties: [{ irsPenaltyAmount: 100.0, name: 'Penalty1' }], - yearOrPeriod: 'something else', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + penalties: [{ irsPenaltyAmount: 100.0, name: 'Penalty1' }], + yearOrPeriod: 'something else', + }); expect(statistic.isValid()).toBeFalsy(); expect(Object.keys(statistic.getFormattedValidationErrors()!)).toContain( @@ -25,43 +16,37 @@ describe('Statistic', () => { }); it('passes validation with minimal required information', () => { - const statistic = new Statistic( - { - irsDeficiencyAmount: 1, - irsTotalPenalties: 1, - penalties: [ - { - name: 'Penalty 1(IRS)', - penaltyAmount: 100.0, - penaltyType: 'irsPenaltyAmount', - }, - ], - year: '2001', - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + penalties: [ + { + name: 'Penalty 1(IRS)', + penaltyAmount: 100.0, + penaltyType: 'irsPenaltyAmount', + }, + ], + year: '2001', + yearOrPeriod: 'Year', + }); expect(statistic.isValid()).toBeTruthy(); }); it('fails validation if a irsDeficiencyAmount, irsTotalPenalties, or year are not numbers', () => { - const statistic = new Statistic( - { - irsDeficiencyAmount: 'something else', - irsTotalPenalties: 'something else', - penalties: [ - { - name: 'Penalty 1(IRS)', - penaltyAmount: 100.0, - penaltyType: 'irsPenaltyAmount', - }, - ], - year: 'something else', - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + irsDeficiencyAmount: 'something else', + irsTotalPenalties: 'something else', + penalties: [ + { + name: 'Penalty 1(IRS)', + penaltyAmount: 100.0, + penaltyType: 'irsPenaltyAmount', + }, + ], + year: 'something else', + yearOrPeriod: 'Year', + }); expect(statistic.isValid()).toBeFalsy(); expect(Object.keys(statistic.getFormattedValidationErrors()!)).toEqual([ @@ -72,22 +57,19 @@ describe('Statistic', () => { }); it('should be invalid when one of the penalties in the statistic is NOT valid', () => { - const statistic = new Statistic( - { - irsDeficiencyAmount: 1, - irsTotalPenalties: 1, - penalties: [ - { - name: 'Penalty 1(IRS)', - penaltyAmount: undefined, // This is a required field - penaltyType: 'irsPenaltyAmount', - }, - ], - year: '2001', - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + penalties: [ + { + name: 'Penalty 1(IRS)', + penaltyAmount: undefined, // This is a required field + penaltyType: 'irsPenaltyAmount', + }, + ], + year: '2001', + yearOrPeriod: 'Year', + }); expect(statistic.getFormattedValidationErrors()!).toEqual({ penalties: [ @@ -100,22 +82,19 @@ describe('Statistic', () => { }); it('should be invalid when one of the penalties in the statistic is NOT valid', () => { - const statistic = new Statistic( - { - irsDeficiencyAmount: 1, - irsTotalPenalties: 1, - penalties: [ - { - name: 'Penalty 1(IRS)', - penaltyAmount: undefined, // This is a required field - penaltyType: 'irsPenaltyAmount', - }, - ], - year: '2001', - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + penalties: [ + { + name: 'Penalty 1(IRS)', + penaltyAmount: undefined, // This is a required field + penaltyType: 'irsPenaltyAmount', + }, + ], + year: '2001', + yearOrPeriod: 'Year', + }); expect(statistic.getFormattedValidationErrors()!).toEqual({ penalties: [ @@ -128,16 +107,13 @@ describe('Statistic', () => { }); it('fails validation if a lastDateOfPeriod is a date in the future', () => { - const statistic = new Statistic( - { - irsDeficiencyAmount: 1, - irsTotalPenalties: 1, - lastDateOfPeriod: '2050-03-01T21:40:46.415Z', - penalties: [{ irsPenaltyAmount: 100.0, name: 'Penalty1' }], - yearOrPeriod: 'Period', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + lastDateOfPeriod: '2050-03-01T21:40:46.415Z', + penalties: [{ irsPenaltyAmount: 100.0, name: 'Penalty1' }], + yearOrPeriod: 'Period', + }); expect(statistic.isValid()).toBeFalsy(); expect(statistic.getFormattedValidationErrors()).toMatchObject({ @@ -146,22 +122,19 @@ describe('Statistic', () => { }); it('fails validation if a year is in the future', () => { - const statistic = new Statistic( - { - irsDeficiencyAmount: 1, - irsTotalPenalties: 1, - penalties: [ - { - name: 'Penalty 1(IRS)', - penaltyAmount: 100.0, - penaltyType: 'irsPenaltyAmount', - }, - ], - year: 2050, - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + penalties: [ + { + name: 'Penalty 1(IRS)', + penaltyAmount: 100.0, + penaltyType: 'irsPenaltyAmount', + }, + ], + year: 2050, + yearOrPeriod: 'Year', + }); expect(statistic.isValid()).toBeFalsy(); expect(Object.keys(statistic.getFormattedValidationErrors()!)).toEqual([ @@ -170,69 +143,60 @@ describe('Statistic', () => { }); it('passes validation with valid values', () => { - const statistic = new Statistic( - { - irsDeficiencyAmount: 654.32, - irsTotalPenalties: 123.45, - lastDateOfPeriod: '2015-03-01T21:40:46.415Z', - penalties: [ - { - name: 'Penalty 1(IRS)', - penaltyAmount: 100.0, - penaltyType: 'irsPenaltyAmount', - }, - ], - year: 2015, - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + irsDeficiencyAmount: 654.32, + irsTotalPenalties: 123.45, + lastDateOfPeriod: '2015-03-01T21:40:46.415Z', + penalties: [ + { + name: 'Penalty 1(IRS)', + penaltyAmount: 100.0, + penaltyType: 'irsPenaltyAmount', + }, + ], + year: 2015, + yearOrPeriod: 'Year', + }); expect(statistic.isValid()).toBeTruthy(); }); it('passes validation if an irsDeficiencyAmount, irsTotalPenalties, determinationTotalPenalties, and/or determinationDeficiencyAmount include negative numbers', () => { - const statistic = new Statistic( - { - determinationDeficiencyAmount: -4352.32, - determinationTotalPenalties: 0, - irsDeficiencyAmount: -2.0, - irsTotalPenalties: -222.22, - penalties: [ - { - name: 'Penalty 1(IRS)', - penaltyAmount: -222.22, - penaltyType: 'irsPenaltyAmount', - }, - ], - year: 2015, - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + determinationDeficiencyAmount: -4352.32, + determinationTotalPenalties: 0, + irsDeficiencyAmount: -2.0, + irsTotalPenalties: -222.22, + penalties: [ + { + name: 'Penalty 1(IRS)', + penaltyAmount: -222.22, + penaltyType: 'irsPenaltyAmount', + }, + ], + year: 2015, + yearOrPeriod: 'Year', + }); expect(statistic.isValid()).toBeTruthy(); }); it('requires determinationDeficiencyAmount be defined if determinationTotalPenalties is set', () => { - const statistic = new Statistic( - { - determinationTotalPenalties: 100.11, - irsDeficiencyAmount: 654.32, - irsTotalPenalties: 123.45, - lastDateOfPeriod: '2015-03-01T21:40:46.415Z', - penalties: [ - { - name: 'Penalty 1(IRS)', - penaltyAmount: 100.0, - penaltyType: 'irsPenaltyAmount', - }, - ], - year: 2015, - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + determinationTotalPenalties: 100.11, + irsDeficiencyAmount: 654.32, + irsTotalPenalties: 123.45, + lastDateOfPeriod: '2015-03-01T21:40:46.415Z', + penalties: [ + { + name: 'Penalty 1(IRS)', + penaltyAmount: 100.0, + penaltyType: 'irsPenaltyAmount', + }, + ], + year: 2015, + yearOrPeriod: 'Year', + }); expect(statistic.isValid()).toBeFalsy(); expect(Object.keys(statistic.getFormattedValidationErrors()!)).toEqual([ @@ -241,24 +205,21 @@ describe('Statistic', () => { }); it('requires determinationTotalPenalties be defined if determinationDeficiencyAmount is set', () => { - const statistic = new Statistic( - { - determinationDeficiencyAmount: 100.11, - irsDeficiencyAmount: 654.32, - irsTotalPenalties: 123.45, - lastDateOfPeriod: '2015-03-01T21:40:46.415Z', - penalties: [ - { - name: 'Penalty 1(IRS)', - penaltyAmount: 100.0, - penaltyType: 'irsPenaltyAmount', - }, - ], - year: 2015, - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statistic = new Statistic({ + determinationDeficiencyAmount: 100.11, + irsDeficiencyAmount: 654.32, + irsTotalPenalties: 123.45, + lastDateOfPeriod: '2015-03-01T21:40:46.415Z', + penalties: [ + { + name: 'Penalty 1(IRS)', + penaltyAmount: 100.0, + penaltyType: 'irsPenaltyAmount', + }, + ], + year: 2015, + yearOrPeriod: 'Year', + }); expect(statistic.isValid()).toBeFalsy(); expect(Object.keys(statistic.getFormattedValidationErrors()!)).toEqual([ @@ -269,7 +230,7 @@ describe('Statistic', () => { describe('Penalties', () => { let statistic; - let statisticId = applicationContext.getUniqueId(); + let statisticId = getUniqueId(); let penaltyArrayLength; const MOCK_PENALTY_WITH_STATISTIC_ID = { entityName: 'Penalty', @@ -296,30 +257,26 @@ describe('Statistic', () => { }; beforeEach(() => { - statistic = new Statistic( - { - irsDeficiencyAmount: 1, - irsTotalPenalties: 1, - penalties: [ - { - irsPenaltyAmount: 100.0, - name: 'Penalty 1', - penaltyId: '123408f8-8b01-4e49-b437-123a581a12bb', - statisticId, - }, - ], - statisticId, - year: '2001', - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + statistic = new Statistic({ + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + penalties: [ + { + irsPenaltyAmount: 100.0, + name: 'Penalty 1', + penaltyId: '123408f8-8b01-4e49-b437-123a581a12bb', + statisticId, + }, + ], + statisticId, + year: '2001', + yearOrPeriod: 'Year', + }); penaltyArrayLength = statistic.penalties.length; }); it('should add a penalty with a statistics id to the penalties array', () => { statistic.addPenalty({ - applicationContext, rawPenalty: MOCK_PENALTY_WITH_STATISTIC_ID, }); @@ -329,7 +286,6 @@ describe('Statistic', () => { it('should add a penalty without a statistics id to the penalties array and add the parent statisticId to the penalty', () => { statistic.addPenalty({ - applicationContext, rawPenalty: MOCK_PENALTY_WITHOUT_STATISTIC_ID, }); @@ -350,17 +306,14 @@ describe('Statistic', () => { }); it('should itemize both determinationTotalPenalties and irsTotalPenalties created prior to penalty itemization', () => { - const preItemizationStatistic = new Statistic( - { - determinationTotalPenalties: 3000, - irsDeficiencyAmount: 1, - irsTotalPenalties: 2000, - statisticId, - year: '2001', - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const preItemizationStatistic = new Statistic({ + determinationTotalPenalties: 3000, + irsDeficiencyAmount: 1, + irsTotalPenalties: 2000, + statisticId, + year: '2001', + yearOrPeriod: 'Year', + }); const expectedPenalties = [ { @@ -386,16 +339,13 @@ describe('Statistic', () => { }); it('should itemize only irsTotalPenalties created prior to penalty itemization, if determinationTotalPenalties does not exist', () => { - const preItemizationStatistic = new Statistic( - { - irsDeficiencyAmount: 1, - irsTotalPenalties: 2000, - statisticId, - year: '2001', - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const preItemizationStatistic = new Statistic({ + irsDeficiencyAmount: 1, + irsTotalPenalties: 2000, + statisticId, + year: '2001', + yearOrPeriod: 'Year', + }); const expectedPenalties = [ { diff --git a/shared/src/business/entities/Statistic.ts b/shared/src/business/entities/Statistic.ts index ae668994966..3a575568c27 100644 --- a/shared/src/business/entities/Statistic.ts +++ b/shared/src/business/entities/Statistic.ts @@ -2,6 +2,7 @@ import { JoiValidationConstants } from './JoiValidationConstants'; import { JoiValidationEntity } from '@shared/business/entities/JoiValidationEntity'; import { PENALTY_TYPES } from './EntityConstants'; import { Penalty } from './Penalty'; +import { getUniqueId } from '@shared/sharedAppContext'; import joi from 'joi'; /** @@ -21,11 +22,8 @@ export class Statistic extends JoiValidationEntity { public statisticId: string; public penalties: any[]; - constructor(rawStatistic, { applicationContext }) { + constructor(rawStatistic) { super('Statistic'); - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } this.determinationDeficiencyAmount = rawStatistic.determinationDeficiencyAmount; @@ -35,8 +33,7 @@ export class Statistic extends JoiValidationEntity { this.lastDateOfPeriod = rawStatistic.lastDateOfPeriod; this.year = rawStatistic.year; this.yearOrPeriod = rawStatistic.yearOrPeriod; - this.statisticId = - rawStatistic.statisticId || applicationContext.getUniqueId(); + this.statisticId = rawStatistic.statisticId || getUniqueId(); this.penalties = []; if ( rawStatistic.penalties && @@ -44,13 +41,11 @@ export class Statistic extends JoiValidationEntity { rawStatistic.irsTotalPenalties ) { assignPenalties(this, { - applicationContext, rawPenalties: rawStatistic.penalties, statisticId: this.statisticId, }); } else if (rawStatistic.irsTotalPenalties) { itemizeTotalPenalties(this, { - applicationContext, determinationTotalPenalties: this.determinationTotalPenalties, irsTotalPenalties: this.irsTotalPenalties, }); @@ -133,12 +128,12 @@ export class Statistic extends JoiValidationEntity { * @param {Object} penalty the Penalty object to add * @returns {void} modifies the penalties array on the Statistic */ - addPenalty({ applicationContext, rawPenalty }) { + addPenalty({ rawPenalty }) { const rawPenaltyCopy = { ...rawPenalty }; if (!rawPenaltyCopy.statisticId) { rawPenaltyCopy.statisticId = this.statisticId; } - const penalty = new Penalty(rawPenaltyCopy, { applicationContext }); + const penalty = new Penalty(rawPenaltyCopy); this.penalties.push(penalty); } @@ -161,15 +156,11 @@ export class Statistic extends JoiValidationEntity { } } -const assignPenalties = ( - obj, - { applicationContext, rawPenalties, statisticId }, -) => { +const assignPenalties = (obj, { rawPenalties, statisticId }) => { rawPenalties.forEach(penalty => { penalty.statisticId - ? obj.addPenalty({ applicationContext, rawPenalty: penalty }) + ? obj.addPenalty({ rawPenalty: penalty }) : obj.addPenalty({ - applicationContext, rawPenalty: { ...penalty, statisticId }, }); }); @@ -177,10 +168,9 @@ const assignPenalties = ( const itemizeTotalPenalties = function ( obj, - { applicationContext, determinationTotalPenalties, irsTotalPenalties }, + { determinationTotalPenalties, irsTotalPenalties }, ) { obj.addPenalty({ - applicationContext, rawPenalty: { name: 'Penalty 1 (IRS)', penaltyAmount: irsTotalPenalties, @@ -191,7 +181,6 @@ const itemizeTotalPenalties = function ( if (determinationTotalPenalties) { obj.addPenalty({ - applicationContext, rawPenalty: { name: 'Penalty 1 (Court)', penaltyAmount: determinationTotalPenalties, diff --git a/shared/src/business/entities/cases/Case.addPetitioner.test.ts b/shared/src/business/entities/cases/Case.addPetitioner.test.ts index 31ac1a3ba04..90bba721351 100644 --- a/shared/src/business/entities/cases/Case.addPetitioner.test.ts +++ b/shared/src/business/entities/cases/Case.addPetitioner.test.ts @@ -16,22 +16,17 @@ describe('addPetitioner', () => { { applicationContext }, ); - const petitionerEntity = new Petitioner( - { - address1: '123 Tomato Street', - city: 'Tomatotown', - contactType: CONTACT_TYPES.otherPetitioner, - countryType: COUNTRY_TYPES.DOMESTIC, - name: 'Susie Tomato', - phone: '123456', - postalCode: '99999', - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, - state: 'KS', - }, - { - applicationContext, - }, - ); + const petitionerEntity = new Petitioner({ + address1: '123 Tomato Street', + city: 'Tomatotown', + contactType: CONTACT_TYPES.otherPetitioner, + countryType: COUNTRY_TYPES.DOMESTIC, + name: 'Susie Tomato', + phone: '123456', + postalCode: '99999', + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + state: 'KS', + }); expect(caseEntity.petitioners.length).toEqual(1); diff --git a/shared/src/business/entities/cases/Case.addStatistic.test.ts b/shared/src/business/entities/cases/Case.addStatistic.test.ts index b4cb8565c63..2a234c33804 100644 --- a/shared/src/business/entities/cases/Case.addStatistic.test.ts +++ b/shared/src/business/entities/cases/Case.addStatistic.test.ts @@ -7,17 +7,14 @@ describe('addStatistic', () => { it('should successfully add a statistic', () => { const caseEntity = new Case(MOCK_CASE, { applicationContext }); - const statisticToAdd = new Statistic( - { - determinationDeficiencyAmount: 567, - determinationTotalPenalties: 789, - irsDeficiencyAmount: 11.2, - irsTotalPenalties: 66.87, - year: 2012, - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statisticToAdd = new Statistic({ + determinationDeficiencyAmount: 567, + determinationTotalPenalties: 789, + irsDeficiencyAmount: 11.2, + irsTotalPenalties: 66.87, + year: 2012, + yearOrPeriod: 'Year', + }); caseEntity.addStatistic(statisticToAdd); @@ -34,17 +31,14 @@ describe('addStatistic', () => { { applicationContext }, ); - const statisticToAdd = new Statistic( - { - determinationDeficiencyAmount: 567, - determinationTotalPenalties: 789, - irsDeficiencyAmount: 11.2, - irsTotalPenalties: 66.87, - year: 2012, - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statisticToAdd = new Statistic({ + determinationDeficiencyAmount: 567, + determinationTotalPenalties: 789, + irsDeficiencyAmount: 11.2, + irsTotalPenalties: 66.87, + year: 2012, + yearOrPeriod: 'Year', + }); let error; try { diff --git a/shared/src/business/entities/cases/Case.updateStatistic.test.ts b/shared/src/business/entities/cases/Case.updateStatistic.test.ts index f4915849423..0d27a1bd31f 100644 --- a/shared/src/business/entities/cases/Case.updateStatistic.test.ts +++ b/shared/src/business/entities/cases/Case.updateStatistic.test.ts @@ -25,18 +25,15 @@ describe('updateStatistic', () => { { applicationContext }, ); - const statisticToUpdate = new Statistic( - { - determinationDeficiencyAmount: 1, - determinationTotalPenalties: 1, - irsDeficiencyAmount: 1, - irsTotalPenalties: 1, - statisticId, - year: 2012, - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statisticToUpdate = new Statistic({ + determinationDeficiencyAmount: 1, + determinationTotalPenalties: 1, + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + statisticId, + year: 2012, + yearOrPeriod: 'Year', + }); caseEntity.updateStatistic(statisticToUpdate, statisticId); @@ -63,18 +60,15 @@ describe('updateStatistic', () => { { applicationContext }, ); - const statisticToUpdate = new Statistic( - { - determinationDeficiencyAmount: 1, - determinationTotalPenalties: 1, - irsDeficiencyAmount: 1, - irsTotalPenalties: 1, - statisticId: '9f23dac6-4a9d-4e66-aafc-b6d3c892d907', - year: 2012, - yearOrPeriod: 'Year', - }, - { applicationContext }, - ); + const statisticToUpdate = new Statistic({ + determinationDeficiencyAmount: 1, + determinationTotalPenalties: 1, + irsDeficiencyAmount: 1, + irsTotalPenalties: 1, + statisticId: '9f23dac6-4a9d-4e66-aafc-b6d3c892d907', + year: 2012, + yearOrPeriod: 'Year', + }); caseEntity.updateStatistic( statisticToUpdate, diff --git a/shared/src/business/entities/cases/ElectronicPetition.test.ts b/shared/src/business/entities/cases/ElectronicPetition.test.ts index 053f539101b..35b32831e69 100644 --- a/shared/src/business/entities/cases/ElectronicPetition.test.ts +++ b/shared/src/business/entities/cases/ElectronicPetition.test.ts @@ -5,22 +5,18 @@ import { PARTY_TYPES, } from '../EntityConstants'; import { ElectronicPetition } from './ElectronicPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ElectronicPetition entity', () => { describe('isValid', () => { it('requires corporate disclosure if filing type is a business', () => { - const electronicPetition = new ElectronicPetition( - { - businessType: PARTY_TYPES.corporation, - caseType: CASE_TYPES_MAP.other, - filingType: 'A business', - hasIrsNotice: false, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + businessType: PARTY_TYPES.corporation, + caseType: CASE_TYPES_MAP.other, + filingType: 'A business', + hasIrsNotice: false, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! @@ -29,15 +25,12 @@ describe('ElectronicPetition entity', () => { }); it('does not require corporate disclosure if filing type not set', () => { - const petition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - hasIrsNotice: false, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const petition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + hasIrsNotice: false, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( petition.getFormattedValidationErrors()!.corporateDisclosureFile, @@ -45,16 +38,13 @@ describe('ElectronicPetition entity', () => { }); it('does not require corporate disclosure if filing type not a business', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'not a biz', - hasIrsNotice: false, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'not a biz', + hasIrsNotice: false, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! @@ -63,17 +53,14 @@ describe('ElectronicPetition entity', () => { }); it('requires stinFile', () => { - const electronicPetition = new ElectronicPetition( - { - businessType: PARTY_TYPES.corporation, - caseType: CASE_TYPES_MAP.other, - filingType: 'A business', - hasIrsNotice: false, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + businessType: PARTY_TYPES.corporation, + caseType: CASE_TYPES_MAP.other, + filingType: 'A business', + hasIrsNotice: false, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFile, @@ -83,19 +70,16 @@ describe('ElectronicPetition entity', () => { describe('Petition file size', () => { it('should inform you if petition file size is greater than the PDF max file size', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: MAX_FILE_SIZE_BYTES + 5, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: MAX_FILE_SIZE_BYTES + 5, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()!.petitionFileSize, @@ -105,19 +89,16 @@ describe('ElectronicPetition entity', () => { }); it('should inform you if petition file size is zero', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - petitionFile: {}, - petitionFileSize: 0, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + petitionFile: {}, + petitionFileSize: 0, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()!.petitionFileSize, @@ -125,17 +106,14 @@ describe('ElectronicPetition entity', () => { }); it('should not error on petitionFileSize when petitionFile is undefined', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()!.petitionFileSize, @@ -143,18 +121,15 @@ describe('ElectronicPetition entity', () => { }); it('should error on petitionFileSize when petitionFile is defined', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - petitionFile: new File([], 'testPetitionFile.pdf'), - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + petitionFile: new File([], 'testPetitionFile.pdf'), + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()!.petitionFileSize, @@ -164,19 +139,16 @@ describe('ElectronicPetition entity', () => { describe('STIN file size', () => { it('should inform you if stin file size is greater than the file max size', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - stinFile: new File([], 'test.pdf'), - stinFileSize: MAX_FILE_SIZE_BYTES + 5, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + stinFile: new File([], 'test.pdf'), + stinFileSize: MAX_FILE_SIZE_BYTES + 5, + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFileSize, @@ -186,19 +158,16 @@ describe('ElectronicPetition entity', () => { }); it('should inform you if stin file size is zero', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - stinFile: new File([], 'test.pdf'), - stinFileSize: 0, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + stinFile: new File([], 'test.pdf'), + stinFileSize: 0, + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFileSize, @@ -206,17 +175,14 @@ describe('ElectronicPetition entity', () => { }); it('should not error on stinFileSize when stinFile is undefined', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFileSize, @@ -224,19 +190,16 @@ describe('ElectronicPetition entity', () => { }); it('should error on stinFileSize when stinFile is undefined', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - stinFile: new File([], 'testStinFile.pdf'), - stinFileSize: undefined, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + stinFile: new File([], 'testStinFile.pdf'), + stinFileSize: undefined, + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFileSize, @@ -246,19 +209,16 @@ describe('ElectronicPetition entity', () => { describe('ATP file size', () => { it('should inform you if atp file size is greater than the file max size', () => { - const electronicPetition = new ElectronicPetition( - { - attachmentToPetitionFile: new File([], 'test.pdf'), - attachmentToPetitionFileSize: MAX_FILE_SIZE_BYTES + 5, - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + attachmentToPetitionFile: new File([], 'test.pdf'), + attachmentToPetitionFileSize: MAX_FILE_SIZE_BYTES + 5, + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! @@ -269,20 +229,17 @@ describe('ElectronicPetition entity', () => { }); it('should inform you if atp file size is zero', () => { - const electronicPetition = new ElectronicPetition( - { - attachmentToPetitionFile: new File([], 'test.pdf'), - attachmentToPetitionFileSize: 0, - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + attachmentToPetitionFile: new File([], 'test.pdf'), + attachmentToPetitionFileSize: 0, + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! @@ -291,17 +248,14 @@ describe('ElectronicPetition entity', () => { }); it('should not error on attachmentToPetitionFileSize when attachmentToPetitionFile is undefined', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! @@ -310,19 +264,16 @@ describe('ElectronicPetition entity', () => { }); it('should error on attachmentToPetitionFileSize when attachmentToPetitionFile is undefined', () => { - const electronicPetition = new ElectronicPetition( - { - attachmentToPetitionFile: new File([], 'testStinFile.pdf'), - attachmentToPetitionFileSize: undefined, - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + attachmentToPetitionFile: new File([], 'testStinFile.pdf'), + attachmentToPetitionFileSize: undefined, + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! @@ -333,19 +284,16 @@ describe('ElectronicPetition entity', () => { describe('corporate disclosure file size', () => { it('should inform you if corporate disclosure file size is greater than the PDF max file size', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - corporateDisclosureFile: new File([], 'cdsFile.pdf'), - corporateDisclosureFileSize: MAX_FILE_SIZE_BYTES + 5, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + corporateDisclosureFile: new File([], 'cdsFile.pdf'), + corporateDisclosureFileSize: MAX_FILE_SIZE_BYTES + 5, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! @@ -356,19 +304,16 @@ describe('ElectronicPetition entity', () => { }); it('should inform you if corporate disclosure file size is zero', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - corporateDisclosureFile: new File([], 'test.pdf'), - corporateDisclosureFileSize: 0, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + corporateDisclosureFile: new File([], 'test.pdf'), + corporateDisclosureFileSize: 0, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! @@ -377,17 +322,14 @@ describe('ElectronicPetition entity', () => { }); it('should not error on corporateDisclosureFileSize when corporateDisclosureFile is undefined', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! @@ -396,19 +338,16 @@ describe('ElectronicPetition entity', () => { }); it('should error on corporateDisclosureFileSize when corporateDisclosureFile is undefined', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - corporateDisclosureFile: new File([], 'testStinFile.pdf'), - corporateDisclosureFileSize: undefined, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.nextFriendForMinor, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + corporateDisclosureFile: new File([], 'testStinFile.pdf'), + corporateDisclosureFileSize: undefined, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.nextFriendForMinor, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + }); expect( electronicPetition.getFormattedValidationErrors()! diff --git a/shared/src/business/entities/cases/ElectronicPetition.ts b/shared/src/business/entities/cases/ElectronicPetition.ts index dc323817c48..801dba84c76 100644 --- a/shared/src/business/entities/cases/ElectronicPetition.ts +++ b/shared/src/business/entities/cases/ElectronicPetition.ts @@ -39,7 +39,7 @@ export class ElectronicPetition extends JoiValidationEntity { public attachmentToPetitionFile?: File; public attachmentToPetitionFileSize?: number; - constructor(rawCase, { applicationContext }) { + constructor(rawCase) { super('ElectronicPetition'); this.attachmentToPetitionFile = rawCase.attachmentToPetitionFile; @@ -63,7 +63,6 @@ export class ElectronicPetition extends JoiValidationEntity { this.corporateDisclosureFileSize = rawCase.corporateDisclosureFileSize; const contacts = ContactFactory({ - applicationContext, contactInfo: { primary: getContactPrimary(rawCase) || rawCase.contactPrimary, secondary: getContactSecondary(rawCase) || rawCase.contactSecondary, diff --git a/shared/src/business/entities/cases/ElectronicPetitionForCorporationContacts.test.ts b/shared/src/business/entities/cases/ElectronicPetitionForCorporationContacts.test.ts index 097dcdc28b5..d171485724e 100644 --- a/shared/src/business/entities/cases/ElectronicPetitionForCorporationContacts.test.ts +++ b/shared/src/business/entities/cases/ElectronicPetitionForCorporationContacts.test.ts @@ -1,90 +1,80 @@ import { CASE_TYPES_MAP, COUNTRY_TYPES, PARTY_TYPES } from '../EntityConstants'; import { ElectronicPetition } from './ElectronicPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ElectronicPetition', () => { describe('for Corporation Contacts', () => { it('should not validate without contact', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.corporation, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.corporation, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.isValid()).toEqual(false); }); it('should not validate without inCareOf', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '876 12th Ave', - city: 'Nashville', - country: 'USA', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'someone@example.com', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - state: 'AK', - }, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.corporation, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '876 12th Ave', + city: 'Nashville', + country: 'USA', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'someone@example.com', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + state: 'AK', }, - { applicationContext }, - ); + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.corporation, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + }); expect(electronicPetition.isValid()).toEqual(false); }); it('can validate primary contact', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '876 12th Ave', - city: 'Nashville', - country: 'USA', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'someone@example.com', - inCareOf: 'USTC', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - state: 'AK', - }, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.corporation, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '876 12th Ave', + city: 'Nashville', + country: 'USA', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'someone@example.com', + inCareOf: 'USTC', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + state: 'AK', }, - { applicationContext }, - ); + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.corporation, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }); diff --git a/shared/src/business/entities/cases/ElectronicPetitionForEstateWithoutExecutorContacts.test.ts b/shared/src/business/entities/cases/ElectronicPetitionForEstateWithoutExecutorContacts.test.ts index 12ce16100f1..004fc1259df 100644 --- a/shared/src/business/entities/cases/ElectronicPetitionForEstateWithoutExecutorContacts.test.ts +++ b/shared/src/business/entities/cases/ElectronicPetitionForEstateWithoutExecutorContacts.test.ts @@ -1,92 +1,82 @@ import { CASE_TYPES_MAP, COUNTRY_TYPES, PARTY_TYPES } from '../EntityConstants'; import { ElectronicPetition } from './ElectronicPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ElectronicPetition', () => { describe('for Estate without an Executor/Personal Representative/Fiduciary/etc. Contacts', () => { it('should not validate without contact', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.estateWithoutExecutor, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.estateWithoutExecutor, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.isValid()).toEqual(false); }); it('should validate without inCareOf', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '876 12th Ave', - city: 'Nashville', - country: 'USA', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'someone@example.com', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - state: 'AK', - }, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.estateWithoutExecutor, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '876 12th Ave', + city: 'Nashville', + country: 'USA', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'someone@example.com', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + state: 'AK', }, - { applicationContext }, - ); + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.estateWithoutExecutor, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); it('can validate primary contact', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '876 12th Ave', - city: 'Nashville', - country: 'USA', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'someone@example.com', - inCareOf: 'USTC', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - state: 'AK', - }, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.estateWithoutExecutor, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '876 12th Ave', + city: 'Nashville', + country: 'USA', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'someone@example.com', + inCareOf: 'USTC', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + state: 'AK', }, - { applicationContext }, - ); + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.estateWithoutExecutor, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }); diff --git a/shared/src/business/entities/cases/ElectronicPetitionForInternationalContacts.test.ts b/shared/src/business/entities/cases/ElectronicPetitionForInternationalContacts.test.ts index fcb7f44ff8f..78d24487594 100644 --- a/shared/src/business/entities/cases/ElectronicPetitionForInternationalContacts.test.ts +++ b/shared/src/business/entities/cases/ElectronicPetitionForInternationalContacts.test.ts @@ -5,41 +5,37 @@ import { PARTY_TYPES, } from '../EntityConstants'; import { ElectronicPetition } from './ElectronicPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ElectronicPetition', () => { describe('for (international) Contacts', () => { it('should not validate without country', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.petitioner, - petitionFile: {}, - petitionFileSize: 1, - petitioners: [ - { - address1: '876 12th Ave', - city: 'Nashville', - contactType: CONTACT_TYPES.primary, - countryType: COUNTRY_TYPES.INTERNATIONAL, - email: 'someone@example.com', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - state: 'AK', - }, - ], - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.petitioner, + petitionFile: {}, + petitionFileSize: 1, + petitioners: [ + { + address1: '876 12th Ave', + city: 'Nashville', + contactType: CONTACT_TYPES.primary, + countryType: COUNTRY_TYPES.INTERNATIONAL, + email: 'someone@example.com', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + state: 'AK', + }, + ], + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual({ petitioners: [ { @@ -51,37 +47,34 @@ describe('ElectronicPetition', () => { }); it('can validate the primary contact in the petitioners array', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.petitioner, - petitionFile: {}, - petitionFileSize: 1, - petitioners: [ - { - address1: '876 12th Ave', - city: 'Nashville', - contactType: CONTACT_TYPES.primary, - country: 'USA', - countryType: COUNTRY_TYPES.INTERNATIONAL, - email: 'someone@example.com', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - state: 'AK', - }, - ], - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.petitioner, + petitionFile: {}, + petitionFileSize: 1, + petitioners: [ + { + address1: '876 12th Ave', + city: 'Nashville', + contactType: CONTACT_TYPES.primary, + country: 'USA', + countryType: COUNTRY_TYPES.INTERNATIONAL, + email: 'someone@example.com', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + state: 'AK', + }, + ], + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }); diff --git a/shared/src/business/entities/cases/ElectronicPetitionForMinorWithoutGuardianContacts.test.ts b/shared/src/business/entities/cases/ElectronicPetitionForMinorWithoutGuardianContacts.test.ts index 9e1bedc2f86..06d6834f5a7 100644 --- a/shared/src/business/entities/cases/ElectronicPetitionForMinorWithoutGuardianContacts.test.ts +++ b/shared/src/business/entities/cases/ElectronicPetitionForMinorWithoutGuardianContacts.test.ts @@ -1,60 +1,53 @@ import { CASE_TYPES_MAP, COUNTRY_TYPES, PARTY_TYPES } from '../EntityConstants'; import { ElectronicPetition } from './ElectronicPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ElectronicPetition', () => { describe('for Minor without Guardian Contacts', () => { it('should not validate without contacts', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.nextFriendForMinor, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.nextFriendForMinor, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.isValid()).toEqual(false); }); it('can validate contacts', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '876 12th Ave', - city: 'Nashville', - country: 'USA', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'someone@example.com', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - secondaryName: 'Jimmy Dean', - state: 'AK', - }, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.nextFriendForMinor, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '876 12th Ave', + city: 'Nashville', + country: 'USA', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'someone@example.com', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + secondaryName: 'Jimmy Dean', + state: 'AK', }, - { applicationContext }, - ); + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.nextFriendForMinor, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }); diff --git a/shared/src/business/entities/cases/ElectronicPetitionForPartnershipTaxMattersPartnerContacts.test.ts b/shared/src/business/entities/cases/ElectronicPetitionForPartnershipTaxMattersPartnerContacts.test.ts index 9048a1d45e2..553c3f2e15d 100644 --- a/shared/src/business/entities/cases/ElectronicPetitionForPartnershipTaxMattersPartnerContacts.test.ts +++ b/shared/src/business/entities/cases/ElectronicPetitionForPartnershipTaxMattersPartnerContacts.test.ts @@ -1,60 +1,53 @@ import { CASE_TYPES_MAP, COUNTRY_TYPES, PARTY_TYPES } from '../EntityConstants'; import { ElectronicPetition } from './ElectronicPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ElectronicPetition', () => { describe('for Partnership (as the Tax Matters Partner) Contacts', () => { it('should not validate without contacts', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.isValid()).toEqual(false); }); it('can validate contacts', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '876 12th Ave', - city: 'Nashville', - country: 'USA', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'someone@example.com', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - secondaryName: 'Jimmy Dean', - state: 'AK', - }, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '876 12th Ave', + city: 'Nashville', + country: 'USA', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'someone@example.com', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + secondaryName: 'Jimmy Dean', + state: 'AK', }, - { applicationContext }, - ); + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }); diff --git a/shared/src/business/entities/cases/ElectronicPetitionForPetitionerAndDeceasedSpouseContacts.test.ts b/shared/src/business/entities/cases/ElectronicPetitionForPetitionerAndDeceasedSpouseContacts.test.ts index f82f3e46cf3..11ef5b06368 100644 --- a/shared/src/business/entities/cases/ElectronicPetitionForPetitionerAndDeceasedSpouseContacts.test.ts +++ b/shared/src/business/entities/cases/ElectronicPetitionForPetitionerAndDeceasedSpouseContacts.test.ts @@ -1,68 +1,61 @@ import { CASE_TYPES_MAP, COUNTRY_TYPES, PARTY_TYPES } from '../EntityConstants'; import { ElectronicPetition } from './ElectronicPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ElectronicPetition', () => { describe('for Petitioner And Deceased Spouse Contacts', () => { it('should not validate without contacts', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.petitionerDeceasedSpouse, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.petitionerDeceasedSpouse, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.isValid()).toEqual(false); }); it('can validate primary contact name', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '876 12th Ave', - city: 'Nashville', - country: 'USA', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'someone@example.com', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - state: 'AK', - }, - contactSecondary: { - address1: '1599 Pennsylvania Ave', - city: 'Walla Walla', - countryType: COUNTRY_TYPES.DOMESTIC, - inCareOf: 'USTC', - name: 'Betty Crocker', - postalCode: '78774', - state: 'WA', - }, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.petitionerDeceasedSpouse, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '876 12th Ave', + city: 'Nashville', + country: 'USA', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'someone@example.com', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + state: 'AK', + }, + contactSecondary: { + address1: '1599 Pennsylvania Ave', + city: 'Walla Walla', + countryType: COUNTRY_TYPES.DOMESTIC, + inCareOf: 'USTC', + name: 'Betty Crocker', + postalCode: '78774', + state: 'WA', }, - { applicationContext }, - ); + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.petitionerDeceasedSpouse, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }); diff --git a/shared/src/business/entities/cases/ElectronicPetitionForPetitionerAndSpouseContacts.test.ts b/shared/src/business/entities/cases/ElectronicPetitionForPetitionerAndSpouseContacts.test.ts index bf528c2e903..174525a556a 100644 --- a/shared/src/business/entities/cases/ElectronicPetitionForPetitionerAndSpouseContacts.test.ts +++ b/shared/src/business/entities/cases/ElectronicPetitionForPetitionerAndSpouseContacts.test.ts @@ -1,69 +1,62 @@ import { CASE_TYPES_MAP, COUNTRY_TYPES, PARTY_TYPES } from '../EntityConstants'; import { ElectronicPetition } from './ElectronicPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ElectronicPetition', () => { describe('for Petitioner And Spouse Contacts', () => { it('should not validate without contacts', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.petitionerSpouse, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.petitionerSpouse, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.isValid()).toEqual(false); }); it('can validate primary contact name', () => { - const electronicPetition = new ElectronicPetition( - { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '876 12th Ave', - city: 'Nashville', - country: 'USA', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'someone@example.com', - name: 'Jimmy Dean', - phone: '1234567890', - postalCode: '05198', - state: 'AK', - }, - contactSecondary: { - address1: '1599 Pennsylvania Ave', - city: 'Walla Walla', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'someone@example.com', - name: 'Betty Crocker', - phone: '1234567890', - postalCode: '78774', - state: 'WA', - }, - filingType: 'Myself', - hasIrsNotice: true, - irsNoticeDate: '2009-10-13', - partyType: PARTY_TYPES.petitionerSpouse, - petitionFile: {}, - petitionFileSize: 1, - preferredTrialCity: 'Memphis, Tennessee', - procedureType: 'Small', - signature: true, - stinFile: {}, - stinFileSize: 1, + const electronicPetition = new ElectronicPetition({ + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '876 12th Ave', + city: 'Nashville', + country: 'USA', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'someone@example.com', + name: 'Jimmy Dean', + phone: '1234567890', + postalCode: '05198', + state: 'AK', + }, + contactSecondary: { + address1: '1599 Pennsylvania Ave', + city: 'Walla Walla', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'someone@example.com', + name: 'Betty Crocker', + phone: '1234567890', + postalCode: '78774', + state: 'WA', }, - { applicationContext }, - ); + filingType: 'Myself', + hasIrsNotice: true, + irsNoticeDate: '2009-10-13', + partyType: PARTY_TYPES.petitionerSpouse, + petitionFile: {}, + petitionFileSize: 1, + preferredTrialCity: 'Memphis, Tennessee', + procedureType: 'Small', + signature: true, + stinFile: {}, + stinFileSize: 1, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }); diff --git a/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.test.ts b/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.test.ts index 0964a3f0657..975615fdbd7 100644 --- a/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.test.ts +++ b/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.test.ts @@ -7,16 +7,10 @@ import { PARTY_TYPES, } from '../EntityConstants'; import { ElectronicPetitionInformationFactory } from './ElectronicPetitionInformationFactory'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ElectronicPetitionInformationFactory entity', () => { it('requires wizard step', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - {}, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({}); expect( electronicPetition.getFormattedValidationErrors()!!.wizardStep, ).toEqual('"wizardStep" is required'); @@ -25,45 +19,30 @@ describe('ElectronicPetitionInformationFactory entity', () => { describe('wizard step 1', () => { it('requires stinFile', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - wizardStep: '1', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + wizardStep: '1', + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFile, ).toEqual('Upload a Statement of Taxpayer Identification Number (STIN)'); }); it('should be valid if all step 1 and step 2 params are present', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '1', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '1', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual(null); }); describe('STIN file size', () => { it('should inform you if stin file size is greater than the PDF max file size', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - stinFile: new File([], 'test.pdf'), - stinFileSize: MAX_FILE_SIZE_BYTES + 5, - wizardStep: '1', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + stinFile: new File([], 'test.pdf'), + stinFileSize: MAX_FILE_SIZE_BYTES + 5, + wizardStep: '1', + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFileSize, @@ -73,45 +52,30 @@ describe('ElectronicPetitionInformationFactory entity', () => { }); it('should inform you if stin file size is zero', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - stinFile: new File([], 'test.pdf'), - stinFileSize: 0, - wizardStep: '1', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + stinFile: new File([], 'test.pdf'), + stinFileSize: 0, + wizardStep: '1', + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFileSize, ).toEqual('Your STIN file size is empty'); }); it('should not error on stinFileSize when stinFile is undefined', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - wizardStep: '1', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + wizardStep: '1', + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFileSize, ).toBeUndefined(); }); it('should error on stinFileSize when stinFile is defined', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - stinFile: new File([], 'testStinFile.pdf'), - wizardStep: '1', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + stinFile: new File([], 'testStinFile.pdf'), + wizardStep: '1', + }); expect( electronicPetition.getFormattedValidationErrors()!.stinFileSize, ).toEqual('Your STIN file size is empty'); @@ -121,29 +85,19 @@ describe('ElectronicPetitionInformationFactory entity', () => { describe('wizard step 2', () => { it('requires all wizard step 1 and 2 items', () => { - let electronicPetition = new ElectronicPetitionInformationFactory( - { - wizardStep: '2', - }, - { - applicationContext, - }, - ); + let electronicPetition = new ElectronicPetitionInformationFactory({ + wizardStep: '2', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ hasIrsNotice: 'Indicate whether you received an IRS notice', petitionFile: 'Upload a Petition', stinFile: 'Upload a Statement of Taxpayer Identification Number (STIN)', }); - electronicPetition = new ElectronicPetitionInformationFactory( - { - stinFile: new File([], 'test.pdf'), - wizardStep: '2', - }, - { - applicationContext, - }, - ); + electronicPetition = new ElectronicPetitionInformationFactory({ + stinFile: new File([], 'test.pdf'), + wizardStep: '2', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ hasIrsNotice: 'Indicate whether you received an IRS notice', petitionFile: 'Upload a Petition', @@ -152,16 +106,11 @@ describe('ElectronicPetitionInformationFactory entity', () => { }); it('requires hasIrsNotice and petitionFile if no params from step 2 are present', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '2', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '2', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ hasIrsNotice: 'Indicate whether you received an IRS notice', petitionFile: 'Upload a Petition', @@ -169,77 +118,57 @@ describe('ElectronicPetitionInformationFactory entity', () => { }); it('requires caseType if hasIrsNotice is present', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - hasIrsNotice: true, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '2', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + hasIrsNotice: true, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '2', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ caseType: 'Select a case type', }); }); it('should be valid if all step 1 and step 2 params are present', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - caseType: CASE_TYPES_MAP.deficiency, - hasIrsNotice: true, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '2', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + caseType: CASE_TYPES_MAP.deficiency, + hasIrsNotice: true, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '2', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual(null); }); it('should be valid if all step 1 and step 2 params are present, but a partyType and invalid contactPrimary are present', () => { - const electronicPetition = new ElectronicPetitionInformationFactory( - { - caseType: CASE_TYPES_MAP.deficiency, - hasIrsNotice: true, - partyType: PARTY_TYPES.petitioner, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - petitioners: [ - { - name: 'Something', - }, - ], - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '2', - }, - { - applicationContext, - }, - ); + const electronicPetition = new ElectronicPetitionInformationFactory({ + caseType: CASE_TYPES_MAP.deficiency, + hasIrsNotice: true, + partyType: PARTY_TYPES.petitioner, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + petitioners: [ + { + name: 'Something', + }, + ], + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '2', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual(null); }); }); describe('wizard step 3', () => { it('requires all wizard step 1, 2, and 3 items', () => { - let electronicPetition = new ElectronicPetitionInformationFactory( - { - wizardStep: '3', - }, - { - applicationContext, - }, - ); + let electronicPetition = new ElectronicPetitionInformationFactory({ + wizardStep: '3', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ filingType: 'Select on whose behalf you are filing', hasIrsNotice: 'Indicate whether you received an IRS notice', @@ -248,17 +177,12 @@ describe('ElectronicPetitionInformationFactory entity', () => { stinFile: 'Upload a Statement of Taxpayer Identification Number (STIN)', }); - electronicPetition = new ElectronicPetitionInformationFactory( - { - hasIrsNotice: true, - petitionFile: new File([], 'test.pdf'), - stinFile: new File([], 'test.pdf'), - wizardStep: '3', - }, - { - applicationContext, - }, - ); + electronicPetition = new ElectronicPetitionInformationFactory({ + hasIrsNotice: true, + petitionFile: new File([], 'test.pdf'), + stinFile: new File([], 'test.pdf'), + wizardStep: '3', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ caseType: 'Select a case type', filingType: 'Select on whose behalf you are filing', @@ -269,20 +193,15 @@ describe('ElectronicPetitionInformationFactory entity', () => { }); it('requires filingType and partyType if wizard step 1 and 2 required fields are present', () => { - let electronicPetition = new ElectronicPetitionInformationFactory( - { - caseType: CASE_TYPES_MAP.deficiency, - hasIrsNotice: true, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '3', - }, - { - applicationContext, - }, - ); + let electronicPetition = new ElectronicPetitionInformationFactory({ + caseType: CASE_TYPES_MAP.deficiency, + hasIrsNotice: true, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '3', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ filingType: 'Select on whose behalf you are filing', partyType: 'Select a party type', @@ -290,22 +209,17 @@ describe('ElectronicPetitionInformationFactory entity', () => { }); it('requires corporateDisclosureFile if filingType is A business', () => { - let electronicPetition = new ElectronicPetitionInformationFactory( - { - caseType: CASE_TYPES_MAP.deficiency, - filingType: 'A business', - hasIrsNotice: true, - partyType: PARTY_TYPES.corporation, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '3', - }, - { - applicationContext, - }, - ); + let electronicPetition = new ElectronicPetitionInformationFactory({ + caseType: CASE_TYPES_MAP.deficiency, + filingType: 'A business', + hasIrsNotice: true, + partyType: PARTY_TYPES.corporation, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '3', + }); expect( electronicPetition.getFormattedValidationErrors()! .corporateDisclosureFile, @@ -313,22 +227,17 @@ describe('ElectronicPetitionInformationFactory entity', () => { }); it('does not require corporateDisclosureFile if filingType is not A business', () => { - let electronicPetition = new ElectronicPetitionInformationFactory( - { - caseType: CASE_TYPES_MAP.deficiency, - filingType: 'something else', - hasIrsNotice: true, - partyType: PARTY_TYPES.corporation, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '3', - }, - { - applicationContext, - }, - ); + let electronicPetition = new ElectronicPetitionInformationFactory({ + caseType: CASE_TYPES_MAP.deficiency, + filingType: 'something else', + hasIrsNotice: true, + partyType: PARTY_TYPES.corporation, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '3', + }); expect( electronicPetition.getFormattedValidationErrors()! .corporateDisclosureFile, @@ -336,22 +245,17 @@ describe('ElectronicPetitionInformationFactory entity', () => { }); it('requires only contactPrimary if partyType is Petitioner', () => { - let electronicPetition = new ElectronicPetitionInformationFactory( - { - caseType: CASE_TYPES_MAP.deficiency, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.petitioner, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '3', - }, - { - applicationContext, - }, - ); + let electronicPetition = new ElectronicPetitionInformationFactory({ + caseType: CASE_TYPES_MAP.deficiency, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.petitioner, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '3', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ petitioners: [ { @@ -369,22 +273,17 @@ describe('ElectronicPetitionInformationFactory entity', () => { }); it('requires contactPrimary and contactSecondary if partyType is Petitioner & Spouse', () => { - let electronicPetition = new ElectronicPetitionInformationFactory( - { - caseType: CASE_TYPES_MAP.deficiency, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.petitionerSpouse, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '3', - }, - { - applicationContext, - }, - ); + let electronicPetition = new ElectronicPetitionInformationFactory({ + caseType: CASE_TYPES_MAP.deficiency, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.petitionerSpouse, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '3', + }); expect( electronicPetition.getFormattedValidationErrors()!.petitioners, ).toBeDefined(); @@ -393,14 +292,9 @@ describe('ElectronicPetitionInformationFactory entity', () => { describe('wizard step 4', () => { it('requires all wizard step 1, 2, 3, and 4 items', () => { - let electronicPetition = new ElectronicPetitionInformationFactory( - { - wizardStep: '4', - }, - { - applicationContext, - }, - ); + let electronicPetition = new ElectronicPetitionInformationFactory({ + wizardStep: '4', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ filingType: 'Select on whose behalf you are filing', hasIrsNotice: 'Indicate whether you received an IRS notice', @@ -411,19 +305,14 @@ describe('ElectronicPetitionInformationFactory entity', () => { stinFile: 'Upload a Statement of Taxpayer Identification Number (STIN)', }); - electronicPetition = new ElectronicPetitionInformationFactory( - { - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.petitionerSpouse, - petitionFile: new File([], 'test.pdf'), - stinFile: new File([], 'test.pdf'), - wizardStep: '4', - }, - { - applicationContext, - }, - ); + electronicPetition = new ElectronicPetitionInformationFactory({ + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.petitionerSpouse, + petitionFile: new File([], 'test.pdf'), + stinFile: new File([], 'test.pdf'), + wizardStep: '4', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual({ caseType: 'Select a case type', petitionFileSize: 'Your Petition file size is empty', @@ -456,45 +345,40 @@ describe('ElectronicPetitionInformationFactory entity', () => { }); it('returns no validation errors if all required fields from all steps are present', () => { - let electronicPetition = new ElectronicPetitionInformationFactory( - { - caseType: CASE_TYPES_MAP.deficiency, - contactSecondary: { + let electronicPetition = new ElectronicPetitionInformationFactory({ + caseType: CASE_TYPES_MAP.deficiency, + contactSecondary: { + address1: '123 Main St', + city: 'Somewhere', + countryType: COUNTRY_TYPES.DOMESTIC, + name: 'Test Secondary', + phone: '1234567890', + postalCode: '12345', + state: 'CA', + }, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.petitionerSpouse, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + petitioners: [ + { address1: '123 Main St', city: 'Somewhere', + contactType: CONTACT_TYPES.primary, countryType: COUNTRY_TYPES.DOMESTIC, - name: 'Test Secondary', + name: 'Test Primary', phone: '1234567890', postalCode: '12345', state: 'CA', }, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.petitionerSpouse, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - petitioners: [ - { - address1: '123 Main St', - city: 'Somewhere', - contactType: CONTACT_TYPES.primary, - countryType: COUNTRY_TYPES.DOMESTIC, - name: 'Test Primary', - phone: '1234567890', - postalCode: '12345', - state: 'CA', - }, - ], - preferredTrialCity: 'Boise, Idaho', - procedureType: 'Regular', - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - wizardStep: '4', - }, - { - applicationContext, - }, - ); + ], + preferredTrialCity: 'Boise, Idaho', + procedureType: 'Regular', + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, + wizardStep: '4', + }); expect(electronicPetition.getFormattedValidationErrors()!).toEqual(null); expect(electronicPetition.isValid()).toBeTruthy(); }); diff --git a/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.ts b/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.ts index 9889b71a572..3334a099442 100644 --- a/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.ts +++ b/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.ts @@ -32,7 +32,7 @@ export class ElectronicPetitionInformationFactory extends JoiValidationEntity { public stinFileSize?: number; public wizardStep: number; - constructor(rawCase, { applicationContext }) { + constructor(rawCase) { super('ElectronicPetitionInformationFactory'); this.attachmentToPetitionFile = rawCase.attachmentToPetitionFile; @@ -55,7 +55,6 @@ export class ElectronicPetitionInformationFactory extends JoiValidationEntity { if (+this.wizardStep >= 3) { const contacts = ContactFactory({ - applicationContext, contactInfo: { primary: getContactPrimary(rawCase) || rawCase.contactPrimary, secondary: getContactSecondary(rawCase) || rawCase.contactSecondary, diff --git a/shared/src/business/entities/cases/PaperPetition.ts b/shared/src/business/entities/cases/PaperPetition.ts index 4de112fe843..0b0c197b362 100644 --- a/shared/src/business/entities/cases/PaperPetition.ts +++ b/shared/src/business/entities/cases/PaperPetition.ts @@ -116,9 +116,7 @@ export class PaperPetition extends JoiValidationEntity { this.docketEntries = rawProps.docketEntries || []; this.statistics = Array.isArray(rawProps.statistics) - ? rawProps.statistics.map( - statistic => new Statistic(statistic, { applicationContext }), - ) + ? rawProps.statistics.map(statistic => new Statistic(statistic)) : []; this.archivedDocketEntries = Array.isArray(rawProps.archivedDocketEntries) @@ -139,7 +137,6 @@ export class PaperPetition extends JoiValidationEntity { : []; const contacts = ContactFactory({ - applicationContext, contactInfo: { primary: getContactPrimary(rawProps) || rawProps.contactPrimary, secondary: getContactSecondary(rawProps) || rawProps.contactSecondary, diff --git a/shared/src/business/entities/contacts/Contact.test.ts b/shared/src/business/entities/contacts/Contact.test.ts index ec8ae91ed2c..b50bfd1e4ba 100644 --- a/shared/src/business/entities/contacts/Contact.test.ts +++ b/shared/src/business/entities/contacts/Contact.test.ts @@ -1,6 +1,5 @@ import { Contact } from './Contact'; import { MOCK_CONTACT_PRIMARY } from '../../../test/mockContact'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('Contact', () => { describe('hasEAccess validation', () => { @@ -12,7 +11,6 @@ describe('Contact', () => { hasEAccess: true, }, 'PetitionerPrimaryContact', - { applicationContext }, ); expect(contact.getFormattedValidationErrors()!.email).toEqual( @@ -28,7 +26,6 @@ describe('Contact', () => { hasEAccess: false, }, 'PetitionerPrimaryContact', - { applicationContext }, ); expect(contact.getFormattedValidationErrors()?.email).toEqual(undefined); diff --git a/shared/src/business/entities/contacts/Contact.ts b/shared/src/business/entities/contacts/Contact.ts index 662c8f47e66..77c30006134 100644 --- a/shared/src/business/entities/contacts/Contact.ts +++ b/shared/src/business/entities/contacts/Contact.ts @@ -10,6 +10,7 @@ import { import { JoiValidationConstants } from '../JoiValidationConstants'; import { JoiValidationEntity } from '../JoiValidationEntity'; import { formatPhoneNumber } from '../../utilities/formatPhoneNumber'; +import { getUniqueId } from '@shared/sharedAppContext'; import joi from 'joi'; export class Contact extends JoiValidationEntity { @@ -37,17 +38,10 @@ export class Contact extends JoiValidationEntity { public additionalName?: string; public hasEAccess?: boolean; - constructor( - rawContact, - contactName: string, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { + constructor(rawContact, contactName: string) { super(contactName); - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } - this.contactId = rawContact.contactId || applicationContext.getUniqueId(); + this.contactId = rawContact.contactId || getUniqueId(); this.address1 = rawContact.address1; this.address2 = rawContact.address2 || undefined; this.address3 = rawContact.address3 || undefined; diff --git a/shared/src/business/entities/contacts/ContactFactory.test.ts b/shared/src/business/entities/contacts/ContactFactory.test.ts index e21f0a605a0..4a81c8a29bd 100644 --- a/shared/src/business/entities/contacts/ContactFactory.test.ts +++ b/shared/src/business/entities/contacts/ContactFactory.test.ts @@ -7,7 +7,6 @@ import { } from '../EntityConstants'; import { ContactFactory } from './ContactFactory'; import { ElectronicPetition } from '../cases/ElectronicPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('ContactFactory', () => { const baseElectronicPetition = { @@ -43,167 +42,128 @@ describe('ContactFactory', () => { state: 'AK', }; - it('should throw an error if app context is not passed in', () => { - expect( - () => new ElectronicPetition(baseElectronicPetition, {} as any), - ).toThrow(); - }); - describe('for Corporation Contacts', () => { it('should not validate without contact when the case status is new', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.corporation, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.corporation, + }); expect(electronicPetition.isValid()).toEqual(false); }); it('can validate primary contact when the case is not served', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.corporation, - petitioners: [baseContact], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.corporation, + petitioners: [baseContact], + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }); it('can validate Petitioner contact when the case is not served', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.petitioner, - petitioners: [baseContact], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.petitioner, + petitioners: [baseContact], + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); it('passes validation when primary contact is defined and everything else is valid on an unserved case', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estateWithoutExecutor, - petitioners: [baseContact], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estateWithoutExecutor, + petitioners: [baseContact], + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); it('passes validation when in care of is undefined and everything else is valid on a served case', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estateWithoutExecutor, - petitioners: [ - { - ...baseContact, - contactType: CONTACT_TYPES.petitioner, - inCareOf: undefined, - }, - ], - status: CASE_STATUS_TYPES.generalDocketReadyForTrial, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estateWithoutExecutor, + petitioners: [ + { + ...baseContact, + contactType: CONTACT_TYPES.petitioner, + inCareOf: undefined, + }, + ], + status: CASE_STATUS_TYPES.generalDocketReadyForTrial, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); it('returns false for isValid if primary contact is missing', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estate, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estate, + }); expect(electronicPetition.isValid()).toEqual(false); }); it('defaults isAddressSealed to false when no value is specified', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estate, - petitioners: [baseContact], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estate, + petitioners: [baseContact], + }); expect(electronicPetition.getContactPrimary().isAddressSealed).toBe(false); }); it('sets the value of isAddressSealed when a value is specified', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estate, - petitioners: [ - { - ...baseContact, - isAddressSealed: true, - }, - ], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estate, + petitioners: [ + { + ...baseContact, + isAddressSealed: true, + }, + ], + }); expect(electronicPetition.getContactPrimary().isAddressSealed).toBe(true); }); it('defaults sealedAndUnavailable to false when no value is specified', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estate, - petitioners: [baseContact], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estate, + petitioners: [baseContact], + }); expect(electronicPetition.getContactPrimary().sealedAndUnavailable).toBe( false, ); }); it('sets the value of sealedAndUnavailable when a value is specified', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estate, - petitioners: [ - { - ...baseContact, - sealedAndUnavailable: true, - }, - ], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estate, + petitioners: [ + { + ...baseContact, + sealedAndUnavailable: true, + }, + ], + }); expect(electronicPetition.getContactPrimary().sealedAndUnavailable).toBe( true, ); }); it('formats phone number string', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - petitioners: [ - { - ...baseContact, - phone: '4444444444', - }, - ], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + petitioners: [ + { + ...baseContact, + phone: '4444444444', + }, + ], + }); expect(electronicPetition.getContactPrimary().phone).toEqual( '444-444-4444', @@ -211,46 +171,35 @@ describe('ContactFactory', () => { }); it('returns false for isValid if serviceIndicator is an invalid value', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estate, - petitioners: [ - { - ...baseContact, - serviceIndicator: 'WHAT', - }, - ], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estate, + petitioners: [ + { + ...baseContact, + serviceIndicator: 'WHAT', + }, + ], + }); expect(electronicPetition.isValid()).toEqual(false); }); it('a valid case returns true for isValid when status is new', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estate, - petitioners: [baseContact], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estate, + petitioners: [baseContact], + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); it('a valid case returns true for isValid when status is not new', () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: PARTY_TYPES.estate, - petitioners: [ - { ...baseContact, contactType: CONTACT_TYPES.petitioner }, - ], - status: CASE_STATUS_TYPES.generalDocketReadyForTrial, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType: PARTY_TYPES.estate, + petitioners: [{ ...baseContact, contactType: CONTACT_TYPES.petitioner }], + status: CASE_STATUS_TYPES.generalDocketReadyForTrial, + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); @@ -274,25 +223,19 @@ describe('ContactFactory', () => { PARTY_TYPES.trust, ].forEach(partyType => { it(`can validate invalid ${partyType} contact`, () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType, + }); expect(electronicPetition.isValid()).toEqual(false); }); it(`can validate valid ${partyType} contact`, () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType, - petitioners: [baseContact], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType, + petitioners: [baseContact], + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }); @@ -300,31 +243,25 @@ describe('ContactFactory', () => { [PARTY_TYPES.petitionerDeceasedSpouse, PARTY_TYPES.petitionerSpouse].forEach( partyType => { it(`can validate invalid ${partyType} contact`, () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType, - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType, + }); expect(electronicPetition.isValid()).toEqual(false); }); it(`can validate valid ${partyType} contact`, () => { - const electronicPetition = new ElectronicPetition( - { - ...baseElectronicPetition, - partyType, - petitioners: [ - baseContact, - { - ...baseContact, - contactType: CONTACT_TYPES.secondary, - }, - ], - }, - { applicationContext }, - ); + const electronicPetition = new ElectronicPetition({ + ...baseElectronicPetition, + partyType, + petitioners: [ + baseContact, + { + ...baseContact, + contactType: CONTACT_TYPES.secondary, + }, + ], + }); expect(electronicPetition.getFormattedValidationErrors()).toEqual(null); }); }, @@ -332,14 +269,11 @@ describe('ContactFactory', () => { it('throws an Error (upon construction) if `partyType` is defined but not found in the available list', () => { expect(() => { - new ElectronicPetition( - { - ...baseElectronicPetition, - partyType: 'SOME INVALID PARTY TYPE', - petitioners: [baseContact], - }, - { applicationContext }, - ); + new ElectronicPetition({ + ...baseElectronicPetition, + partyType: 'SOME INVALID PARTY TYPE', + petitioners: [baseContact], + }); }).toThrow('Unrecognized party type "SOME INVALID PARTY TYPE"'); }); diff --git a/shared/src/business/entities/contacts/ContactFactory.ts b/shared/src/business/entities/contacts/ContactFactory.ts index c9e152270b3..e14a18bda1e 100644 --- a/shared/src/business/entities/contacts/ContactFactory.ts +++ b/shared/src/business/entities/contacts/ContactFactory.ts @@ -17,11 +17,9 @@ import { PetitionerTrustContact } from './PetitionerTrustContact'; import { SurvivingSpouseContact } from './SurvivingSpouseContact'; export function ContactFactory({ - applicationContext, contactInfo, partyType, }: { - applicationContext: IApplicationContext; contactInfo: any; partyType: PartyType; }) { @@ -30,135 +28,135 @@ export function ContactFactory({ case PARTY_TYPES.transferee: case PARTY_TYPES.petitioner: return { - primary: new PetitionerPrimaryContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PetitionerPrimaryContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.conservator: return { - primary: new PetitionerConservatorContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PetitionerConservatorContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), }; case PARTY_TYPES.corporation: return { - primary: new PetitionerCorporationContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PetitionerCorporationContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.custodian: return { - primary: new PetitionerCustodianContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PetitionerCustodianContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.estate: return { - primary: new PetitionerEstateWithExecutorPrimaryContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PetitionerEstateWithExecutorPrimaryContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.estateWithoutExecutor: return { - primary: new PetitionerIntermediaryContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PetitionerIntermediaryContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.guardian: return { - primary: new PetitionerGuardianContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PetitionerGuardianContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.nextFriendForIncompetentPerson: return { - primary: new NextFriendForIncompetentPersonContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new NextFriendForIncompetentPersonContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.nextFriendForMinor: return { - primary: new NextFriendForMinorContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new NextFriendForMinorContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.partnershipAsTaxMattersPartner: return { - primary: new PartnershipAsTaxMattersPartnerPrimaryContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PartnershipAsTaxMattersPartnerPrimaryContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.partnershipBBA: return { - primary: new PartnershipBBAPrimaryContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PartnershipBBAPrimaryContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.partnershipOtherThanTaxMatters: return { - primary: new PartnershipOtherThanTaxMattersPrimaryContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PartnershipOtherThanTaxMattersPrimaryContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.petitionerDeceasedSpouse: return { - primary: new PetitionerPrimaryContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), - secondary: new PetitionerDeceasedSpouseContact( - { ...contactInfo.secondary, contactType: CONTACT_TYPES.secondary }, - { applicationContext }, - ), + primary: new PetitionerPrimaryContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), + secondary: new PetitionerDeceasedSpouseContact({ + ...contactInfo.secondary, + contactType: CONTACT_TYPES.secondary, + }), }; case PARTY_TYPES.petitionerSpouse: return { - primary: new PetitionerPrimaryContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), - secondary: new PetitionerSpouseContact( - { ...contactInfo.secondary, contactType: CONTACT_TYPES.secondary }, - { applicationContext }, - ), + primary: new PetitionerPrimaryContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), + secondary: new PetitionerSpouseContact({ + ...contactInfo.secondary, + contactType: CONTACT_TYPES.secondary, + }), }; case PARTY_TYPES.survivingSpouse: return { - primary: new SurvivingSpouseContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new SurvivingSpouseContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; case PARTY_TYPES.trust: return { - primary: new PetitionerTrustContact( - { ...contactInfo.primary, contactType: CONTACT_TYPES.primary }, - { applicationContext }, - ), + primary: new PetitionerTrustContact({ + ...contactInfo.primary, + contactType: CONTACT_TYPES.primary, + }), secondary: null, }; default: diff --git a/shared/src/business/entities/contacts/NextFriendForIncompetentPersonContact.ts b/shared/src/business/entities/contacts/NextFriendForIncompetentPersonContact.ts index 6f5297ffaa4..7802a9b56c5 100644 --- a/shared/src/business/entities/contacts/NextFriendForIncompetentPersonContact.ts +++ b/shared/src/business/entities/contacts/NextFriendForIncompetentPersonContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class NextFriendForIncompetentPersonContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'NextFriendForIncompetentPersonContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'NextFriendForIncompetentPersonContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/NextFriendForMinorContact.ts b/shared/src/business/entities/contacts/NextFriendForMinorContact.ts index d6970f252fb..8fcdadd1211 100644 --- a/shared/src/business/entities/contacts/NextFriendForMinorContact.ts +++ b/shared/src/business/entities/contacts/NextFriendForMinorContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class NextFriendForMinorContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'NextFriendForMinorContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'NextFriendForMinorContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PartnershipAsTaxMattersPartnerContact.ts b/shared/src/business/entities/contacts/PartnershipAsTaxMattersPartnerContact.ts index efd2c481fb2..ab3e825c406 100644 --- a/shared/src/business/entities/contacts/PartnershipAsTaxMattersPartnerContact.ts +++ b/shared/src/business/entities/contacts/PartnershipAsTaxMattersPartnerContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PartnershipAsTaxMattersPartnerPrimaryContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PartnershipAsTaxMattersPartnerPrimaryContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PartnershipAsTaxMattersPartnerPrimaryContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PartnershipBBAContact.ts b/shared/src/business/entities/contacts/PartnershipBBAContact.ts index 1b56f06cf93..6833430870c 100644 --- a/shared/src/business/entities/contacts/PartnershipBBAContact.ts +++ b/shared/src/business/entities/contacts/PartnershipBBAContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PartnershipBBAPrimaryContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PartnershipBBAPrimaryContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PartnershipBBAPrimaryContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PartnershipOtherThanTaxMattersContact.ts b/shared/src/business/entities/contacts/PartnershipOtherThanTaxMattersContact.ts index b60ba6bdcca..61b50dc1720 100644 --- a/shared/src/business/entities/contacts/PartnershipOtherThanTaxMattersContact.ts +++ b/shared/src/business/entities/contacts/PartnershipOtherThanTaxMattersContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PartnershipOtherThanTaxMattersPrimaryContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PartnershipOtherThanTaxMattersPrimaryContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PartnershipOtherThanTaxMattersPrimaryContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/Petitioner.test.ts b/shared/src/business/entities/contacts/Petitioner.test.ts index 7daea00e120..78bf8dbe757 100644 --- a/shared/src/business/entities/contacts/Petitioner.test.ts +++ b/shared/src/business/entities/contacts/Petitioner.test.ts @@ -4,7 +4,6 @@ import { SERVICE_INDICATOR_TYPES, } from '../EntityConstants'; import { Petitioner } from './Petitioner'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { getTextByCount } from '../../utilities/getTextByCount'; describe('Petitioner', () => { @@ -20,21 +19,12 @@ describe('Petitioner', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, }; - it('should throw an error when applicationContext is not provided to the importructor', () => { - expect(() => new Petitioner(mockValidPetitioner, {} as any)).toThrow( - 'applicationContext must be defined', - ); - }); - describe('validate', () => { it('should be false when serviceIndicator is undefined', () => { - const entity = new Petitioner( - { - ...mockValidPetitioner, - serviceIndicator: undefined, - }, - { applicationContext }, - ); + const entity = new Petitioner({ + ...mockValidPetitioner, + serviceIndicator: undefined, + }); expect(entity.isValid()).toBe(false); expect(entity.getFormattedValidationErrors()).toEqual({ @@ -43,13 +33,10 @@ describe('Petitioner', () => { }); it('should be false when name field is too long', () => { - const entity = new Petitioner( - { - ...mockValidPetitioner, - name: getTextByCount(101), - }, - { applicationContext }, - ); + const entity = new Petitioner({ + ...mockValidPetitioner, + name: getTextByCount(101), + }); expect(entity.isValid()).toBe(false); expect(entity.getFormattedValidationErrors()).toEqual({ @@ -58,13 +45,10 @@ describe('Petitioner', () => { }); it('should be false when additionalName field is too long', () => { - const entity = new Petitioner( - { - ...mockValidPetitioner, - additionalName: getTextByCount(601), - }, - { applicationContext }, - ); + const entity = new Petitioner({ + ...mockValidPetitioner, + additionalName: getTextByCount(601), + }); expect(entity.isValid()).toBe(false); expect(entity.getFormattedValidationErrors()).toEqual({ @@ -74,22 +58,17 @@ describe('Petitioner', () => { }); it('should be true when all required fields have been provided', () => { - const entity = new Petitioner(mockValidPetitioner, { - applicationContext, - }); + const entity = new Petitioner(mockValidPetitioner); expect(entity.isValid()).toBe(true); expect(entity.getFormattedValidationErrors()).toEqual(null); }); it('should be false when title is longer than 100 chars', () => { - const entity = new Petitioner( - { - ...mockValidPetitioner, - title: getTextByCount(101), - }, - { applicationContext }, - ); + const entity = new Petitioner({ + ...mockValidPetitioner, + title: getTextByCount(101), + }); expect(entity.isValid()).toBe(false); expect(entity.getFormattedValidationErrors()).toEqual({ @@ -101,13 +80,10 @@ describe('Petitioner', () => { describe('phone number formatting', () => { it('should format phone number string', () => { - const entity = new Petitioner( - { - ...mockValidPetitioner, - phone: '1234567890', - }, - { applicationContext }, - ); + const entity = new Petitioner({ + ...mockValidPetitioner, + phone: '1234567890', + }); expect(entity.phone).toEqual('123-456-7890'); }); @@ -117,13 +93,10 @@ describe('Petitioner', () => { it('should populate paperPetitionEmail when one is provided', () => { const mockEmail = 'petitioner@example.com'; - const entity = new Petitioner( - { - ...mockValidPetitioner, - paperPetitionEmail: mockEmail, - }, - { applicationContext }, - ); + const entity = new Petitioner({ + ...mockValidPetitioner, + paperPetitionEmail: mockEmail, + }); expect(entity.paperPetitionEmail).toEqual(mockEmail); }); @@ -131,13 +104,10 @@ describe('Petitioner', () => { it('should populate hasConsentedToEService when one is provided', () => { const mockHasConsentedToEService = false; - const entity = new Petitioner( - { - ...mockValidPetitioner, - hasConsentedToEService: mockHasConsentedToEService, - }, - { applicationContext }, - ); + const entity = new Petitioner({ + ...mockValidPetitioner, + hasConsentedToEService: mockHasConsentedToEService, + }); expect(entity.hasConsentedToEService).toEqual(mockHasConsentedToEService); }); diff --git a/shared/src/business/entities/contacts/Petitioner.ts b/shared/src/business/entities/contacts/Petitioner.ts index 2b91ec51e2d..8604305438a 100644 --- a/shared/src/business/entities/contacts/Petitioner.ts +++ b/shared/src/business/entities/contacts/Petitioner.ts @@ -3,6 +3,7 @@ import { JoiValidationConstants } from '../JoiValidationConstants'; import { JoiValidationEntity } from '../JoiValidationEntity'; import { User } from '@shared/business/entities/User'; import { formatPhoneNumber } from '../../utilities/formatPhoneNumber'; +import { getUniqueId } from '@shared/sharedAppContext'; import joi from 'joi'; export class Petitioner extends JoiValidationEntity { @@ -30,22 +31,15 @@ export class Petitioner extends JoiValidationEntity { public state?: string; public title?: string; - constructor( - rawProps, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { + constructor(rawProps) { super('Petitioner'); - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } - this.additionalName = rawProps.additionalName; this.address1 = rawProps.address1; this.address2 = rawProps.address2 || undefined; this.address3 = rawProps.address3 || undefined; this.city = rawProps.city; - this.contactId = rawProps.contactId || applicationContext.getUniqueId(); + this.contactId = rawProps.contactId || getUniqueId(); this.contactType = rawProps.contactType; this.country = rawProps.country; this.countryType = rawProps.countryType; diff --git a/shared/src/business/entities/contacts/PetitionerConservatorContact.ts b/shared/src/business/entities/contacts/PetitionerConservatorContact.ts index 7be6929bc9f..cb3ce928afa 100644 --- a/shared/src/business/entities/contacts/PetitionerConservatorContact.ts +++ b/shared/src/business/entities/contacts/PetitionerConservatorContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PetitionerConservatorContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerConservatorContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerConservatorContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PetitionerCorporationContact.ts b/shared/src/business/entities/contacts/PetitionerCorporationContact.ts index f186fb9de96..b6ec21f7b41 100644 --- a/shared/src/business/entities/contacts/PetitionerCorporationContact.ts +++ b/shared/src/business/entities/contacts/PetitionerCorporationContact.ts @@ -1,13 +1,8 @@ import { Contact } from './Contact'; export class PetitionerCorporationContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerCorporationContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerCorporationContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PetitionerCustodianContact.ts b/shared/src/business/entities/contacts/PetitionerCustodianContact.ts index 6eed12e188f..234ddb48c07 100644 --- a/shared/src/business/entities/contacts/PetitionerCustodianContact.ts +++ b/shared/src/business/entities/contacts/PetitionerCustodianContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PetitionerCustodianContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerCustodianContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerCustodianContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PetitionerDeceasedSpouseContact.ts b/shared/src/business/entities/contacts/PetitionerDeceasedSpouseContact.ts index 613a9b3e109..093b2016490 100644 --- a/shared/src/business/entities/contacts/PetitionerDeceasedSpouseContact.ts +++ b/shared/src/business/entities/contacts/PetitionerDeceasedSpouseContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PetitionerDeceasedSpouseContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerDeceasedSpouseContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerDeceasedSpouseContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PetitionerEstateWithExecutorPrimaryContact.ts b/shared/src/business/entities/contacts/PetitionerEstateWithExecutorPrimaryContact.ts index 044aa735f65..63c4199065c 100644 --- a/shared/src/business/entities/contacts/PetitionerEstateWithExecutorPrimaryContact.ts +++ b/shared/src/business/entities/contacts/PetitionerEstateWithExecutorPrimaryContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PetitionerEstateWithExecutorPrimaryContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerEstateWithExecutorPrimaryContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerEstateWithExecutorPrimaryContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PetitionerGuardianContact.ts b/shared/src/business/entities/contacts/PetitionerGuardianContact.ts index 22974691da4..a4c69731344 100644 --- a/shared/src/business/entities/contacts/PetitionerGuardianContact.ts +++ b/shared/src/business/entities/contacts/PetitionerGuardianContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PetitionerGuardianContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerGuardianContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerGuardianContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PetitionerIntermediaryContact.ts b/shared/src/business/entities/contacts/PetitionerIntermediaryContact.ts index 3a0dfadb018..4909a91d62c 100644 --- a/shared/src/business/entities/contacts/PetitionerIntermediaryContact.ts +++ b/shared/src/business/entities/contacts/PetitionerIntermediaryContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PetitionerIntermediaryContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerIntermediaryContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerIntermediaryContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PetitionerPrimaryContact.test.ts b/shared/src/business/entities/contacts/PetitionerPrimaryContact.test.ts index 841409237d2..d146945c2ab 100644 --- a/shared/src/business/entities/contacts/PetitionerPrimaryContact.test.ts +++ b/shared/src/business/entities/contacts/PetitionerPrimaryContact.test.ts @@ -1,25 +1,22 @@ import { CONTACT_TYPES, COUNTRY_TYPES } from '../EntityConstants'; import { PetitionerPrimaryContact } from './PetitionerPrimaryContact'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('Petition', () => { describe('for Petitioner Primary contact', () => { it('can validate primary contact name', () => { - const petition = new PetitionerPrimaryContact( - { - address1: '123 Deming Way', - city: 'Los Angeles', - contactType: CONTACT_TYPES.primary, - country: 'USA', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'petitioner@example.com', - name: 'Eric', - phone: '555-555-1212', - postalCode: '90210', - state: 'TN', - }, - { applicationContext }, - ); + const petition = new PetitionerPrimaryContact({ + address1: '123 Deming Way', + city: 'Los Angeles', + contactType: CONTACT_TYPES.primary, + country: 'USA', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'petitioner@example.com', + name: 'Eric', + phone: '555-555-1212', + postalCode: '90210', + state: 'TN', + }); + expect(petition.getFormattedValidationErrors()).toEqual(null); }); }); diff --git a/shared/src/business/entities/contacts/PetitionerPrimaryContact.ts b/shared/src/business/entities/contacts/PetitionerPrimaryContact.ts index b93ea725d26..b5d2e2b5e06 100644 --- a/shared/src/business/entities/contacts/PetitionerPrimaryContact.ts +++ b/shared/src/business/entities/contacts/PetitionerPrimaryContact.ts @@ -1,13 +1,8 @@ import { Contact } from './Contact'; export class PetitionerPrimaryContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerPrimaryContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerPrimaryContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PetitionerSpouseContact.ts b/shared/src/business/entities/contacts/PetitionerSpouseContact.ts index 152023276cb..ebe17f6c5d8 100644 --- a/shared/src/business/entities/contacts/PetitionerSpouseContact.ts +++ b/shared/src/business/entities/contacts/PetitionerSpouseContact.ts @@ -1,13 +1,8 @@ import { Contact } from './Contact'; export class PetitionerSpouseContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerSpouseContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerSpouseContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/PetitionerTrustContact.ts b/shared/src/business/entities/contacts/PetitionerTrustContact.ts index abd3c0efa86..082405e7cab 100644 --- a/shared/src/business/entities/contacts/PetitionerTrustContact.ts +++ b/shared/src/business/entities/contacts/PetitionerTrustContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class PetitionerTrustContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'PetitionerTrustContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'PetitionerTrustContact'); } getValidationRules() { diff --git a/shared/src/business/entities/contacts/SurvivingSpouseContact.ts b/shared/src/business/entities/contacts/SurvivingSpouseContact.ts index 81527e7edda..62028ae01e2 100644 --- a/shared/src/business/entities/contacts/SurvivingSpouseContact.ts +++ b/shared/src/business/entities/contacts/SurvivingSpouseContact.ts @@ -2,13 +2,8 @@ import { Contact } from './Contact'; import { JoiValidationConstants } from '../JoiValidationConstants'; export class SurvivingSpouseContact extends Contact { - constructor( - rawContact, - { applicationContext }: { applicationContext: IApplicationContext }, - ) { - super(rawContact, 'SurvivingSpouseContact', { - applicationContext, - }); + constructor(rawContact) { + super(rawContact, 'SurvivingSpouseContact'); } getValidationRules() { diff --git a/shared/src/business/useCases/startCase/validateStartCaseWizardInteractor.ts b/shared/src/business/useCases/startCase/validateStartCaseWizardInteractor.ts index 0abb5ec5608..307cca41d50 100644 --- a/shared/src/business/useCases/startCase/validateStartCaseWizardInteractor.ts +++ b/shared/src/business/useCases/startCase/validateStartCaseWizardInteractor.ts @@ -12,8 +12,8 @@ export const validateStartCaseWizardInteractor = ( applicationContext: IApplicationContext, { petition }: { petition: any }, ) => { - const errors = new ElectronicPetitionInformationFactory(petition, { - applicationContext, - }).getFormattedValidationErrors(); + const errors = new ElectronicPetitionInformationFactory( + petition, + ).getFormattedValidationErrors(); return errors || null; }; diff --git a/shared/src/business/useCases/validateAddDeficiencyStatisticsInteractor.ts b/shared/src/business/useCases/validateAddDeficiencyStatisticsInteractor.ts index a4275f6a899..f8e6607dca1 100644 --- a/shared/src/business/useCases/validateAddDeficiencyStatisticsInteractor.ts +++ b/shared/src/business/useCases/validateAddDeficiencyStatisticsInteractor.ts @@ -4,7 +4,5 @@ export const validateAddDeficiencyStatisticsInteractor = ( applicationContext: IApplicationContext, { statistic }: { statistic: any }, ) => { - return new Statistic(statistic, { - applicationContext, - }).getFormattedValidationErrors(); + return new Statistic(statistic).getFormattedValidationErrors(); }; diff --git a/shared/src/business/useCases/validateAddPetitionerInteractor.ts b/shared/src/business/useCases/validateAddPetitionerInteractor.ts index 0cb57b37030..12467a74e49 100644 --- a/shared/src/business/useCases/validateAddPetitionerInteractor.ts +++ b/shared/src/business/useCases/validateAddPetitionerInteractor.ts @@ -17,9 +17,9 @@ export const validateAddPetitionerInteractor = ( existingPetitioners, }: { contact: any; existingPetitioners?: any[] }, ) => { - const petitionerErrors = new Petitioner(contact, { - applicationContext, - }).getFormattedValidationErrors(); + const petitionerErrors = new Petitioner( + contact, + ).getFormattedValidationErrors(); let caseCaptionError; if (!contact.caseCaption) { diff --git a/shared/src/business/useCases/validatePenaltiesInteractor.ts b/shared/src/business/useCases/validatePenaltiesInteractor.ts index bdc7d7eb25b..f266fc92681 100644 --- a/shared/src/business/useCases/validatePenaltiesInteractor.ts +++ b/shared/src/business/useCases/validatePenaltiesInteractor.ts @@ -4,7 +4,5 @@ export const validatePenaltiesInteractor = ( applicationContext: IApplicationContext, { rawPenalty }: { rawPenalty: object }, ): Record | null => { - return new Penalty(rawPenalty, { - applicationContext, - }).getFormattedValidationErrors(); + return new Penalty(rawPenalty).getFormattedValidationErrors(); }; diff --git a/shared/src/business/useCases/validatePetitionInteractor.ts b/shared/src/business/useCases/validatePetitionInteractor.ts index adf58817577..72f4730b5f7 100644 --- a/shared/src/business/useCases/validatePetitionInteractor.ts +++ b/shared/src/business/useCases/validatePetitionInteractor.ts @@ -4,7 +4,5 @@ export const validatePetitionInteractor = ( applicationContext: IApplicationContext, { petition }: { petition: any }, ) => { - return new ElectronicPetition(petition, { - applicationContext, - }).getFormattedValidationErrors(); + return new ElectronicPetition(petition).getFormattedValidationErrors(); }; diff --git a/shared/src/business/useCases/validatePetitionerInformationFormInteractor.ts b/shared/src/business/useCases/validatePetitionerInformationFormInteractor.ts index e4a399befcf..9478de1b40c 100644 --- a/shared/src/business/useCases/validatePetitionerInformationFormInteractor.ts +++ b/shared/src/business/useCases/validatePetitionerInformationFormInteractor.ts @@ -25,7 +25,6 @@ export const validatePetitionerInformationFormInteractor = ( }, ) => { const contacts = ContactFactory({ - applicationContext, contactInfo: { primary: contactPrimary, secondary: contactSecondary }, partyType, }); diff --git a/shared/src/business/useCases/validatePetitionerInteractor.ts b/shared/src/business/useCases/validatePetitionerInteractor.ts index f73daf322c5..250f6d0c6ce 100644 --- a/shared/src/business/useCases/validatePetitionerInteractor.ts +++ b/shared/src/business/useCases/validatePetitionerInteractor.ts @@ -23,9 +23,9 @@ export const validatePetitionerInteractor = ( existingPetitioners: TPetitioner[]; }, ) => { - const contactErrors = new Petitioner(contactInfo, { - applicationContext, - }).getFormattedValidationErrors(); + const contactErrors = new Petitioner( + contactInfo, + ).getFormattedValidationErrors(); let updateUserEmailErrors; if (contactInfo.updatedEmail || contactInfo.confirmEmail) { diff --git a/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts b/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts index bc607ce217c..7729e8836bd 100644 --- a/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts +++ b/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts @@ -48,9 +48,7 @@ export const addPetitionerToCase = async ( caseEntity.caseCaption = caseCaption; - const petitionerEntity = new Petitioner(contact, { - applicationContext, - }); + const petitionerEntity = new Petitioner(contact); caseEntity.addPetitioner(petitionerEntity); diff --git a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts index c05dc01431f..3a7d4663687 100644 --- a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts @@ -62,19 +62,16 @@ export const addDeficiencyStatistic = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const statisticEntity = new Statistic( - { - determinationDeficiencyAmount, - determinationTotalPenalties, - irsDeficiencyAmount, - irsTotalPenalties, - lastDateOfPeriod, - penalties, - year, - yearOrPeriod, - }, - { applicationContext }, - ).validate(); + const statisticEntity = new Statistic({ + determinationDeficiencyAmount, + determinationTotalPenalties, + irsDeficiencyAmount, + irsTotalPenalties, + lastDateOfPeriod, + penalties, + year, + yearOrPeriod, + }).validate(); const newCase = new Case(oldCase, { applicationContext }); newCase.addStatistic(statisticEntity); diff --git a/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts b/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts index 56bcb204e85..73fdac65af3 100644 --- a/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts @@ -65,20 +65,17 @@ export const updateDeficiencyStatistic = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const statisticEntity = new Statistic( - { - determinationDeficiencyAmount, - determinationTotalPenalties, - irsDeficiencyAmount, - irsTotalPenalties, - lastDateOfPeriod, - penalties, - statisticId, - year, - yearOrPeriod, - }, - { applicationContext }, - ).validate(); + const statisticEntity = new Statistic({ + determinationDeficiencyAmount, + determinationTotalPenalties, + irsDeficiencyAmount, + irsTotalPenalties, + lastDateOfPeriod, + penalties, + statisticId, + year, + yearOrPeriod, + }).validate(); const newCase = new Case(oldCase, { applicationContext }); newCase.updateStatistic(statisticEntity, statisticId); diff --git a/web-api/src/business/useCases/createCaseInteractor.ts b/web-api/src/business/useCases/createCaseInteractor.ts index 6368805b671..6fe55552abd 100644 --- a/web-api/src/business/useCases/createCaseInteractor.ts +++ b/web-api/src/business/useCases/createCaseInteractor.ts @@ -91,9 +91,7 @@ export const createCaseInteractor = async ( .getPersistenceGateway() .getUserById({ applicationContext, userId: authorizedUser.userId }); - const petitionEntity = new ElectronicPetition(petitionMetadata, { - applicationContext, - }).validate(); + const petitionEntity = new ElectronicPetition(petitionMetadata).validate(); const docketNumber = await applicationContext.docketNumberGenerator.createDocketNumber({ From 84c003bcfa69dd7a0230d8b85264959fef05473f Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 3 Jul 2024 09:41:43 -0700 Subject: [PATCH 066/523] 10417: WIP Transition TrialSession away from appContext --- .../entities/cases/Case.isHearing.test.ts | 46 +- .../cases/Case.removeFromHearing.test.ts | 23 +- .../cases/Case.removeFromTrial.test.ts | 69 +-- ...removeFromTrialWithAssociatedJudge.test.ts | 46 +- .../cases/Case.setAsCalendared.test.ts | 46 +- ...Case.updateTrialSessionInformation.test.ts | 46 +- .../trialSessions/NewTrialSession.test.ts | 49 +- .../entities/trialSessions/NewTrialSession.ts | 4 +- ...ssion.IrsCalendarAdministratorInfo.test.ts | 72 +-- .../TrialSession.addCaseToCalendar.test.ts | 31 +- .../TrialSession.addPaperServicePdf.test.ts | 14 +- .../TrialSession.canSetAsCalendared.test.ts | 35 +- ...rialSession.deleteCaseFromCalendar.test.ts | 27 +- ...TrialSession.generateSortKeyPrefix.test.ts | 31 +- .../TrialSession.getEmptyFields.test.ts | 53 +- ...ialSession.isCaseAlreadyCalendared.test.ts | 40 +- ...lSession.manuallyAddCaseToCalendar.test.ts | 13 +- ...TrialSession.noticeOfTrialReminder.test.ts | 29 +- ...rialSession.removeCaseFromCalendar.test.ts | 53 +- .../TrialSession.setAsCalendared.test.ts | 14 +- .../TrialSession.setNoticesIssued.test.ts | 14 +- .../trialSessions/TrialSession.test.ts | 583 +++++++----------- ...ion.thirtyDaysBeforeTrialFormatted.test.ts | 16 +- .../entities/trialSessions/TrialSession.ts | 10 +- ...anSetTrialSessionAsCalendaredInteractor.ts | 4 +- .../validateTrialSessionInteractor.ts | 6 +- .../useCases/updateCaseContextInteractor.ts | 4 +- ...rialSessionForEnteredAndServedDocuments.ts | 4 +- .../associateSwingTrialSessions.test.ts | 4 +- .../associateSwingTrialSessions.ts | 4 +- .../createTrialSessionAndWorkingCopy.test.ts | 17 +- .../createTrialSessionAndWorkingCopy.ts | 4 +- .../addCaseToTrialSessionInteractor.ts | 4 +- .../closeTrialSessionInteractor.ts | 4 +- .../createTrialSessionInteractor.ts | 4 +- .../deleteTrialSessionInteractor.ts | 4 +- .../dismissNOTTReminderForTrialInteractor.ts | 10 +- ...esForCaseTrialSessionCalendarInteractor.ts | 4 +- ...teTrialSessionPaperServicePdfInteractor.ts | 4 +- ...tEligibleCasesForTrialSessionInteractor.ts | 4 +- .../getTrialSessionDetailsInteractor.ts | 4 +- .../getTrialSessionWorkingCopyInteractor.ts | 4 +- .../getTrialSessionsForJudgeInteractor.ts | 3 - .../getTrialSessionsInteractor.ts | 4 +- .../removeCaseFromTrialInteractor.ts | 4 +- .../saveCalendarNoteInteractor.ts | 4 +- .../serveThirtyDayNoticeInteractor.ts | 4 +- .../trialSessions/setForHearingInteractor.ts | 4 +- ...icesForCalendaredTrialSessionInteractor.ts | 4 +- .../setTrialSessionCalendarInteractor.ts | 8 +- .../updateTrialSessionInteractor.ts | 10 +- 51 files changed, 523 insertions(+), 979 deletions(-) diff --git a/shared/src/business/entities/cases/Case.isHearing.test.ts b/shared/src/business/entities/cases/Case.isHearing.test.ts index 42186fc5ea2..1f11b5e53a1 100644 --- a/shared/src/business/entities/cases/Case.isHearing.test.ts +++ b/shared/src/business/entities/cases/Case.isHearing.test.ts @@ -5,19 +5,16 @@ import { applicationContext } from '../../test/createTestApplicationContext'; describe('isHearing', () => { it('checks if the given trialSessionId is a hearing (true)', () => { - const trialSessionHearing = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSessionHearing = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); const caseToUpdate = new Case( { ...MOCK_CASE, @@ -34,19 +31,16 @@ describe('isHearing', () => { }); it('checks if the given trialSessionId is a hearing (false)', () => { - const trialSessionHearing = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSessionHearing = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); const caseToUpdate = new Case( { ...MOCK_CASE, diff --git a/shared/src/business/entities/cases/Case.removeFromHearing.test.ts b/shared/src/business/entities/cases/Case.removeFromHearing.test.ts index 3e2ea386680..dea2e1c0c0b 100644 --- a/shared/src/business/entities/cases/Case.removeFromHearing.test.ts +++ b/shared/src/business/entities/cases/Case.removeFromHearing.test.ts @@ -5,19 +5,16 @@ import { applicationContext } from '../../test/createTestApplicationContext'; describe('removeFromHearing', () => { it('removes the hearing from the case', () => { - const trialSessionHearing = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSessionHearing = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); const caseToUpdate = new Case( { ...MOCK_CASE, diff --git a/shared/src/business/entities/cases/Case.removeFromTrial.test.ts b/shared/src/business/entities/cases/Case.removeFromTrial.test.ts index 28d8fb4b96c..94add8c3dc9 100644 --- a/shared/src/business/entities/cases/Case.removeFromTrial.test.ts +++ b/shared/src/business/entities/cases/Case.removeFromTrial.test.ts @@ -14,19 +14,16 @@ describe('removeFromTrial', () => { applicationContext, }, ); - const trialSession = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch', userId: 'judge-user-id' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSession = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch', userId: 'judge-user-id' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); const user = 'Petitions Clerk'; caseToUpdate.setAsCalendared(trialSession); @@ -67,19 +64,16 @@ describe('removeFromTrial', () => { applicationContext, }, ); - const trialSession = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch', userId: 'judge-user-id' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSession = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch', userId: 'judge-user-id' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); caseToUpdate.setAsCalendared(trialSession); expect(caseToUpdate.status).toEqual(CASE_STATUS_TYPES.calendared); @@ -105,19 +99,16 @@ describe('removeFromTrial', () => { applicationContext, }, ); - const trialSession = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch', userId: 'judge-user-id' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSession = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch', userId: 'judge-user-id' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); caseToUpdate.setAsCalendared(trialSession); expect(caseToUpdate.status).toEqual(CASE_STATUS_TYPES.calendared); diff --git a/shared/src/business/entities/cases/Case.removeFromTrialWithAssociatedJudge.test.ts b/shared/src/business/entities/cases/Case.removeFromTrialWithAssociatedJudge.test.ts index 8d0a21f87e9..298cfa7831f 100644 --- a/shared/src/business/entities/cases/Case.removeFromTrialWithAssociatedJudge.test.ts +++ b/shared/src/business/entities/cases/Case.removeFromTrialWithAssociatedJudge.test.ts @@ -14,19 +14,16 @@ describe('removeFromTrialWithAssociatedJudge', () => { applicationContext, }, ); - const trialSession = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch', userId: 'buch_id' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSession = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch', userId: 'buch_id' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); caseToUpdate.setAsCalendared(trialSession); expect(caseToUpdate.status).toEqual(CASE_STATUS_TYPES.calendared); @@ -59,19 +56,16 @@ describe('removeFromTrialWithAssociatedJudge', () => { applicationContext, }, ); - const trialSession = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch', userId: 'buch-id' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSession = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch', userId: 'buch-id' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); caseToUpdate.setAsCalendared(trialSession); expect(caseToUpdate.status).toEqual(CASE_STATUS_TYPES.calendared); diff --git a/shared/src/business/entities/cases/Case.setAsCalendared.test.ts b/shared/src/business/entities/cases/Case.setAsCalendared.test.ts index f40dce69d33..726a7e5b479 100644 --- a/shared/src/business/entities/cases/Case.setAsCalendared.test.ts +++ b/shared/src/business/entities/cases/Case.setAsCalendared.test.ts @@ -29,19 +29,16 @@ describe('setAsCalendared', () => { applicationContext, }, ); - const trialSession = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch', userId: 'buch-id' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSession = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch', userId: 'buch-id' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); myCase.setAsCalendared(trialSession); expect(myCase.status).toEqual(CASE_STATUS_TYPES.calendared); @@ -62,19 +59,16 @@ describe('setAsCalendared', () => { applicationContext, }, ); - const trialSession = new TrialSession( - { - isCalendared: false, - judge: { name: 'Judge Buch', userId: 'buch-id' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSession = new TrialSession({ + isCalendared: false, + judge: { name: 'Judge Buch', userId: 'buch-id' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); myCase.setAsCalendared(trialSession); expect(myCase.status).toEqual(CASE_STATUS_TYPES.new); diff --git a/shared/src/business/entities/cases/Case.updateTrialSessionInformation.test.ts b/shared/src/business/entities/cases/Case.updateTrialSessionInformation.test.ts index 8ae07a1a495..5d608580aaa 100644 --- a/shared/src/business/entities/cases/Case.updateTrialSessionInformation.test.ts +++ b/shared/src/business/entities/cases/Case.updateTrialSessionInformation.test.ts @@ -45,19 +45,16 @@ describe('updateTrialSessionInformation', () => { applicationContext, }, ); - const trialSession = new TrialSession( - { - isCalendared: true, - judge: { name: 'Judge Buch', userId: 'buch_id' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSession = new TrialSession({ + isCalendared: true, + judge: { name: 'Judge Buch', userId: 'buch_id' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); myCase.updateTrialSessionInformation(trialSession); expect(myCase.trialDate).toBeTruthy(); @@ -77,19 +74,16 @@ describe('updateTrialSessionInformation', () => { applicationContext, }, ); - const trialSession = new TrialSession( - { - isCalendared: false, - judge: { name: 'Judge Buch' }, - maxCases: 100, - sessionType: 'Regular', - startDate: '2025-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '2025', - trialLocation: 'Birmingham, Alabama', - }, - { applicationContext }, - ); + const trialSession = new TrialSession({ + isCalendared: false, + judge: { name: 'Judge Buch' }, + maxCases: 100, + sessionType: 'Regular', + startDate: '2025-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '2025', + trialLocation: 'Birmingham, Alabama', + }); myCase.setAsCalendared(trialSession); expect(myCase.status).toEqual(CASE_STATUS_TYPES.new); diff --git a/shared/src/business/entities/trialSessions/NewTrialSession.test.ts b/shared/src/business/entities/trialSessions/NewTrialSession.test.ts index d071207bcab..6e526fc19a0 100644 --- a/shared/src/business/entities/trialSessions/NewTrialSession.test.ts +++ b/shared/src/business/entities/trialSessions/NewTrialSession.test.ts @@ -1,43 +1,28 @@ import { MOCK_NEW_TRIAL_REMOTE } from '../../../test/mockTrial'; import { NewTrialSession } from './NewTrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('NewTrialSession entity', () => { - it('should throw an error when application context is not passed in to the constructor', () => { - expect( - () => new NewTrialSession(MOCK_NEW_TRIAL_REMOTE, {} as any), - ).toThrow(); - }); - describe('isValid', () => { it('should return true when the trial session has all required and valid data', () => { - const trialSession = new NewTrialSession(MOCK_NEW_TRIAL_REMOTE, { - applicationContext, - }); + const trialSession = new NewTrialSession(MOCK_NEW_TRIAL_REMOTE); expect(trialSession.isValid()).toEqual(true); }); it('should be false when the trial session start date is in the past', () => { - const trialSession = new NewTrialSession( - { - ...MOCK_NEW_TRIAL_REMOTE, - startDate: '2000-03-01T00:00:00.000Z', - }, - { applicationContext }, - ); + const trialSession = new NewTrialSession({ + ...MOCK_NEW_TRIAL_REMOTE, + startDate: '2000-03-01T00:00:00.000Z', + }); expect(trialSession.isValid()).toEqual(false); }); it('should be false when the trial session type is not valid', () => { - const trialSession = new NewTrialSession( - { - ...MOCK_NEW_TRIAL_REMOTE, - sessionType: 'Something Else', - }, - { applicationContext }, - ); + const trialSession = new NewTrialSession({ + ...MOCK_NEW_TRIAL_REMOTE, + sessionType: 'Something Else', + }); expect(trialSession.isValid()).toEqual(false); }); @@ -45,26 +30,22 @@ describe('NewTrialSession entity', () => { describe('validate', () => { it('should do nothing when the trial session is valid', () => { - const trialSession = new NewTrialSession(MOCK_NEW_TRIAL_REMOTE, { - applicationContext, - }); + const trialSession = new NewTrialSession(MOCK_NEW_TRIAL_REMOTE); expect(() => trialSession.validate()).not.toThrow(); }); it('should throw an error when the trial session is invalid', () => { - const trialSession = new NewTrialSession({} as any, { - applicationContext, - }); + const trialSession = new NewTrialSession({} as any); expect(() => trialSession.validate()).toThrow(); }); it('should throw an error when a valid alternateTrialClerkName is not provided and only when "Other" is selected', () => { - const trialSession = new NewTrialSession( - { ...MOCK_NEW_TRIAL_REMOTE, trialClerkId: 'Other' }, - { applicationContext }, - ); + const trialSession = new NewTrialSession({ + ...MOCK_NEW_TRIAL_REMOTE, + trialClerkId: 'Other', + }); expect(() => trialSession.validate()).toThrow(); }); diff --git a/shared/src/business/entities/trialSessions/NewTrialSession.ts b/shared/src/business/entities/trialSessions/NewTrialSession.ts index 5617e0211ed..f4a9c0b907e 100644 --- a/shared/src/business/entities/trialSessions/NewTrialSession.ts +++ b/shared/src/business/entities/trialSessions/NewTrialSession.ts @@ -5,8 +5,8 @@ import joi from 'joi'; export class NewTrialSession extends TrialSession { public trialClerkId: string; - constructor(rawSession: RawNewTrialSession, { applicationContext }) { - super(rawSession, { applicationContext }); + constructor(rawSession: RawNewTrialSession) { + super(rawSession); this.trialClerkId = rawSession.trialClerkId; } diff --git a/shared/src/business/entities/trialSessions/TrialSession.IrsCalendarAdministratorInfo.test.ts b/shared/src/business/entities/trialSessions/TrialSession.IrsCalendarAdministratorInfo.test.ts index 2df9e58475b..9e4b6830f18 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.IrsCalendarAdministratorInfo.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.IrsCalendarAdministratorInfo.test.ts @@ -1,48 +1,32 @@ import { MOCK_TRIAL_REGULAR } from '@shared/test/mockTrial'; import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession.IrsCalendarAdministratorInfo', () => { it('should not throw any validation error when IrsCalendarAdministratorInfo is undefined', () => { - const entity = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - irsCalendarAdministratorInfo: undefined, - }, - { - applicationContext, - }, - ); + const entity = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + irsCalendarAdministratorInfo: undefined, + }); expect(entity.getFormattedValidationErrors()).toEqual(null); }); it('should not throw any validation error when IrsCalendarAdministratorInfo is an empty object', () => { - const entity = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - irsCalendarAdministratorInfo: {}, - }, - { - applicationContext, - }, - ); + const entity = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + irsCalendarAdministratorInfo: {}, + }); expect(entity.getFormattedValidationErrors()).toEqual(null); }); it('should return a validation error when IrsCalendarAdministratorInfo name exceeds max length', () => { - const entity = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - irsCalendarAdministratorInfo: { - name: '#'.repeat(101), - }, + const entity = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + irsCalendarAdministratorInfo: { + name: '#'.repeat(101), }, - { - applicationContext, - }, - ); + }); const validationErrors = entity.getFormattedValidationErrors(); expect(validationErrors).toEqual({ @@ -51,17 +35,12 @@ describe('TrialSession.IrsCalendarAdministratorInfo', () => { }); it('should return a validation error when IrsCalendarAdministratorInfo email exceeds max length', () => { - const entity = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - irsCalendarAdministratorInfo: { - email: '#'.repeat(101), - }, - }, - { - applicationContext, + const entity = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + irsCalendarAdministratorInfo: { + email: '#'.repeat(101), }, - ); + }); const validationErrors = entity.getFormattedValidationErrors(); expect(validationErrors).toEqual({ @@ -71,17 +50,12 @@ describe('TrialSession.IrsCalendarAdministratorInfo', () => { }); it('should return a validation error when IrsCalendarAdministratorInfo phone exceeds max length', () => { - const entity = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - irsCalendarAdministratorInfo: { - phone: '#'.repeat(101), - }, - }, - { - applicationContext, + const entity = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + irsCalendarAdministratorInfo: { + phone: '#'.repeat(101), }, - ); + }); const validationErrors = entity.getFormattedValidationErrors(); expect(validationErrors).toEqual({ diff --git a/shared/src/business/entities/trialSessions/TrialSession.addCaseToCalendar.test.ts b/shared/src/business/entities/trialSessions/TrialSession.addCaseToCalendar.test.ts index 1fb18585b6d..f50792cbedf 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.addCaseToCalendar.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.addCaseToCalendar.test.ts @@ -1,20 +1,14 @@ import { MOCK_TRIAL_INPERSON } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('addCaseToCalendar', () => { it('should add case to calendar of valid trial session when provided a raw case entity with a docketNumber', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [], - sessionType: 'Hybrid', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [], + sessionType: 'Hybrid', + }); trialSession.addCaseToCalendar({ docketNumber: '123-45' }); @@ -22,16 +16,11 @@ describe('TrialSession entity', () => { }); it('should add case to calendar once', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [], - sessionType: 'Hybrid', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [], + sessionType: 'Hybrid', + }); trialSession.addCaseToCalendar({ docketNumber: '123-45' }); trialSession.addCaseToCalendar({ docketNumber: '123-45' }); diff --git a/shared/src/business/entities/trialSessions/TrialSession.addPaperServicePdf.test.ts b/shared/src/business/entities/trialSessions/TrialSession.addPaperServicePdf.test.ts index 1c5e4f640fe..c477835ecb2 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.addPaperServicePdf.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.addPaperServicePdf.test.ts @@ -1,6 +1,5 @@ import { MOCK_TRIAL_INPERSON } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('addPaperServicePdf', () => { @@ -9,15 +8,10 @@ describe('TrialSession entity', () => { const mockPaperServicePdfTitle = '30 Day Notice of Trial on 10/12/2023 at Seattle, WA'; - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - paperServicePdfs: [], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + paperServicePdfs: [], + }); trialSession.addPaperServicePdf(mockFileId, mockPaperServicePdfTitle); diff --git a/shared/src/business/entities/trialSessions/TrialSession.canSetAsCalendared.test.ts b/shared/src/business/entities/trialSessions/TrialSession.canSetAsCalendared.test.ts index dd8ee79a96d..d653ea04013 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.canSetAsCalendared.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.canSetAsCalendared.test.ts @@ -3,50 +3,35 @@ import { MOCK_TRIAL_REMOTE, } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('canSetAsCalendared', () => { it('should be able to set a trial session as calendared when all properties are not empty for an in-person session', () => { - const trialSession = new TrialSession(MOCK_TRIAL_INPERSON, { - applicationContext, - }); + const trialSession = new TrialSession(MOCK_TRIAL_INPERSON); expect(trialSession.canSetAsCalendared()).toEqual(true); }); it('should NOT be able to set a trial session as calendared when one or more properties are empty for an in-person session', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - judge: {}, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + judge: {}, + }); expect(trialSession.canSetAsCalendared()).toEqual(false); }); it('should be able to set a trial session as calendared when all properties are not empty for a remote session', () => { - const trialSession = new TrialSession(MOCK_TRIAL_REMOTE, { - applicationContext, - }); + const trialSession = new TrialSession(MOCK_TRIAL_REMOTE); expect(trialSession.canSetAsCalendared()).toEqual(true); }); it('should NOT be able to set a trial session as calendared when one or more properties are empty for a remote session', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REMOTE, - judge: {}, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REMOTE, + judge: {}, + }); expect(trialSession.canSetAsCalendared()).toEqual(false); }); diff --git a/shared/src/business/entities/trialSessions/TrialSession.deleteCaseFromCalendar.test.ts b/shared/src/business/entities/trialSessions/TrialSession.deleteCaseFromCalendar.test.ts index 31ec8355de3..10d208b6874 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.deleteCaseFromCalendar.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.deleteCaseFromCalendar.test.ts @@ -1,19 +1,13 @@ import { MOCK_TRIAL_INPERSON } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('deleteCaseFromCalendar', () => { it('should remove the expected case from the order', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [{ docketNumber: '678-90' }, { docketNumber: '123-45' }], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [{ docketNumber: '678-90' }, { docketNumber: '123-45' }], + }); trialSession.deleteCaseFromCalendar({ docketNumber: '123-45', @@ -23,15 +17,10 @@ describe('TrialSession entity', () => { }); it('should remove the expected case from the order when there is only one entry', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [{ docketNumber: '123-45' }], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [{ docketNumber: '123-45' }], + }); trialSession.deleteCaseFromCalendar({ docketNumber: '123-45', diff --git a/shared/src/business/entities/trialSessions/TrialSession.generateSortKeyPrefix.test.ts b/shared/src/business/entities/trialSessions/TrialSession.generateSortKeyPrefix.test.ts index dffea958747..2c8ca6e15bf 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.generateSortKeyPrefix.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.generateSortKeyPrefix.test.ts @@ -1,13 +1,10 @@ import { MOCK_TRIAL_REGULAR } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('generateSortKeyPrefix', () => { it('should generate correct sort key prefix for a regular trial session', () => { - const trialSession = new TrialSession(MOCK_TRIAL_REGULAR, { - applicationContext, - }); + const trialSession = new TrialSession(MOCK_TRIAL_REGULAR); expect(trialSession.generateSortKeyPrefix()).toEqual( 'BirminghamAlabama-R', @@ -15,15 +12,10 @@ describe('TrialSession entity', () => { }); it('should generate correct sort key prefix for a small trial session', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionType: 'Small', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionType: 'Small', + }); expect(trialSession.generateSortKeyPrefix()).toEqual( 'BirminghamAlabama-S', @@ -31,15 +23,10 @@ describe('TrialSession entity', () => { }); it('should generate correct sort key prefix for a hybrid trial session', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionType: 'Hybrid', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionType: 'Hybrid', + }); expect(trialSession.generateSortKeyPrefix()).toEqual( 'BirminghamAlabama-H', diff --git a/shared/src/business/entities/trialSessions/TrialSession.getEmptyFields.test.ts b/shared/src/business/entities/trialSessions/TrialSession.getEmptyFields.test.ts index fbbc26b1802..9afcbf7ea5f 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.getEmptyFields.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.getEmptyFields.test.ts @@ -3,25 +3,19 @@ import { MOCK_TRIAL_REMOTE, } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('getEmptyFields', () => { it('should return all missing fields as a list for an in-person session', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - address1: undefined, - chambersPhoneNumber: undefined, - city: undefined, - judge: undefined, - postalCode: undefined, - state: undefined, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + address1: undefined, + chambersPhoneNumber: undefined, + city: undefined, + judge: undefined, + postalCode: undefined, + state: undefined, + }); const result = trialSession.getEmptyFields(); @@ -36,9 +30,7 @@ describe('TrialSession entity', () => { }); it('should return an empty list when all required fields as set for an in-person session', () => { - const trialSession = new TrialSession(MOCK_TRIAL_INPERSON, { - applicationContext, - }); + const trialSession = new TrialSession(MOCK_TRIAL_INPERSON); const result = trialSession.getEmptyFields(); @@ -46,19 +38,14 @@ describe('TrialSession entity', () => { }); it('should return all missing fields as a list for a remote session', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REMOTE, - chambersPhoneNumber: undefined, - joinPhoneNumber: undefined, - judge: undefined, - meetingId: undefined, - password: undefined, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REMOTE, + chambersPhoneNumber: undefined, + joinPhoneNumber: undefined, + judge: undefined, + meetingId: undefined, + password: undefined, + }); const result = trialSession.getEmptyFields(); @@ -72,9 +59,7 @@ describe('TrialSession entity', () => { }); it('should return an empty list when all required fields as set for a remote session', () => { - const trialSession = new TrialSession(MOCK_TRIAL_REMOTE, { - applicationContext, - }); + const trialSession = new TrialSession(MOCK_TRIAL_REMOTE); const result = trialSession.getEmptyFields(); diff --git a/shared/src/business/entities/trialSessions/TrialSession.isCaseAlreadyCalendared.test.ts b/shared/src/business/entities/trialSessions/TrialSession.isCaseAlreadyCalendared.test.ts index 8bb34e235c6..5f2d238715e 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.isCaseAlreadyCalendared.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.isCaseAlreadyCalendared.test.ts @@ -1,19 +1,13 @@ import { MOCK_TRIAL_INPERSON } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('isCaseAlreadyCalendared', () => { it('should return true when a case is already part of the trial session', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [{ docketNumber: '123-45' }], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [{ docketNumber: '123-45' }], + }); expect( trialSession.isCaseAlreadyCalendared({ docketNumber: '123-45' }), @@ -21,15 +15,10 @@ describe('TrialSession entity', () => { }); it('should return false when a case is not already part of the trial session', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [{ docketNumber: 'abc-de' }], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [{ docketNumber: 'abc-de' }], + }); expect( trialSession.isCaseAlreadyCalendared({ docketNumber: '123-45' }), @@ -37,15 +26,10 @@ describe('TrialSession entity', () => { }); it('should return false even for cases that have been manually removed', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [{ docketNumber: 'abc-de', removedFromTrial: true }], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [{ docketNumber: 'abc-de', removedFromTrial: true }], + }); expect( trialSession.isCaseAlreadyCalendared({ docketNumber: '123-45' }), diff --git a/shared/src/business/entities/trialSessions/TrialSession.manuallyAddCaseToCalendar.test.ts b/shared/src/business/entities/trialSessions/TrialSession.manuallyAddCaseToCalendar.test.ts index 61e7368b124..cf0711f8863 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.manuallyAddCaseToCalendar.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.manuallyAddCaseToCalendar.test.ts @@ -12,15 +12,10 @@ describe('TrialSession entity', () => { let trialSession: TrialSession; beforeEach(() => { - trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [], - }, - { - applicationContext, - }, - ); + trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [], + }); }); it('should add case to calendar of valid trial session when provided a raw case entity with a docketNumber', () => { diff --git a/shared/src/business/entities/trialSessions/TrialSession.noticeOfTrialReminder.test.ts b/shared/src/business/entities/trialSessions/TrialSession.noticeOfTrialReminder.test.ts index ecca18cbfdd..3e0ff04614b 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.noticeOfTrialReminder.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.noticeOfTrialReminder.test.ts @@ -1,6 +1,5 @@ import { MOCK_TRIAL_REGULAR } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { prepareDateFromString } from '../../utilities/DateHandler'; describe('TrialSession entity', () => { @@ -22,15 +21,10 @@ describe('TrialSession entity', () => { { daysFromToday: 35, expectedOutput: false }, ]; it('should set isStartDateWithinNOTTReminderRange to false when the trial session is not calendared', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - isCalendared: false, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + isCalendared: false, + }); expect(trialSession.isStartDateWithinNOTTReminderRange).toBe(false); }); @@ -39,16 +33,11 @@ describe('TrialSession entity', () => { it(`should set isStartDateWithinNOTTReminderRange to ${expectedOutput} when the trial session is calendared and the start date is ${daysFromToday} days from today`, () => { const thirtyDaysFromToday = today.plus({ ['days']: daysFromToday }); - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - isCalendared: true, - startDate: thirtyDaysFromToday, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + isCalendared: true, + startDate: thirtyDaysFromToday, + }); expect(trialSession.isStartDateWithinNOTTReminderRange).toBe( expectedOutput, diff --git a/shared/src/business/entities/trialSessions/TrialSession.removeCaseFromCalendar.test.ts b/shared/src/business/entities/trialSessions/TrialSession.removeCaseFromCalendar.test.ts index a09a74f8dd3..a624fcc720e 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.removeCaseFromCalendar.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.removeCaseFromCalendar.test.ts @@ -4,20 +4,14 @@ import { } from '../../../test/mockTrial'; import { SESSION_STATUS_GROUPS } from '../EntityConstants'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('removeCaseFromCalendar', () => { it('should set case on calendar to removedFromTrial with removedFromTrialDate and disposition', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [], + }); trialSession.addCaseToCalendar({ docketNumber: '123-45' }); trialSession.addCaseToCalendar({ docketNumber: '234-45' }); trialSession.addCaseToCalendar({ docketNumber: '456-45' }); @@ -40,15 +34,10 @@ describe('TrialSession entity', () => { }); it('should not modify case calendar if docketNumber is not in caseOrder', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [], + }); trialSession.addCaseToCalendar({ docketNumber: '123-45' }); trialSession.addCaseToCalendar({ docketNumber: '234-45' }); trialSession.addCaseToCalendar({ docketNumber: '456-45' }); @@ -67,15 +56,10 @@ describe('TrialSession entity', () => { }); it('should set the sessionStatus to closed when all cases on the session are removed', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - caseOrder: [], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + caseOrder: [], + }); trialSession.addCaseToCalendar({ docketNumber: '123-45' }); expect(trialSession.caseOrder!.length).toEqual(1); @@ -90,15 +74,10 @@ describe('TrialSession entity', () => { }); it('should keep the status as open when the session is standalone remote, even after removing all cases', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_STANDALONE_REMOTE, - caseOrder: [], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_STANDALONE_REMOTE, + caseOrder: [], + }); trialSession.addCaseToCalendar({ docketNumber: '123-45' }); expect(trialSession.caseOrder!.length).toEqual(1); diff --git a/shared/src/business/entities/trialSessions/TrialSession.setAsCalendared.test.ts b/shared/src/business/entities/trialSessions/TrialSession.setAsCalendared.test.ts index 41dd393f715..226fbca6261 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.setAsCalendared.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.setAsCalendared.test.ts @@ -1,19 +1,13 @@ import { MOCK_TRIAL_INPERSON } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('setAsCalendared', () => { it('should set a valid trial session entity as calendared upon request', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - isCalendared: false, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + isCalendared: false, + }); trialSession.setAsCalendared(); diff --git a/shared/src/business/entities/trialSessions/TrialSession.setNoticesIssued.test.ts b/shared/src/business/entities/trialSessions/TrialSession.setNoticesIssued.test.ts index d121223af0a..d7bbcc0f623 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.setNoticesIssued.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.setNoticesIssued.test.ts @@ -1,19 +1,13 @@ import { MOCK_TRIAL_INPERSON } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('setNoticesIssued', () => { it('should set the noticeIssuedDate on the trial session', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_INPERSON, - noticeIssuedDate: undefined, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_INPERSON, + noticeIssuedDate: undefined, + }); trialSession.setNoticesIssued(); diff --git a/shared/src/business/entities/trialSessions/TrialSession.test.ts b/shared/src/business/entities/trialSessions/TrialSession.test.ts index 0aae5932ff2..0e347122eb0 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.test.ts @@ -7,65 +7,43 @@ import { TRIAL_SESSION_SCOPE_TYPES, } from '../EntityConstants'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { - it('should throw an error when applicationContext is not passed in', () => { - expect(() => new TrialSession({}, {} as any)).toThrow(); - }); - describe('isValid', () => { it('should be true when a valid trial session is provided', () => { - const trialSession = new TrialSession(MOCK_TRIAL_REGULAR, { - applicationContext, - }); + const trialSession = new TrialSession(MOCK_TRIAL_REGULAR); expect(trialSession.isValid()).toBe(true); }); it('should be true when a valid trial session with startDate in the past is provided', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - startDate: '2000-03-01T00:00:00.000Z', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + startDate: '2000-03-01T00:00:00.000Z', + }); expect(trialSession.isValid()).toBe(true); }); it('should be false when an invalid sessionType is provided', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionType: 'Something Else', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionType: 'Something Else', + }); expect(trialSession.isValid()).toBe(false); }); it('should be false when an invalid docketNumber in caseOrder is provided', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - caseOrder: [ - { - docketNumber: 'abc', - }, - ], - sessionType: 'Something Else', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + caseOrder: [ + { + docketNumber: 'abc', + }, + ], + sessionType: 'Something Else', + }); expect(trialSession.isValid()).toBe(false); }); @@ -73,40 +51,30 @@ describe('TrialSession entity', () => { describe('isCalendared === true', () => { describe('proceedingType === "In Person"', () => { it('should be valid when isCalendared is true, proceedingType is "In Person", and optional address fields are missing', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - address1: undefined, - city: undefined, - isCalendared: true, - postalCode: undefined, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - state: undefined, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + address1: undefined, + city: undefined, + isCalendared: true, + postalCode: undefined, + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, + state: undefined, + }); expect(trialSession.isValid()).toBe(true); expect(trialSession.getFormattedValidationErrors()).toEqual(null); }); it('should be valid when isCalendared is true, proceedingType is In Person, and required address fields are defined', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - address1: '123 Flavor Ave', - city: 'Flavortown', - isCalendared: true, - postalCode: '12345', - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - state: 'TN', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + address1: '123 Flavor Ave', + city: 'Flavortown', + isCalendared: true, + postalCode: '12345', + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, + state: 'TN', + }); expect(trialSession.isValid()).toBe(true); expect(trialSession.getFormattedValidationErrors()).toEqual(null); @@ -116,21 +84,16 @@ describe('TrialSession entity', () => { describe('proceedingType === "Remote"', () => { describe(`sessionScope === ${TRIAL_SESSION_SCOPE_TYPES.locationBased}`, () => { it('should be invalid when isCalendared is true and required proceeding information fields are missing', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - chambersPhoneNumber: undefined, - isCalendared: true, - joinPhoneNumber: undefined, - meetingId: undefined, - password: undefined, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + chambersPhoneNumber: undefined, + isCalendared: true, + joinPhoneNumber: undefined, + meetingId: undefined, + password: undefined, + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + }); expect(trialSession.isValid()).toBe(false); expect(trialSession.getFormattedValidationErrors()).toMatchObject({ @@ -142,65 +105,50 @@ describe('TrialSession entity', () => { }); it('should be valid when isCalendared is true and required proceeding information fields are defined', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - chambersPhoneNumber: '1111', - isCalendared: true, - joinPhoneNumber: '222222', - meetingId: '33333', - password: '44444', - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + chambersPhoneNumber: '1111', + isCalendared: true, + joinPhoneNumber: '222222', + meetingId: '33333', + password: '44444', + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + }); expect(trialSession.isValid()).toBe(true); expect(trialSession.getFormattedValidationErrors()).toEqual(null); }); it('should be valid when isCalendared is true, sessionType is "Special" and optional proceeding information fields are missing', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - chambersPhoneNumber: undefined, - isCalendared: true, - joinPhoneNumber: undefined, - meetingId: undefined, - password: undefined, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - sessionType: SESSION_TYPES.special, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + chambersPhoneNumber: undefined, + isCalendared: true, + joinPhoneNumber: undefined, + meetingId: undefined, + password: undefined, + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + sessionType: SESSION_TYPES.special, + }); expect(trialSession.isValid()).toBe(true); expect(trialSession.getFormattedValidationErrors()).toEqual(null); }); it('should be valid when isCalendared is true, sessionType is Motion/Hearing and optional proceeding information fields are missing', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - chambersPhoneNumber: undefined, - isCalendared: true, - joinPhoneNumber: undefined, - meetingId: undefined, - password: undefined, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - sessionType: SESSION_TYPES.motionHearing, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + chambersPhoneNumber: undefined, + isCalendared: true, + joinPhoneNumber: undefined, + meetingId: undefined, + password: undefined, + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + sessionType: SESSION_TYPES.motionHearing, + }); expect(trialSession.isValid()).toBe(true); expect(trialSession.getFormattedValidationErrors()).toEqual(null); @@ -209,21 +157,16 @@ describe('TrialSession entity', () => { describe(`sessionScope === ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote}`, () => { it('should be valid when isCalendared is true and optional proceeding information fields are missing', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - chambersPhoneNumber: undefined, - isCalendared: true, - joinPhoneNumber: undefined, - meetingId: undefined, - password: undefined, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + chambersPhoneNumber: undefined, + isCalendared: true, + joinPhoneNumber: undefined, + meetingId: undefined, + password: undefined, + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, + }); expect(trialSession.isValid()).toBe(true); expect(trialSession.getFormattedValidationErrors()).toEqual(null); @@ -234,20 +177,15 @@ describe('TrialSession entity', () => { describe('proceedingType', () => { it('should be invalid when proceedingType is invalid', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - address1: '123 Flavor Ave', - city: 'Flavortown', - judge: {}, - postalCode: '12345', - proceedingType: 'NOT A VALID TYPE', - state: 'TN', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + address1: '123 Flavor Ave', + city: 'Flavortown', + judge: {}, + postalCode: '12345', + proceedingType: 'NOT A VALID TYPE', + state: 'TN', + }); expect(trialSession.isValid()).toBe(false); expect(trialSession.getFormattedValidationErrors()).toMatchObject({ @@ -256,58 +194,43 @@ describe('TrialSession entity', () => { }); it('should be valid when proceedingType is "Remote"', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - address1: '123 Flavor Ave', - city: 'Flavortown', - judge: {}, - postalCode: '12345', - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, - state: 'TN', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + address1: '123 Flavor Ave', + city: 'Flavortown', + judge: {}, + postalCode: '12345', + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, + state: 'TN', + }); expect(trialSession.isValid()).toBe(true); }); it('should be valid when proceedingType is "In Person"', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - address1: '123 Flavor Ave', - city: 'Flavortown', - judge: {}, - postalCode: '12345', - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - state: 'TN', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + address1: '123 Flavor Ave', + city: 'Flavortown', + judge: {}, + postalCode: '12345', + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, + state: 'TN', + }); expect(trialSession.isValid()).toBe(true); }); it('should be invalid when proceedingType is undefined', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - address1: '123 Flavor Ave', - city: 'Flavortown', - judge: {}, - postalCode: '12345', - proceedingType: null, - state: 'TN', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + address1: '123 Flavor Ave', + city: 'Flavortown', + judge: {}, + postalCode: '12345', + proceedingType: null, + state: 'TN', + }); expect(trialSession.isValid()).toBe(false); expect(trialSession.getFormattedValidationErrors()).toMatchObject({ @@ -318,31 +241,21 @@ describe('TrialSession entity', () => { describe('sessionScope', () => { it(`should make maxCases optional when sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote}`, () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - maxCases: undefined, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + maxCases: undefined, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, + }); expect(trialSession.isValid()).toBe(true); }); it(`should require maxCases when sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.locationBased}`, () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - maxCases: undefined, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + maxCases: undefined, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + }); expect(trialSession.isValid()).toBe(false); expect(trialSession.getFormattedValidationErrors()).toMatchObject({ @@ -351,31 +264,21 @@ describe('TrialSession entity', () => { }); it(`should make trialLocation optional when sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote}`, () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, - trialLocation: undefined, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, + trialLocation: undefined, + }); expect(trialSession.isValid()).toBe(true); }); it(`should require trialLocation when sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.locationBased}`, () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - trialLocation: undefined, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + trialLocation: undefined, + }); expect(trialSession.isValid()).toBe(false); expect(trialSession.getFormattedValidationErrors()).toMatchObject({ @@ -387,20 +290,13 @@ describe('TrialSession entity', () => { describe('validate', () => { it('should do nothing when the trialSession is valid', () => { - const trialSession = new TrialSession(MOCK_TRIAL_REGULAR, { - applicationContext, - }); + const trialSession = new TrialSession(MOCK_TRIAL_REGULAR); expect(() => trialSession.validate()).not.toThrow(); }); it('should throw an error when the trialSession is invalid', () => { - const trialSession = new TrialSession( - {}, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({}); expect(() => trialSession.validate()).toThrow(); }); @@ -408,29 +304,19 @@ describe('TrialSession entity', () => { describe('isStandaloneRemote', () => { it(`should return false when the sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.locationBased}`, () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + }); expect(trialSession.isStandaloneRemote()).toEqual(false); }); it(`should return true when the sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote}`, () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, + }); expect(trialSession.isStandaloneRemote()).toEqual(true); }); @@ -438,21 +324,16 @@ describe('TrialSession entity', () => { describe('proceedingType', () => { it(`should be ${TRIAL_SESSION_PROCEEDING_TYPES.remote} when sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote}`, () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - address1: '123 Flavor Ave', - city: 'Flavortown', - judge: {}, - postalCode: '12345', - proceedingType: undefined, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, - state: 'TN', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + address1: '123 Flavor Ave', + city: 'Flavortown', + judge: {}, + postalCode: '12345', + proceedingType: undefined, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, + state: 'TN', + }); expect(trialSession.proceedingType).toBe( TRIAL_SESSION_PROCEEDING_TYPES.remote, @@ -462,12 +343,10 @@ describe('TrialSession entity', () => { describe('sessionScope', () => { it(`should default to ${TRIAL_SESSION_SCOPE_TYPES.locationBased} when sessionScope is undefined`, () => { - const trialSession = new TrialSession( - { ...MOCK_TRIAL_REGULAR, sessionScope: undefined }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionScope: undefined, + }); expect(trialSession.sessionScope).toEqual( TRIAL_SESSION_SCOPE_TYPES.locationBased, @@ -477,16 +356,11 @@ describe('TrialSession entity', () => { describe('startTime', () => { it(`should default to "10:00" when sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.locationBased} and startTime is not provided`, () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - startTime: undefined, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + startTime: undefined, + }); expect(trialSession.startTime).toEqual('10:00'); }); @@ -494,16 +368,11 @@ describe('TrialSession entity', () => { it(`should be set to the provided value when sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.locationBased}`, () => { const mockStartTime = '12:00'; - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - startTime: mockStartTime, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + startTime: mockStartTime, + }); expect(trialSession.startTime).toEqual(mockStartTime); }); @@ -511,16 +380,11 @@ describe('TrialSession entity', () => { it(`should be set to "13:00" (1:00PM) when sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote}`, () => { const mockStartTime = '12:00'; - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, - startTime: mockStartTime, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, + startTime: mockStartTime, + }); expect(trialSession.startTime).toEqual('13:00'); }); @@ -528,16 +392,11 @@ describe('TrialSession entity', () => { describe('trialLocation', () => { it(`should be set to ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote} when sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote}`, () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, - trialLocation: undefined, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, + trialLocation: undefined, + }); expect(trialSession.trialLocation).toBe( TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, @@ -554,9 +413,6 @@ describe('TrialSession entity', () => { trialLocation: mockTrialLocation, }, // eslint-disable-next-line max-lines - { - applicationContext, - }, ); expect(trialSession.trialLocation).toBe(mockTrialLocation); @@ -572,15 +428,10 @@ describe('TrialSession entity', () => { ['days']: 34, }); - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - estimatedEndDate: incorrectEstimatedEndDate, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + estimatedEndDate: incorrectEstimatedEndDate, + }); expect(() => trialSession.validate()).toThrow(); expect(trialSession.getFormattedValidationErrors()).toMatchObject({ @@ -589,15 +440,10 @@ describe('TrialSession entity', () => { }); it('should be valid when estimatedEndDate is greater than or equal to the startDate', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - estimatedEndDate: MOCK_TRIAL_REGULAR.startDate, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + estimatedEndDate: MOCK_TRIAL_REGULAR.startDate, + }); expect(trialSession.isValid()).toBe(true); }); @@ -605,14 +451,9 @@ describe('TrialSession entity', () => { describe('dismissedAlertForNOTT', () => { it('should have a default value of false', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + }); expect(trialSession.dismissedAlertForNOTT).toBe(false); }); @@ -620,29 +461,19 @@ describe('TrialSession entity', () => { describe('paperServicePdfs', () => { it('should default to an empty array when the trial session does not already have any paper service pdfs', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - paperServicePdfs: undefined, - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + paperServicePdfs: undefined, + }); expect(trialSession.paperServicePdfs).toEqual([]); }); it('should require a fileId and title on each entry to be valid', () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - paperServicePdfs: [{}], - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + paperServicePdfs: [{}], + }); expect(trialSession.getFormattedValidationErrors()).toEqual({ fileId: '"paperServicePdfs[0].fileId" is required', diff --git a/shared/src/business/entities/trialSessions/TrialSession.thirtyDaysBeforeTrialFormatted.test.ts b/shared/src/business/entities/trialSessions/TrialSession.thirtyDaysBeforeTrialFormatted.test.ts index 510d64f3610..4e4c6d00d6e 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.thirtyDaysBeforeTrialFormatted.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.thirtyDaysBeforeTrialFormatted.test.ts @@ -1,22 +1,16 @@ import { MOCK_TRIAL_REGULAR } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('TrialSession entity', () => { describe('thirtyDaysBeforeTrialFormatted', () => { // this is how the court was calculating the duration days between dates // https://www.timeanddate.com/date/durationresult.html?m1=5&d1=17&y1=2023&m2=6&d2=15&y2=2023&ti=on it("should set thirtyDaysBeforeTrialFormatted to 30 days prior to the trial's startDate, inclusive of the startDate, when the trial session is calendared", () => { - const trialSession = new TrialSession( - { - ...MOCK_TRIAL_REGULAR, - isCalendared: true, - startDate: '2023-06-15', - }, - { - applicationContext, - }, - ); + const trialSession = new TrialSession({ + ...MOCK_TRIAL_REGULAR, + isCalendared: true, + startDate: '2023-06-15', + }); expect(trialSession.thirtyDaysBeforeTrialFormatted).toBe('05/17/23'); }); diff --git a/shared/src/business/entities/trialSessions/TrialSession.ts b/shared/src/business/entities/trialSessions/TrialSession.ts index fc3322789e5..570050287da 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.ts @@ -26,6 +26,7 @@ import { US_STATES, US_STATES_OTHER, } from '../EntityConstants'; +import { getUniqueId } from '@shared/sharedAppContext'; import { isEmpty, isEqual } from 'lodash'; import joi from 'joi'; @@ -132,13 +133,9 @@ export class TrialSession extends JoiValidationEntity { ], }; - constructor(rawSession, { applicationContext }) { + constructor(rawSession) { super('TrialSession'); - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } - this.address1 = rawSession.address1; this.address2 = rawSession.address2; this.alternateTrialClerkName = rawSession.alternateTrialClerkName; @@ -191,8 +188,7 @@ export class TrialSession extends JoiValidationEntity { this.proceedingType = this.isStandaloneRemote() ? TRIAL_SESSION_PROCEEDING_TYPES.remote : rawSession.proceedingType; - this.trialSessionId = - rawSession.trialSessionId || applicationContext.getUniqueId(); + this.trialSessionId = rawSession.trialSessionId || getUniqueId(); this.paperServicePdfs = rawSession.paperServicePdfs || []; if (rawSession.judge?.name) { diff --git a/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.ts b/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.ts index 523b8265841..b135c6ee5b4 100644 --- a/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.ts +++ b/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.ts @@ -26,9 +26,7 @@ export const canSetTrialSessionAsCalendaredInteractor = ( throw new UnauthorizedError('Unauthorized'); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); const canSetAsCalendared = trialSessionEntity.canSetAsCalendared(); const emptyFields = trialSessionEntity.getEmptyFields(); diff --git a/shared/src/business/useCases/trialSessions/validateTrialSessionInteractor.ts b/shared/src/business/useCases/trialSessions/validateTrialSessionInteractor.ts index 9ae70aa72d9..8325bff3305 100644 --- a/shared/src/business/useCases/trialSessions/validateTrialSessionInteractor.ts +++ b/shared/src/business/useCases/trialSessions/validateTrialSessionInteractor.ts @@ -15,8 +15,8 @@ export const validateTrialSessionInteractor = ( applicationContext: IApplicationContext, { trialSession }: { trialSession: RawNewTrialSession }, ) => { - const errors = new NewTrialSession(trialSession, { - applicationContext, - }).getFormattedValidationErrors(); + const errors = new NewTrialSession( + trialSession, + ).getFormattedValidationErrors(); return errors || null; }; diff --git a/shared/src/business/useCases/updateCaseContextInteractor.ts b/shared/src/business/useCases/updateCaseContextInteractor.ts index 479f435ec51..a68e7e11859 100644 --- a/shared/src/business/useCases/updateCaseContextInteractor.ts +++ b/shared/src/business/useCases/updateCaseContextInteractor.ts @@ -74,9 +74,7 @@ export const updateCaseContext = async ( ); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); trialSessionEntity.removeCaseFromCalendar({ disposition, diff --git a/web-api/src/business/useCaseHelper/docketEntry/closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments.ts b/web-api/src/business/useCaseHelper/docketEntry/closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments.ts index d021decba21..55c444af926 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments.ts @@ -39,9 +39,7 @@ export const closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments = ); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); if (trialSessionEntity.isCalendared) { trialSessionEntity.removeCaseFromCalendar({ diff --git a/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.test.ts b/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.test.ts index 291b0fb4e33..ea8cdef3abf 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.test.ts @@ -37,9 +37,7 @@ describe('associateSwingTrialSessions', () => { .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_SESSION_FOR_ASSOCIATION); - mockCurrentTrialSessionEntity = new TrialSession(MOCK_TRIAL_SESSION, { - applicationContext, - }); + mockCurrentTrialSessionEntity = new TrialSession(MOCK_TRIAL_SESSION); }); it('throws an error if user is unauthorized to associate swing sessions', async () => { diff --git a/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.ts b/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.ts index 7c993d1c297..d1a85202592 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.ts @@ -40,9 +40,7 @@ export const associateSwingTrialSessions = async ( throw new NotFoundError(`Trial session ${swingSessionId} was not found.`); } - const swingSessionEntity = new TrialSession(swingTrialSession, { - applicationContext, - }); + const swingSessionEntity = new TrialSession(swingTrialSession); trialSessionEntity.setAsSwingSession(swingSessionId); swingSessionEntity.setAsSwingSession(trialSessionEntity.trialSessionId); diff --git a/web-api/src/business/useCaseHelper/trialSessions/createTrialSessionAndWorkingCopy.test.ts b/web-api/src/business/useCaseHelper/trialSessions/createTrialSessionAndWorkingCopy.test.ts index 7d7052f26be..9b1fd9bea11 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/createTrialSessionAndWorkingCopy.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/createTrialSessionAndWorkingCopy.test.ts @@ -21,9 +21,7 @@ let trialSessionToAdd; describe('createTrialSessionAndWorkingCopy', () => { beforeEach(() => { - trialSessionToAdd = new TrialSession(trialSessionMetadata, { - applicationContext, - }); + trialSessionToAdd = new TrialSession(trialSessionMetadata); applicationContext .getPersistenceGateway() @@ -84,20 +82,15 @@ describe('createTrialSessionAndWorkingCopy', () => { await expect( createTrialSessionAndWorkingCopy({ applicationContext, - trialSessionToAdd: new TrialSession( - { - trialSessionId: 'a54ba5a9-b37b-479d-9201-067ec6e335cc', - }, - { applicationContext }, - ), + trialSessionToAdd: new TrialSession({ + trialSessionId: 'a54ba5a9-b37b-479d-9201-067ec6e335cc', + }), }), ).rejects.toThrow('The TrialSession entity was invalid'); }); it('should fail to migrate a trial session when the trialSessionId is not provided', async () => { - const trialSessionToCreate = new TrialSession(trialSessionToAdd, { - applicationContext, - }); + const trialSessionToCreate = new TrialSession(trialSessionToAdd); delete trialSessionToCreate.trialSessionId; await expect( diff --git a/web-api/src/business/useCaseHelper/trialSessions/createTrialSessionAndWorkingCopy.ts b/web-api/src/business/useCaseHelper/trialSessions/createTrialSessionAndWorkingCopy.ts index b49f1c98491..e02b2336787 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/createTrialSessionAndWorkingCopy.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/createTrialSessionAndWorkingCopy.ts @@ -52,7 +52,5 @@ export const createTrialSessionAndWorkingCopy = async ({ }); } - return new TrialSession(createdTrialSession, { applicationContext }) - .validate() - .toRawObject(); + return new TrialSession(createdTrialSession).validate().toRawObject(); }; diff --git a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts index ba495414abf..0c5464c14f6 100644 --- a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts @@ -56,9 +56,7 @@ export const addCaseToTrialSession = async ( const caseEntity = new Case(caseDetails, { applicationContext }); - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); if (caseEntity.isCalendared()) { throw new Error('The case is already calendared'); diff --git a/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.ts index 6dab1c698a2..3acf698be4f 100644 --- a/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.ts @@ -62,9 +62,7 @@ export const closeTrialSessionInteractor = async ( throw new Error('Trial session cannot be closed with open cases'); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); trialSessionEntity.setAsClosed(); diff --git a/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts index c39900d3af7..f05e110757c 100644 --- a/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts @@ -27,9 +27,7 @@ export const createTrialSessionInteractor = async ( throw new UnauthorizedError('Unauthorized'); } - const trialSessionToAdd = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionToAdd = new TrialSession(trialSession); if ( ['Motion/Hearing', 'Special'].includes(trialSessionToAdd.sessionType) || diff --git a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts index dd0ebf0526a..0f17942a7af 100644 --- a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts @@ -36,9 +36,7 @@ export const deleteTrialSessionInteractor = async ( throw new NotFoundError(`Trial session ${trialSessionId} was not found.`); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); if ( trialSessionEntity.startDate < diff --git a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts index f0195403c09..c37f4b349bf 100644 --- a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts @@ -34,12 +34,10 @@ export const dismissNOTTReminderForTrialInteractor = async ( throw new NotFoundError(`Trial session ${trialSessionId} was not found.`); } - const updatedTrialSessionEntity: TrialSession = new TrialSession( - { ...currentTrialSession, dismissedAlertForNOTT: true }, - { - applicationContext, - }, - ); + const updatedTrialSessionEntity: TrialSession = new TrialSession({ + ...currentTrialSession, + dismissedAlertForNOTT: true, + }); await applicationContext.getPersistenceGateway().updateTrialSession({ applicationContext, diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index e34211ed9b1..70b32991478 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -365,9 +365,7 @@ export const generateNoticesForCaseTrialSessionCalendarInteractor = async ( status: 'processing', }); - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); const caseRecord = await applicationContext .getPersistenceGateway() diff --git a/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.ts b/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.ts index 5f8817c7ebf..23e250dc12d 100644 --- a/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.ts @@ -92,9 +92,7 @@ export const generateTrialSessionPaperServicePdfInteractor = async ( throw new NotFoundError(`Trial session ${trialSessionId} was not found.`); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); trialSessionEntity.addPaperServicePdf(fileId, 'Initial Calendaring'); diff --git a/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.ts index 04fc22a9f04..4de085e4cc4 100644 --- a/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.ts @@ -53,9 +53,7 @@ export const getEligibleCasesForTrialSessionInteractor = async ( }); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); trialSessionEntity.validate(); diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.ts index 36ede96b20b..9becc981c83 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.ts @@ -29,9 +29,7 @@ export const getTrialSessionDetailsInteractor = async ( throw new NotFoundError(`Trial session ${trialSessionId} was not found.`); } - const trialSessionEntity = new TrialSession(trialSessionDetails, { - applicationContext, - }).validate(); + const trialSessionEntity = new TrialSession(trialSessionDetails).validate(); return trialSessionEntity.toRawObject(); }; diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.ts index edeb3ec3b49..2a984ac64bf 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.ts @@ -70,9 +70,7 @@ export const getTrialSessionWorkingCopyInteractor = async ( throw new NotFoundError(`Trial session ${trialSessionId} was not found.`); } - const trialSessionEntity = new TrialSession(trialSessionDetails, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSessionDetails); const canCreateWorkingCopy = (trialSessionEntity.trialClerk && diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.ts index 02b23af92e7..4b0f2df10a5 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.ts @@ -35,9 +35,6 @@ export const getTrialSessionsForJudgeInteractor = async ( const validatedSessions = TrialSession.validateRawCollection( judgeSessions as any, - { - applicationContext, - }, ); return validatedSessions.map( diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts index dc6b65c63ff..bef3f8fca13 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts @@ -22,9 +22,7 @@ export const getTrialSessionsInteractor = async ( applicationContext, }); - const validatedSessions = TrialSession.validateRawCollection(trialSessions, { - applicationContext, - }); + const validatedSessions = TrialSession.validateRawCollection(trialSessions); return validatedSessions.map( trialSession => new TrialSessionInfoDTO(trialSession), diff --git a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts index f160d5aa3f4..b59a06d6ff5 100644 --- a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts @@ -44,9 +44,7 @@ export const removeCaseFromTrial = async ( throw new NotFoundError(`Trial session ${trialSessionId} was not found.`); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); if (trialSessionEntity.isCalendared) { trialSessionEntity.removeCaseFromCalendar({ disposition, docketNumber }); diff --git a/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.ts b/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.ts index 9d753ae31e6..6ddc1f45c2b 100644 --- a/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.ts @@ -47,9 +47,7 @@ export const saveCalendarNoteInteractor = async ( } }); - const rawTrialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }) + const rawTrialSessionEntity = new TrialSession(trialSession) .validate() .toRawObject(); diff --git a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts index d1ef54fe170..1c3359959f4 100644 --- a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts @@ -74,9 +74,7 @@ export const serveThirtyDayNoticeInteractor = async ( return; } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); const { PDFDocument } = await applicationContext.getPdfLib(); const paperServicePdf = await PDFDocument.create(); diff --git a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts index e4b6876acae..de25936ec78 100644 --- a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts @@ -52,9 +52,7 @@ export const setForHearingInteractor = async ( const caseEntity = new Case(caseDetails, { applicationContext }); - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); const existingTrialSessionIds = []; if (caseEntity.trialSessionId) { diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts index 968ed295ac6..a5fe020750b 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts @@ -67,9 +67,7 @@ export const setNoticesForCalendaredTrialSession = async ( throw new NotFoundError(`Trial session ${trialSessionId} was not found.`); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); const trialSessionProcessingStatus = await applicationContext .getPersistenceGateway() diff --git a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts index a8820ea40f6..ca1fc645042 100644 --- a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts @@ -35,9 +35,7 @@ export const setTrialSessionCalendarInteractor = async ( throw new NotFoundError(`Trial session ${trialSessionId} was not found.`); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); trialSessionEntity.validate(); @@ -179,9 +177,7 @@ export const setTrialSessionCalendarInteractor = async ( trialSessionToUpdate: trialSessionEntity.validate().toRawObject(), }); - return new TrialSession(trialSessionEntity.toRawObject(), { - applicationContext, - }) + return new TrialSession(trialSessionEntity.toRawObject()) .validate() .toRawObject(); }; diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index 0e2e0d722b1..7de8a73246d 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -81,12 +81,10 @@ export const updateTrialSession = async ( trialLocation: trialSession.trialLocation, }; - const updatedTrialSessionEntity = new TrialSession( - { ...currentTrialSession, ...editableFields }, - { - applicationContext, - }, - ); + const updatedTrialSessionEntity = new TrialSession({ + ...currentTrialSession, + ...editableFields, + }); const shouldCreateWorkingCopyForNewJudge = (!get(currentTrialSession, 'judge.userId') && From fae40c5cb4eca0494dc6a0094055769cb972ded6 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 3 Jul 2024 09:52:35 -0700 Subject: [PATCH 067/523] 10417: WIP Transition Case away from appContext --- shared/src/business/entities/DocketEntry.ts | 3 +- shared/src/business/entities/cases/Case.ts | 108 ++++++++++-------- ...Case.updateCaseCaptionDocketRecord.test.ts | 13 ++- .../Case.updateDocketNumberRecord.test.ts | 9 +- .../serveCaseToIrsInteractor.ts | 4 +- 5 files changed, 75 insertions(+), 62 deletions(-) diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index 8102d16b8c3..8fea24f0a37 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -21,6 +21,7 @@ import { PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES, REVISED_TRANSCRIPT_EVENT_CODE, ROLES, + Role, STIN_DOCKET_ENTRY_TYPE, TRACKED_DOCUMENT_TYPES_EVENT_CODES, TRANSCRIPT_EVENT_CODE, @@ -731,7 +732,7 @@ export class DocketEntry extends JoiValidationEntity { this.numberOfPages = numberOfPages; } - setFiledBy(user: RawUser) { + setFiledBy(user: { userId: string; role: Role }): void { this.userId = user.userId; this.filedByRole = user.role; } diff --git a/shared/src/business/entities/cases/Case.ts b/shared/src/business/entities/cases/Case.ts index ea062761bb0..5c75e590cd0 100644 --- a/shared/src/business/entities/cases/Case.ts +++ b/shared/src/business/entities/cases/Case.ts @@ -27,6 +27,10 @@ import { TRIAL_CITY_STRINGS, TRIAL_LOCATION_MATCHER, } from '../EntityConstants'; +import { + AuthUser, + UnknownAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { CASE_CAPTION_RULE, CASE_DOCKET_NUMBER_RULE, @@ -64,7 +68,6 @@ import { PrivatePractitioner } from '../PrivatePractitioner'; import { PublicCase } from '@shared/business/entities/cases/PublicCase'; import { Statistic } from '../Statistic'; import { TrialSession } from '../trialSessions/TrialSession'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { UnprocessableEntityError } from '../../../../../web-api/src/errors/errors'; import { User } from '../User'; import { clone, compact, includes, isEmpty, startCase } from 'lodash'; @@ -148,50 +151,50 @@ export class Case extends JoiValidationEntity { constructor( rawCase: any, { - applicationContext, + authorizedUser, filtered = false, isNewCase = false, }: { - applicationContext: IApplicationContext; + authorizedUser: UnknownAuthUser; filtered?: boolean; isNewCase?: boolean; }, ) { super('Case'); - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } - this.petitioners = []; this.correspondence = []; - const currentUser = applicationContext.getCurrentUser(); - if (!filtered || User.isInternalUser(currentUser.role)) { + if (!filtered || User.isInternalUser(authorizedUser?.role)) { this.assignFieldsForInternalUsers({ - applicationContext, + authorizedUser, rawCase, }); } - const params = { - applicationContext, - authorizedUser: currentUser, - filtered, - rawCase, - }; - // assignContacts needs to come first before assignDocketEntries this.assignConsolidatedCases({ rawCase }); - this.assignContacts(params); - this.assignDocketEntries(params); - this.assignHearings(params); - this.assignPractitioners(params); - this.assignFieldsForAllUsers(params); + this.assignContacts({ + rawCase, + }); + this.assignDocketEntries({ + authorizedUser, + filtered, + rawCase, + }); + this.assignHearings({ + rawCase, + }); + this.assignPractitioners({ + rawCase, + }); + this.assignFieldsForAllUsers({ + rawCase, + }); if (isNewCase) { const changedBy = rawCase.isPaper - ? currentUser.name - : startCase(currentUser.role); + ? authorizedUser?.name + : startCase(authorizedUser?.role); this.setCaseStatus({ changedBy, @@ -296,7 +299,13 @@ export class Case extends JoiValidationEntity { ); } - assignFieldsForInternalUsers({ applicationContext, rawCase }) { + private assignFieldsForInternalUsers({ + authorizedUser, + rawCase, + }: { + authorizedUser: UnknownAuthUser; + rawCase: any; + }): void { this.associatedJudge = rawCase.associatedJudge || CHIEF_JUDGE; this.associatedJudgeId = rawCase.associatedJudgeId; this.automaticBlocked = rawCase.automaticBlocked; @@ -325,10 +334,10 @@ export class Case extends JoiValidationEntity { this.orderToShowCause = rawCase.orderToShowCause || false; this.assignArchivedDocketEntries({ - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, rawCase, }); - this.assignStatistics({ applicationContext, rawCase }); + this.assignStatistics({ rawCase }); this.assignCorrespondences({ rawCase }); } @@ -793,10 +802,13 @@ export class Case extends JoiValidationEntity { } private assignDocketEntries({ - applicationContext, authorizedUser, filtered, rawCase, + }: { + authorizedUser: UnknownAuthUser; + filtered: boolean; + rawCase: any; }) { if (Array.isArray(rawCase.docketEntries)) { this.docketEntries = rawCase.docketEntries @@ -814,10 +826,9 @@ export class Case extends JoiValidationEntity { if ( filtered && - applicationContext.getCurrentUser().role !== ROLES.irsSuperuser && - ((applicationContext.getCurrentUser().role !== ROLES.petitionsClerk && - applicationContext.getCurrentUser().role !== - ROLES.caseServicesSupervisor) || + authorizedUser?.role !== ROLES.irsSuperuser && + ((authorizedUser?.role !== ROLES.petitionsClerk && + authorizedUser?.role !== ROLES.caseServicesSupervisor) || this.getIrsSendDate()) ) { this.docketEntries = this.docketEntries.filter( @@ -829,10 +840,10 @@ export class Case extends JoiValidationEntity { } } - assignHearings({ applicationContext, rawCase }) { + private assignHearings({ rawCase }) { if (Array.isArray(rawCase.hearings)) { this.hearings = rawCase.hearings - .map(hearing => new TrialSession(hearing, { applicationContext })) + .map(hearing => new TrialSession(hearing)) .sort((a, b) => compareStrings(a.createdAt, b.createdAt)); } else { this.hearings = []; @@ -843,10 +854,9 @@ export class Case extends JoiValidationEntity { return this.privatePractitioners && this.privatePractitioners.length > 0; } - assignContacts({ applicationContext, rawCase }) { + private assignContacts({ rawCase }: { rawCase: any }): void { if (!rawCase.status || rawCase.status === CASE_STATUS_TYPES.new) { const contacts = ContactFactory({ - applicationContext, contactInfo: { primary: getContactPrimary(rawCase) || rawCase.contactPrimary, secondary: getContactSecondary(rawCase) || rawCase.contactSecondary, @@ -861,7 +871,7 @@ export class Case extends JoiValidationEntity { } else { if (Array.isArray(rawCase.petitioners)) { this.petitioners = rawCase.petitioners.map( - petitioner => new Petitioner(petitioner, { applicationContext }), + petitioner => new Petitioner(petitioner), ); setAdditionalNameOnPetitioners({ obj: this, rawCase }); @@ -887,10 +897,10 @@ export class Case extends JoiValidationEntity { } } - assignStatistics({ applicationContext, rawCase }) { + private assignStatistics({ rawCase }) { if (Array.isArray(rawCase.statistics)) { this.statistics = rawCase.statistics.map( - statistic => new Statistic(statistic, { applicationContext }), + statistic => new Statistic(statistic), ); } else { this.statistics = []; @@ -1126,7 +1136,11 @@ export class Case extends JoiValidationEntity { * * @returns {Case} the updated case entity */ - updateCaseCaptionDocketRecord({ applicationContext }) { + updateCaseCaptionDocketRecord({ + authorizedUser, + }: { + authorizedUser: AuthUser; + }): Case { const caseCaptionRegex = /^Caption of case is amended from '(.*)' to '(.*)'/; let lastCaption = this.initialCaption; @@ -1143,8 +1157,6 @@ export class Case extends JoiValidationEntity { this.initialCaption && lastCaption !== this.caseCaption && !this.isPaper; if (needsCaptionChangedRecord) { - const user = applicationContext.getCurrentUser(); - const mincDocketEntry = new DocketEntry( { documentTitle: `Caption of case is amended from '${lastCaption} ${CASE_CAPTION_POSTFIX}' to '${this.caseCaption} ${CASE_CAPTION_POSTFIX}'`, @@ -1155,10 +1167,10 @@ export class Case extends JoiValidationEntity { isOnDocketRecord: true, processingStatus: 'complete', }, - { authorizedUser: user, petitioners: this.petitioners }, + { authorizedUser, petitioners: this.petitioners }, ); - mincDocketEntry.setFiledBy(user); + mincDocketEntry.setFiledBy(authorizedUser); this.addDocketEntry(mincDocketEntry); } @@ -1170,7 +1182,7 @@ export class Case extends JoiValidationEntity { * * @returns {Case} the updated case entity */ - updateDocketNumberRecord({ applicationContext }) { + updateDocketNumberRecord({ authorizedUser }: { authorizedUser: AuthUser }) { const docketNumberRegex = /^Docket Number is amended from '(.*)' to '(.*)'/; let lastDocketNumber = @@ -1193,8 +1205,6 @@ export class Case extends JoiValidationEntity { lastDocketNumber !== newDocketNumber && !this.isPaper; if (needsDocketNumberChangeRecord) { - const user = applicationContext.getCurrentUser(); - const mindDocketEntry = new DocketEntry( { documentTitle: `Docket Number is amended from '${lastDocketNumber}' to '${newDocketNumber}'`, @@ -1205,10 +1215,10 @@ export class Case extends JoiValidationEntity { isOnDocketRecord: true, processingStatus: 'complete', }, - { authorizedUser: user, petitioners: this.petitioners }, + { authorizedUser, petitioners: this.petitioners }, ); - mindDocketEntry.setFiledBy(user); + mindDocketEntry.setFiledBy(authorizedUser); this.addDocketEntry(mindDocketEntry); } diff --git a/shared/src/business/entities/cases/Case.updateCaseCaptionDocketRecord.test.ts b/shared/src/business/entities/cases/Case.updateCaseCaptionDocketRecord.test.ts index de8d645e56c..5b127e4cfef 100644 --- a/shared/src/business/entities/cases/Case.updateCaseCaptionDocketRecord.test.ts +++ b/shared/src/business/entities/cases/Case.updateCaseCaptionDocketRecord.test.ts @@ -1,6 +1,7 @@ import { CASE_STATUS_TYPES } from '../EntityConstants'; import { Case } from './Case'; import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateCaseCaptionDocketRecord', () => { it('should not add a notice of caption changed document when the caption is not set', () => { @@ -10,7 +11,7 @@ describe('updateCaseCaptionDocketRecord', () => { applicationContext, }, ).updateCaseCaptionDocketRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(0); }); @@ -24,7 +25,7 @@ describe('updateCaseCaptionDocketRecord', () => { applicationContext, }, ).updateCaseCaptionDocketRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(0); }); @@ -39,7 +40,7 @@ describe('updateCaseCaptionDocketRecord', () => { applicationContext, }, ).updateCaseCaptionDocketRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(0); }); @@ -55,7 +56,7 @@ describe('updateCaseCaptionDocketRecord', () => { applicationContext, }, ).updateCaseCaptionDocketRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(1); expect(caseToVerify.docketEntries[0].eventCode).toEqual('MINC'); @@ -85,7 +86,7 @@ describe('updateCaseCaptionDocketRecord', () => { applicationContext, }, ).updateCaseCaptionDocketRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(2); }); @@ -115,7 +116,7 @@ describe('updateCaseCaptionDocketRecord', () => { applicationContext, }, ).updateCaseCaptionDocketRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(3); expect(caseToVerify.docketEntries[2]).toMatchObject({ diff --git a/shared/src/business/entities/cases/Case.updateDocketNumberRecord.test.ts b/shared/src/business/entities/cases/Case.updateDocketNumberRecord.test.ts index a6a6418ac70..0f2c6fade67 100644 --- a/shared/src/business/entities/cases/Case.updateDocketNumberRecord.test.ts +++ b/shared/src/business/entities/cases/Case.updateDocketNumberRecord.test.ts @@ -2,6 +2,7 @@ import { CASE_STATUS_TYPES, DOCKET_NUMBER_SUFFIXES } from '../EntityConstants'; import { Case } from './Case'; import { DocketEntry } from '@shared/business/entities/DocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateDocketNumberRecord records suffix changes', () => { it('should create a notice of docket number change document when the suffix updates for an electronically created case', () => { @@ -19,7 +20,7 @@ describe('updateDocketNumberRecord records suffix changes', () => { expect(caseToVerify.initialDocketNumberSuffix).toEqual('S'); caseToVerify.docketNumberSuffix = DOCKET_NUMBER_SUFFIXES.WHISTLEBLOWER; caseToVerify.updateDocketNumberRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(1); expect(caseToVerify.docketEntries[0]).toMatchObject({ @@ -44,7 +45,7 @@ describe('updateDocketNumberRecord records suffix changes', () => { ); expect(caseToVerify.initialDocketNumberSuffix).toEqual('_'); caseToVerify.updateDocketNumberRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(0); }); @@ -58,7 +59,7 @@ describe('updateDocketNumberRecord records suffix changes', () => { ); expect(caseToVerify.initialDocketNumberSuffix).toEqual('_'); caseToVerify.updateDocketNumberRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(0); }); @@ -90,7 +91,7 @@ describe('updateDocketNumberRecord records suffix changes', () => { ); caseToVerify.docketNumberSuffix = DOCKET_NUMBER_SUFFIXES.WHISTLEBLOWER; caseToVerify.updateDocketNumberRecord({ - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToVerify.docketEntries.length).toEqual(3); expect(caseToVerify.docketEntries[2].documentTitle).toEqual( diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts index afb48077f21..da3bfc0f565 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts @@ -512,8 +512,8 @@ export const serveCaseToIrs = async ( }); caseEntity - .updateCaseCaptionDocketRecord({ applicationContext }) - .updateDocketNumberRecord({ applicationContext }) + .updateCaseCaptionDocketRecord({ authorizedUser: user }) + .updateDocketNumberRecord({ authorizedUser: user }) .validate(); const generatedDocuments: Promise[] = []; From b2de6492df4c34fa0a3bae4351281de6ab5cd62e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 3 Jul 2024 09:53:19 -0700 Subject: [PATCH 068/523] 10417: docs --- docs/remove-get-current-user.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index 2b264e2e5ef..c177dead7fd 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -1,3 +1,7 @@ +# HeadSpace +- DO NOT REFACTOR +- If something seems questionable or gives a moment of pause mark with a comment: // TODO 10417 + # Web-Client Steps to transition getCurrentUser() in web-client 1. Find applicationContext.getCurrentUser() and replace with get(state.user); @@ -8,6 +12,8 @@ For Interactors that are still in shared follow the steps in the `Web-Api` secti For DocketEntry, Case, PublicCase +TODO: Look for 'extends' Classname + # Web-Api Steps To transition an interactor away from getCurrentUser() 1. Make Interactor accept a 3rd paramater called authorizedUser: UnknownAuthUser From 113ea713d38f3986c76efb57a4d93967d48d3bf8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 3 Jul 2024 11:04:41 -0700 Subject: [PATCH 069/523] 10417: WIP Transition Case away from appContext --- .../fix-race-condition-served-in-drafts.ts | 2 +- .../resend-service-email-to-irs-superuser.ts | 6 +- .../cases/Case.addCorrespondence.test.ts | 6 +- .../cases/Case.addDocketEntry.test.ts | 8 +- .../entities/cases/Case.addPetitioner.test.ts | 4 +- .../entities/cases/Case.addStatistic.test.ts | 5 +- .../cases/Case.archiveCorrespondence.test.ts | 8 +- .../cases/Case.archiveDocketEntry.test.ts | 4 +- .../cases/Case.attachIrsPractitioner.test.ts | 4 +- .../Case.attachPrivatePractitioner.test.ts | 4 +- .../cases/Case.canConsolidate.test.ts | 4 +- .../cases/Case.checkForReadyForTrial.test.ts | 14 +- .../Case.deleteCorrespondenceById.test.ts | 6 +- .../cases/Case.deleteDocketEntryById.test.ts | 6 +- .../cases/Case.deleteStatistic.test.ts | 6 +- ...Case.generateNextDocketRecordIndex.test.ts | 6 +- .../cases/Case.generateTrialSortTags.test.ts | 12 +- .../Case.getAttachmentDocumentById.test.ts | 12 +- ...seConfirmationGeneratedPdfFileName.test.ts | 4 +- .../cases/Case.getConsolidationStatus.test.ts | 5 +- .../cases/Case.getCorrespondenceById.test.ts | 4 +- .../cases/Case.getDocketEntryById.test.ts | 4 +- .../cases/Case.getIrsSendDate.test.ts | 8 +- .../cases/Case.getOtherFilers.test.ts | 4 +- .../cases/Case.getPetitionDocketEntry.test.ts | 4 +- .../cases/Case.getPetitionerByEmail.test.ts | 6 +- .../cases/Case.getPetitionerById.test.ts | 6 +- .../Case.getPractitionersRepresenting.test.ts | 6 +- .../Case.hasPartyWithServiceType.test.ts | 12 +- .../cases/Case.hasPendingItems.test.ts | 10 +- .../Case.hasPrivatePractitioners.test.ts | 6 +- .../cases/Case.isAssociatedUser.test.ts | 8 +- .../entities/cases/Case.isClosed.test.ts | 10 +- .../entities/cases/Case.isHearing.test.ts | 6 +- .../cases/Case.isPractitioner.test.ts | 8 +- ...IdRepresentedByPrivatePractitioner.test.ts | 6 +- .../cases/Case.markAsSentToIRS.test.ts | 8 +- .../cases/Case.removeConsolidation.test.ts | 4 +- .../cases/Case.removeFromHearing.test.ts | 4 +- .../cases/Case.removeFromTrial.test.ts | 8 +- ...removeFromTrialWithAssociatedJudge.test.ts | 6 +- .../cases/Case.removeIrsPractitioner.test.ts | 6 +- .../cases/Case.removePetitioner.test.ts | 6 +- .../Case.removePrivatePractitioner.test.ts | 6 +- ...emoveRepresentingFromPractitioners.test.ts | 4 +- ...ase.setAdditionalNameOnPetitioners.test.ts | 29 +-- .../entities/cases/Case.setAsBlocked.test.ts | 4 +- .../cases/Case.setAsCalendared.test.ts | 8 +- .../cases/Case.setAsHighPriority.test.ts | 4 +- .../entities/cases/Case.setAsUnsealed.test.ts | 4 +- .../cases/Case.setCaseCaption.test.ts | 4 +- .../entities/cases/Case.setCaseStatus.test.ts | 14 +- .../entities/cases/Case.setLeadCase.test.ts | 4 +- .../cases/Case.setNoticeOfTrialDate.test.ts | 13 +- .../cases/Case.setQcCompleteForTrial.test.ts | 8 +- .../Case.shouldGenerateNoticesForCase.test.ts | 10 +- .../src/business/entities/cases/Case.test.ts | 216 ++++++++---------- .../entities/cases/Case.toRawObject.test.ts | 6 +- .../cases/Case.unsetAsBlocked.test.ts | 4 +- .../cases/Case.unsetAsHighPriority.test.ts | 4 +- .../cases/Case.updateAutomaticBlocked.test.ts | 6 +- ...Case.updateCaseCaptionDocketRecord.test.ts | 13 +- .../cases/Case.updateCorrespondence.test.ts | 6 +- .../cases/Case.updateDocketEntry.test.ts | 6 +- .../Case.updateDocketNumberRecord.test.ts | 9 +- .../cases/Case.updateIrsPractitioner.test.ts | 6 +- .../cases/Case.updatePetitioner.test.ts | 12 +- .../Case.updatePrivatePractitioner.test.ts | 6 +- .../cases/Case.updateStatistic.test.ts | 6 +- ...Case.updateTrialSessionInformation.test.ts | 10 +- shared/src/test/mockAuthUsers.ts | 7 + 71 files changed, 344 insertions(+), 361 deletions(-) diff --git a/scripts/dynamo/fix-race-condition-served-in-drafts.ts b/scripts/dynamo/fix-race-condition-served-in-drafts.ts index ac2ed118c6d..796ae515325 100644 --- a/scripts/dynamo/fix-race-condition-served-in-drafts.ts +++ b/scripts/dynamo/fix-race-condition-served-in-drafts.ts @@ -68,7 +68,7 @@ export const fixRaceConditionServedInDrafts = async ( applicationContext, docketNumber, }); - const caseEntity = new Case(subjectCase, { applicationContext }); + const caseEntity = new Case(subjectCase, { authorizedUser: undefined }); const servedParties = aggregatePartiesForService(caseEntity); diff --git a/scripts/email/resend-service-email-to-irs-superuser.ts b/scripts/email/resend-service-email-to-irs-superuser.ts index e4b7b1b5f8e..e8b4cdf4c72 100644 --- a/scripts/email/resend-service-email-to-irs-superuser.ts +++ b/scripts/email/resend-service-email-to-irs-superuser.ts @@ -10,8 +10,8 @@ if (!process.argv[2] || !process.argv[3]) { import { Case } from '@shared/business/entities/cases/Case'; import { INITIAL_DOCUMENT_TYPES } from '@shared/business/entities/EntityConstants'; import { createApplicationContext } from '@web-api/applicationContext'; -import { sendIrsSuperuserPetitionEmail } from '@shared/business/useCaseHelper/service/sendIrsSuperuserPetitionEmail'; -import { sendServedPartiesEmails } from '@shared/business/useCaseHelper/service/sendServedPartiesEmails'; +import { sendIrsSuperuserPetitionEmail } from '@web-api/business/useCaseHelper/service/sendIrsSuperuserPetitionEmail'; +import { sendServedPartiesEmails } from '@web-api/business/useCaseHelper/service/sendServedPartiesEmails'; const getCase = async ( applicationContext: IApplicationContext, @@ -24,7 +24,7 @@ const getCase = async ( docketNumber, }); - return new Case(caseToBatch, { applicationContext }); + return new Case(caseToBatch, { authorizedUser: undefined }); }; const resendServiceEmail = async ( diff --git a/shared/src/business/entities/cases/Case.addCorrespondence.test.ts b/shared/src/business/entities/cases/Case.addCorrespondence.test.ts index ba74dc1c5f4..9c12be6c2a7 100644 --- a/shared/src/business/entities/cases/Case.addCorrespondence.test.ts +++ b/shared/src/business/entities/cases/Case.addCorrespondence.test.ts @@ -1,10 +1,12 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('addCorrespondence', () => { it('should successfully add correspondence', () => { - const caseEntity = new Case(MOCK_CASE, { applicationContext }); + const caseEntity = new Case(MOCK_CASE, { + authorizedUser: mockDocketClerkUser, + }); caseEntity.fileCorrespondence({ correspondenceId: 'yeehaw', diff --git a/shared/src/business/entities/cases/Case.addDocketEntry.test.ts b/shared/src/business/entities/cases/Case.addDocketEntry.test.ts index aef110eb270..bb9adcb7860 100644 --- a/shared/src/business/entities/cases/Case.addDocketEntry.test.ts +++ b/shared/src/business/entities/cases/Case.addDocketEntry.test.ts @@ -1,12 +1,12 @@ import { Case } from './Case'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('addDocketEntry', () => { it('should throw when docket entry to be added to the docket record is a STIN', () => { const caseToVerify = new Case( { docketNumber: '123-45' }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(() => { @@ -24,7 +24,7 @@ describe('addDocketEntry', () => { const caseToVerify = new Case( { docketNumber: '123-45' }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); caseToVerify.addDocketEntry({ @@ -45,7 +45,7 @@ describe('addDocketEntry', () => { const caseToVerify = new Case( { docketNumber: '123-45' }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); caseToVerify.addDocketEntry({ diff --git a/shared/src/business/entities/cases/Case.addPetitioner.test.ts b/shared/src/business/entities/cases/Case.addPetitioner.test.ts index 90bba721351..b06a2aa99ab 100644 --- a/shared/src/business/entities/cases/Case.addPetitioner.test.ts +++ b/shared/src/business/entities/cases/Case.addPetitioner.test.ts @@ -7,13 +7,13 @@ import { import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { Petitioner } from '../contacts/Petitioner'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockAdmissionsClerkUser } from '@shared/test/mockAuthUsers'; describe('addPetitioner', () => { it('should add the petitioner to the petitioners array and return the updated case', () => { const caseEntity = new Case( { ...MOCK_CASE, status: CASE_STATUS_TYPES.generalDocket }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ); const petitionerEntity = new Petitioner({ diff --git a/shared/src/business/entities/cases/Case.addStatistic.test.ts b/shared/src/business/entities/cases/Case.addStatistic.test.ts index 2a234c33804..05bdbcd0355 100644 --- a/shared/src/business/entities/cases/Case.addStatistic.test.ts +++ b/shared/src/business/entities/cases/Case.addStatistic.test.ts @@ -1,11 +1,10 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { Statistic } from '../Statistic'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('addStatistic', () => { it('should successfully add a statistic', () => { - const caseEntity = new Case(MOCK_CASE, { applicationContext }); + const caseEntity = new Case(MOCK_CASE, { authorizedUser: undefined }); const statisticToAdd = new Statistic({ determinationDeficiencyAmount: 567, @@ -28,7 +27,7 @@ describe('addStatistic', () => { ...MOCK_CASE, statistics: statisticsWithMaxLength, }, - { applicationContext }, + { authorizedUser: undefined }, ); const statisticToAdd = new Statistic({ diff --git a/shared/src/business/entities/cases/Case.archiveCorrespondence.test.ts b/shared/src/business/entities/cases/Case.archiveCorrespondence.test.ts index ef442197d04..152f586975e 100644 --- a/shared/src/business/entities/cases/Case.archiveCorrespondence.test.ts +++ b/shared/src/business/entities/cases/Case.archiveCorrespondence.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { Correspondence } from '../Correspondence'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('archiveCorrespondence', () => { let caseRecord; @@ -19,14 +19,14 @@ describe('archiveCorrespondence', () => { correspondence: [correspondenceToArchive], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); }); it('marks the correspondence document as archived', () => { caseRecord.archiveCorrespondence(correspondenceToArchive, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); const archivedDocketEntry = caseRecord.archivedCorrespondences.find( d => d.correspondenceId === correspondenceToArchive.correspondenceId, @@ -36,7 +36,7 @@ describe('archiveCorrespondence', () => { it('adds the provided document to the case archivedDocketEntries', () => { caseRecord.archiveCorrespondence(correspondenceToArchive, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect( diff --git a/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts b/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts index 68338703696..348ba74ba68 100644 --- a/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts +++ b/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts @@ -2,8 +2,8 @@ import { Case } from './Case'; import { DocketEntry } from '../DocketEntry'; import { MOCK_CASE } from '../../../test/mockCase'; import { PENDING_DOCKET_ENTRY } from '../../../test/mockDocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('archiveDocketEntry', () => { let caseRecord: Case; @@ -21,7 +21,7 @@ describe('archiveDocketEntry', () => { docketEntries: [...MOCK_CASE.docketEntries, docketEntryToArchive], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); }); diff --git a/shared/src/business/entities/cases/Case.attachIrsPractitioner.test.ts b/shared/src/business/entities/cases/Case.attachIrsPractitioner.test.ts index 2c2e6618d6f..27d04298da1 100644 --- a/shared/src/business/entities/cases/Case.attachIrsPractitioner.test.ts +++ b/shared/src/business/entities/cases/Case.attachIrsPractitioner.test.ts @@ -1,13 +1,13 @@ import { Case } from './Case'; import { IrsPractitioner } from '../IrsPractitioner'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('attachIrsPractitioner', () => { it('adds the user to the irsPractitioners', () => { const caseToVerify = new Case( {}, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); caseToVerify.attachIrsPractitioner( diff --git a/shared/src/business/entities/cases/Case.attachPrivatePractitioner.test.ts b/shared/src/business/entities/cases/Case.attachPrivatePractitioner.test.ts index dcf50e5a799..0ffa04b17f3 100644 --- a/shared/src/business/entities/cases/Case.attachPrivatePractitioner.test.ts +++ b/shared/src/business/entities/cases/Case.attachPrivatePractitioner.test.ts @@ -1,13 +1,13 @@ import { Case } from './Case'; import { PrivatePractitioner } from '../PrivatePractitioner'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('attachPrivatePractitioner', () => { it('adds the user to the privatePractitioners', () => { const caseToVerify = new Case( {}, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); caseToVerify.attachPrivatePractitioner( diff --git a/shared/src/business/entities/cases/Case.canConsolidate.test.ts b/shared/src/business/entities/cases/Case.canConsolidate.test.ts index 71110d6e27a..0f41a0b18ab 100644 --- a/shared/src/business/entities/cases/Case.canConsolidate.test.ts +++ b/shared/src/business/entities/cases/Case.canConsolidate.test.ts @@ -1,7 +1,7 @@ import { CASE_STATUS_TYPES } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('canConsolidate', () => { let caseEntity; @@ -10,7 +10,7 @@ describe('canConsolidate', () => { caseEntity = new Case( { ...MOCK_CASE, status: CASE_STATUS_TYPES.submitted }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); }); diff --git a/shared/src/business/entities/cases/Case.checkForReadyForTrial.test.ts b/shared/src/business/entities/cases/Case.checkForReadyForTrial.test.ts index 0096f3fba31..cf2d9def13c 100644 --- a/shared/src/business/entities/cases/Case.checkForReadyForTrial.test.ts +++ b/shared/src/business/entities/cases/Case.checkForReadyForTrial.test.ts @@ -4,11 +4,11 @@ import { CASE_STATUS_TYPES, } from '../EntityConstants'; import { Case } from './Case'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { calculateISODate, prepareDateFromString, } from '../../utilities/DateHandler'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('checkForReadyForTrial', () => { it('should not change the status if no answer docketEntries have been filed', () => { @@ -18,7 +18,7 @@ describe('checkForReadyForTrial', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).checkForReadyForTrial(); expect(caseToCheck.status).toEqual(CASE_STATUS_TYPES.generalDocket); @@ -36,7 +36,7 @@ describe('checkForReadyForTrial', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).checkForReadyForTrial(); expect(caseToCheck.status).toEqual(CASE_STATUS_TYPES.generalDocket); @@ -54,7 +54,7 @@ describe('checkForReadyForTrial', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).checkForReadyForTrial(); expect(caseToCheck.status).toEqual(CASE_STATUS_TYPES.generalDocket); @@ -81,7 +81,7 @@ describe('checkForReadyForTrial', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).checkForReadyForTrial(); @@ -107,7 +107,7 @@ describe('checkForReadyForTrial', () => { status: CASE_STATUS_TYPES.new, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).checkForReadyForTrial(); @@ -131,7 +131,7 @@ describe('checkForReadyForTrial', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).checkForReadyForTrial(); diff --git a/shared/src/business/entities/cases/Case.deleteCorrespondenceById.test.ts b/shared/src/business/entities/cases/Case.deleteCorrespondenceById.test.ts index 8029326bb16..49a9b14afdd 100644 --- a/shared/src/business/entities/cases/Case.deleteCorrespondenceById.test.ts +++ b/shared/src/business/entities/cases/Case.deleteCorrespondenceById.test.ts @@ -2,7 +2,7 @@ import { Case } from './Case'; import { Correspondence } from '../Correspondence'; import { MOCK_CASE } from '../../../test/mockCase'; import { MOCK_USERS } from '../../../test/mockUsers'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('deleteCorrespondenceById', () => { const mockCorrespondence = new Correspondence({ @@ -15,7 +15,7 @@ describe('deleteCorrespondenceById', () => { const myCase = new Case( { ...MOCK_CASE, correspondence: [mockCorrespondence] }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -37,7 +37,7 @@ describe('deleteCorrespondenceById', () => { const myCase = new Case( { ...MOCK_CASE, correspondence: [mockCorrespondence] }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(myCase.correspondence!.length).toEqual(1); diff --git a/shared/src/business/entities/cases/Case.deleteDocketEntryById.test.ts b/shared/src/business/entities/cases/Case.deleteDocketEntryById.test.ts index 2e187187d6d..6ab8272bc99 100644 --- a/shared/src/business/entities/cases/Case.deleteDocketEntryById.test.ts +++ b/shared/src/business/entities/cases/Case.deleteDocketEntryById.test.ts @@ -1,12 +1,12 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('deleteDocketEntryById', () => { it('should delete the document with the given id', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); const docketEntryIdToDelete = MOCK_DOCUMENTS[1].docketEntryId; expect(myCase.docketEntries.length).toEqual(4); @@ -21,7 +21,7 @@ describe('deleteDocketEntryById', () => { it('should not delete a document if a document with the given id does not exist', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); const docketEntryIdToDelete = '016fda7d-eb0a-4194-b603-ef422c898122'; expect(myCase.docketEntries.length).toEqual(4); diff --git a/shared/src/business/entities/cases/Case.deleteStatistic.test.ts b/shared/src/business/entities/cases/Case.deleteStatistic.test.ts index 34fab0c8c69..32329736d8c 100644 --- a/shared/src/business/entities/cases/Case.deleteStatistic.test.ts +++ b/shared/src/business/entities/cases/Case.deleteStatistic.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('deleteStatistic', () => { it('should successfully delete a statistic', () => { @@ -32,7 +32,7 @@ describe('deleteStatistic', () => { ...MOCK_CASE, statistics: originalStatistics, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); caseEntity.deleteStatistic(statistic0Id); @@ -70,7 +70,7 @@ describe('deleteStatistic', () => { ...MOCK_CASE, statistics: originalStatistics, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); caseEntity.deleteStatistic('16fc02bc-f00a-453c-a19c-e5597a8850ba'); diff --git a/shared/src/business/entities/cases/Case.generateNextDocketRecordIndex.test.ts b/shared/src/business/entities/cases/Case.generateNextDocketRecordIndex.test.ts index bf4110f2da7..2069073e7e5 100644 --- a/shared/src/business/entities/cases/Case.generateNextDocketRecordIndex.test.ts +++ b/shared/src/business/entities/cases/Case.generateNextDocketRecordIndex.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; describe('generateNextDocketRecordIndex', () => { it('returns the next possible index based on the current docket record array', () => { @@ -9,7 +9,7 @@ describe('generateNextDocketRecordIndex', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockPetitionsClerkUser, }, ); @@ -24,7 +24,7 @@ describe('generateNextDocketRecordIndex', () => { docketEntries: [], }, { - applicationContext, + authorizedUser: mockPetitionsClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.generateTrialSortTags.test.ts b/shared/src/business/entities/cases/Case.generateTrialSortTags.test.ts index 1c8f7a73b01..04a612c73e6 100644 --- a/shared/src/business/entities/cases/Case.generateTrialSortTags.test.ts +++ b/shared/src/business/entities/cases/Case.generateTrialSortTags.test.ts @@ -1,7 +1,7 @@ import { CASE_TYPES_MAP } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('generateTrialSortTags', () => { it('should generate sort tags for a regular case', () => { @@ -11,7 +11,7 @@ describe('generateTrialSortTags', () => { receivedAt: '2018-12-12T05:00:00.000Z', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(myCase.generateTrialSortTags()).toEqual({ @@ -28,7 +28,7 @@ describe('generateTrialSortTags', () => { receivedAt: '2018-12-12T05:00:00.000Z', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(myCase.generateTrialSortTags()).toEqual({ @@ -45,7 +45,7 @@ describe('generateTrialSortTags', () => { receivedAt: '2018-12-12T05:00:00.000Z', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(myCase.generateTrialSortTags()).toEqual({ @@ -62,7 +62,7 @@ describe('generateTrialSortTags', () => { receivedAt: '2018-12-12T05:00:00.000Z', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(myCase.generateTrialSortTags()).toEqual({ @@ -80,7 +80,7 @@ describe('generateTrialSortTags', () => { receivedAt: '2018-12-12T05:00:00.000Z', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(myCase.generateTrialSortTags()).toEqual({ diff --git a/shared/src/business/entities/cases/Case.getAttachmentDocumentById.test.ts b/shared/src/business/entities/cases/Case.getAttachmentDocumentById.test.ts index 6c6033b2095..ba5a7b22574 100644 --- a/shared/src/business/entities/cases/Case.getAttachmentDocumentById.test.ts +++ b/shared/src/business/entities/cases/Case.getAttachmentDocumentById.test.ts @@ -1,12 +1,12 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getAttachmentDocumentById', () => { it('should get a docket entry document', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); const result = Case.getAttachmentDocumentById({ caseDetail: myCase.toRawObject(), @@ -31,7 +31,7 @@ describe('getAttachmentDocumentById', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const result = Case.getAttachmentDocumentById({ @@ -49,7 +49,7 @@ describe('getAttachmentDocumentById', () => { docketEntries: [], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const result = Case.getAttachmentDocumentById({ @@ -68,7 +68,7 @@ describe('getAttachmentDocumentById', () => { docketEntries: [], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const result = Case.getAttachmentDocumentById({ @@ -94,7 +94,7 @@ describe('getAttachmentDocumentById', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const result = Case.getAttachmentDocumentById({ diff --git a/shared/src/business/entities/cases/Case.getCaseConfirmationGeneratedPdfFileName.test.ts b/shared/src/business/entities/cases/Case.getCaseConfirmationGeneratedPdfFileName.test.ts index 23e42539a57..25fcd907fc9 100644 --- a/shared/src/business/entities/cases/Case.getCaseConfirmationGeneratedPdfFileName.test.ts +++ b/shared/src/business/entities/cases/Case.getCaseConfirmationGeneratedPdfFileName.test.ts @@ -1,5 +1,5 @@ import { Case } from './Case'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getCaseConfirmationGeneratedPdfFileName', () => { it('generates the correct name for the case confirmation pdf', () => { @@ -8,7 +8,7 @@ describe('getCaseConfirmationGeneratedPdfFileName', () => { docketNumber: '123-20', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(caseToVerify.getCaseConfirmationGeneratedPdfFileName()).toEqual( diff --git a/shared/src/business/entities/cases/Case.getConsolidationStatus.test.ts b/shared/src/business/entities/cases/Case.getConsolidationStatus.test.ts index 79a2c3a24be..cd53553d36c 100644 --- a/shared/src/business/entities/cases/Case.getConsolidationStatus.test.ts +++ b/shared/src/business/entities/cases/Case.getConsolidationStatus.test.ts @@ -1,7 +1,6 @@ import { CASE_STATUS_TYPES } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; describe('getConsolidationStatus', () => { let leadCaseEntity; @@ -14,7 +13,7 @@ describe('getConsolidationStatus', () => { procedureType: 'Regular', status: CASE_STATUS_TYPES.submitted, }, - { applicationContext }, + { authorizedUser: undefined }, ); pendingCaseEntity = new Case( @@ -24,7 +23,7 @@ describe('getConsolidationStatus', () => { procedureType: 'Regular', status: CASE_STATUS_TYPES.submitted, }, - { applicationContext }, + { authorizedUser: undefined }, ); }); diff --git a/shared/src/business/entities/cases/Case.getCorrespondenceById.test.ts b/shared/src/business/entities/cases/Case.getCorrespondenceById.test.ts index f9d914bfc54..3880b18518e 100644 --- a/shared/src/business/entities/cases/Case.getCorrespondenceById.test.ts +++ b/shared/src/business/entities/cases/Case.getCorrespondenceById.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { Correspondence } from '../Correspondence'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getCorrespondenceById', () => { it('should get a correspondence document by id', () => { @@ -13,7 +13,7 @@ describe('getCorrespondenceById', () => { const myCase = new Case( { ...MOCK_CASE, correspondence: [mockCorrespondence] }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.getDocketEntryById.test.ts b/shared/src/business/entities/cases/Case.getDocketEntryById.test.ts index f2258f70f1c..4dc329c31ec 100644 --- a/shared/src/business/entities/cases/Case.getDocketEntryById.test.ts +++ b/shared/src/business/entities/cases/Case.getDocketEntryById.test.ts @@ -1,12 +1,12 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getDocketEntryById', () => { it('should get the docket entry by an Id', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); const result = myCase.getDocketEntryById({ docketEntryId: MOCK_DOCUMENTS[0].docketEntryId, diff --git a/shared/src/business/entities/cases/Case.getIrsSendDate.test.ts b/shared/src/business/entities/cases/Case.getIrsSendDate.test.ts index 14e18111bd4..1111ceaae1c 100644 --- a/shared/src/business/entities/cases/Case.getIrsSendDate.test.ts +++ b/shared/src/business/entities/cases/Case.getIrsSendDate.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getIrsSendDate', () => { it('should get the IRS send date from the petition docket entry', () => { @@ -12,7 +12,7 @@ describe('getIrsSendDate', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const result = myCase.getIrsSendDate(); @@ -26,7 +26,7 @@ describe('getIrsSendDate', () => { docketEntries: [{ documentType: 'Petition' }], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const result = myCase.getIrsSendDate(); @@ -42,7 +42,7 @@ describe('getIrsSendDate', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const result = myCase.getIrsSendDate(); diff --git a/shared/src/business/entities/cases/Case.getOtherFilers.test.ts b/shared/src/business/entities/cases/Case.getOtherFilers.test.ts index e2ac8094102..11ac88cb6ad 100644 --- a/shared/src/business/entities/cases/Case.getOtherFilers.test.ts +++ b/shared/src/business/entities/cases/Case.getOtherFilers.test.ts @@ -6,7 +6,7 @@ import { } from '../EntityConstants'; import { Case, getContactPrimary } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getOtherFilers', () => { it('sets a valid value of otherFilers on the case', () => { @@ -46,7 +46,7 @@ describe('getOtherFilers', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.getPetitionDocketEntry.test.ts b/shared/src/business/entities/cases/Case.getPetitionDocketEntry.test.ts index cbe7b477f1c..ce3aca242c3 100644 --- a/shared/src/business/entities/cases/Case.getPetitionDocketEntry.test.ts +++ b/shared/src/business/entities/cases/Case.getPetitionDocketEntry.test.ts @@ -1,12 +1,12 @@ import { Case, getPetitionDocketEntry } from './Case'; import { INITIAL_DOCUMENT_TYPES } from '../EntityConstants'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getPetitionDocketEntry', () => { it('should get the petition docket entry by documentType', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); const result = myCase.getPetitionDocketEntry(); expect(result.documentType).toEqual( diff --git a/shared/src/business/entities/cases/Case.getPetitionerByEmail.test.ts b/shared/src/business/entities/cases/Case.getPetitionerByEmail.test.ts index f12421e29c6..227e7779451 100644 --- a/shared/src/business/entities/cases/Case.getPetitionerByEmail.test.ts +++ b/shared/src/business/entities/cases/Case.getPetitionerByEmail.test.ts @@ -1,17 +1,17 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getPetitionerByEmail', () => { const mockContactEmail = 'petitioner@example.com'; it('returns petitioner with matching email from petitioners array', () => { - const myCase = new Case(MOCK_CASE, { applicationContext }); + const myCase = new Case(MOCK_CASE, { authorizedUser: mockDocketClerkUser }); expect(myCase.getPetitionerByEmail(mockContactEmail)).toBeDefined(); }); it('returns undefined if matching petitioner is not found', () => { - const myCase = new Case(MOCK_CASE, { applicationContext }); + const myCase = new Case(MOCK_CASE, { authorizedUser: mockDocketClerkUser }); expect(myCase.getPetitionerByEmail('nobody@example.com')).toBeUndefined(); }); diff --git a/shared/src/business/entities/cases/Case.getPetitionerById.test.ts b/shared/src/business/entities/cases/Case.getPetitionerById.test.ts index 485b710caed..1bdfcd0d6a4 100644 --- a/shared/src/business/entities/cases/Case.getPetitionerById.test.ts +++ b/shared/src/business/entities/cases/Case.getPetitionerById.test.ts @@ -1,6 +1,6 @@ import { Case, getContactPrimary } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getPetitionerById', () => { it('returns petitioner with matching contactId from petitioners array', () => { @@ -13,7 +13,7 @@ describe('getPetitionerById', () => { { ...getContactPrimary(MOCK_CASE), contactId: mockContactId }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.getPetitionerById(mockContactId)).toBeDefined(); @@ -32,7 +32,7 @@ describe('getPetitionerById', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.getPetitionerById(mockNonExistingContactId)).toBeUndefined(); diff --git a/shared/src/business/entities/cases/Case.getPractitionersRepresenting.test.ts b/shared/src/business/entities/cases/Case.getPractitionersRepresenting.test.ts index 9e91f3cd2ae..42a6bd11355 100644 --- a/shared/src/business/entities/cases/Case.getPractitionersRepresenting.test.ts +++ b/shared/src/business/entities/cases/Case.getPractitionersRepresenting.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getPractitionersRepresenting', () => { it('should return the practitioner associated with the contactId provided', () => { @@ -9,7 +9,7 @@ describe('getPractitionersRepresenting', () => { ...MOCK_CASE, privatePractitioners: [{ representing: ['567'], userId: '567' }], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const practitioner = caseEntity.getPractitionersRepresenting('567'); @@ -28,7 +28,7 @@ describe('getPractitionersRepresenting', () => { ...MOCK_CASE, privatePractitioners: [{ representing: ['123'], userId: '567' }], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const practitioner = caseEntity.getPractitionersRepresenting('567'); diff --git a/shared/src/business/entities/cases/Case.hasPartyWithServiceType.test.ts b/shared/src/business/entities/cases/Case.hasPartyWithServiceType.test.ts index b5273cc54e5..5718063e7cf 100644 --- a/shared/src/business/entities/cases/Case.hasPartyWithServiceType.test.ts +++ b/shared/src/business/entities/cases/Case.hasPartyWithServiceType.test.ts @@ -5,7 +5,7 @@ import { } from '../EntityConstants'; import { Case, getContactPrimary } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('hasPartyWithServiceType', () => { it('should return true if contactPrimary service indicator is paper', () => { @@ -19,7 +19,7 @@ describe('hasPartyWithServiceType', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const hasPartyWithPaperService = myCase.hasPartyWithServiceType( @@ -46,7 +46,7 @@ describe('hasPartyWithServiceType', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const hasPartyWithPaperService = myCase.hasPartyWithServiceType( @@ -68,7 +68,7 @@ describe('hasPartyWithServiceType', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const hasPartyWithPaperService = myCase.hasPartyWithServiceType( @@ -90,7 +90,7 @@ describe('hasPartyWithServiceType', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const hasPartyWithPaperService = myCase.hasPartyWithServiceType( @@ -111,7 +111,7 @@ describe('hasPartyWithServiceType', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const hasPartyWithPaperService = myCase.hasPartyWithServiceType( diff --git a/shared/src/business/entities/cases/Case.hasPendingItems.test.ts b/shared/src/business/entities/cases/Case.hasPendingItems.test.ts index 14483bb83cc..c041e9a5b15 100644 --- a/shared/src/business/entities/cases/Case.hasPendingItems.test.ts +++ b/shared/src/business/entities/cases/Case.hasPendingItems.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE, MOCK_CASE_WITHOUT_PENDING } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('hasPendingItems', () => { it('should not show the case as having pending items if no docketEntries are pending', () => { @@ -9,7 +9,7 @@ describe('hasPendingItems', () => { ...MOCK_CASE_WITHOUT_PENDING, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -30,7 +30,7 @@ describe('hasPendingItems', () => { }; const caseToUpdate = new Case(mockCase, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToUpdate.hasPendingItems).toEqual(false); @@ -51,7 +51,7 @@ describe('hasPendingItems', () => { }; const caseToUpdate = new Case(mockCase, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToUpdate.hasPendingItems).toEqual(true); @@ -73,7 +73,7 @@ describe('hasPendingItems', () => { }; const caseToUpdate = new Case(mockCase, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(caseToUpdate.hasPendingItems).toEqual(true); diff --git a/shared/src/business/entities/cases/Case.hasPrivatePractitioners.test.ts b/shared/src/business/entities/cases/Case.hasPrivatePractitioners.test.ts index d02893a4a55..cfa69ba6896 100644 --- a/shared/src/business/entities/cases/Case.hasPrivatePractitioners.test.ts +++ b/shared/src/business/entities/cases/Case.hasPrivatePractitioners.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('hasPrivatePractitioners', () => { it('returns true when there are privatePractitioners on the case', () => { @@ -31,7 +31,7 @@ describe('hasPrivatePractitioners', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -45,7 +45,7 @@ describe('hasPrivatePractitioners', () => { privatePractitioners: [], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.isAssociatedUser.test.ts b/shared/src/business/entities/cases/Case.isAssociatedUser.test.ts index 2ee6456ccf4..79a0f700c29 100644 --- a/shared/src/business/entities/cases/Case.isAssociatedUser.test.ts +++ b/shared/src/business/entities/cases/Case.isAssociatedUser.test.ts @@ -1,17 +1,13 @@ import { Case, getContactPrimary, isAssociatedUser } from './Case'; import { INITIAL_DOCUMENT_TYPES, PARTY_TYPES, ROLES } from '../EntityConstants'; import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_USERS } from '../../../test/mockUsers'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('isAssociatedUser', () => { let caseEntity; const CONTACT_ID = '3855b2dd-4094-4526-acc0-b48d7eed1f28'; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue( - MOCK_USERS['a7d90c05-f6cd-442c-a168-202db587f16f'], - ); caseEntity = new Case( { ...MOCK_CASE, @@ -28,7 +24,7 @@ describe('isAssociatedUser', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); }); diff --git a/shared/src/business/entities/cases/Case.isClosed.test.ts b/shared/src/business/entities/cases/Case.isClosed.test.ts index f46b0b34ccd..1f531046c20 100644 --- a/shared/src/business/entities/cases/Case.isClosed.test.ts +++ b/shared/src/business/entities/cases/Case.isClosed.test.ts @@ -1,14 +1,14 @@ import { CASE_STATUS_TYPES, CLOSED_CASE_STATUSES } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('isClosed', () => { it(`should return false when the case status is NOT one of ${CLOSED_CASE_STATUSES}`, () => { const caseEntity = new Case( { ...MOCK_CASE, status: CASE_STATUS_TYPES.generalDocket }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -21,7 +21,7 @@ describe('isClosed', () => { const caseEntity = new Case( { ...MOCK_CASE, status: undefined }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -34,7 +34,7 @@ describe('isClosed', () => { const caseEntity = new Case( { ...MOCK_CASE, status: CASE_STATUS_TYPES.closed }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -47,7 +47,7 @@ describe('isClosed', () => { const caseEntity = new Case( { ...MOCK_CASE, status: CASE_STATUS_TYPES.closedDismissed }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.isHearing.test.ts b/shared/src/business/entities/cases/Case.isHearing.test.ts index 1f11b5e53a1..082f8b05eb2 100644 --- a/shared/src/business/entities/cases/Case.isHearing.test.ts +++ b/shared/src/business/entities/cases/Case.isHearing.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { TrialSession } from '../trialSessions/TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('isHearing', () => { it('checks if the given trialSessionId is a hearing (true)', () => { @@ -21,7 +21,7 @@ describe('isHearing', () => { hearings: [trialSessionHearing], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -46,7 +46,7 @@ describe('isHearing', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); caseToUpdate.setAsCalendared(trialSessionHearing); diff --git a/shared/src/business/entities/cases/Case.isPractitioner.test.ts b/shared/src/business/entities/cases/Case.isPractitioner.test.ts index e7b995a2d22..23dfe251e1c 100644 --- a/shared/src/business/entities/cases/Case.isPractitioner.test.ts +++ b/shared/src/business/entities/cases/Case.isPractitioner.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_ELIGIBLE_CASE_WITH_PRACTITIONERS } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('isPractitioner', () => { it('returns true if the contactId is a privatePractitioner on the case', () => { @@ -9,7 +9,7 @@ describe('isPractitioner', () => { ...MOCK_ELIGIBLE_CASE_WITH_PRACTITIONERS, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect( @@ -23,7 +23,7 @@ describe('isPractitioner', () => { ...MOCK_ELIGIBLE_CASE_WITH_PRACTITIONERS, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect( @@ -37,7 +37,7 @@ describe('isPractitioner', () => { ...MOCK_ELIGIBLE_CASE_WITH_PRACTITIONERS, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect( diff --git a/shared/src/business/entities/cases/Case.isUserIdRepresentedByPrivatePractitioner.test.ts b/shared/src/business/entities/cases/Case.isUserIdRepresentedByPrivatePractitioner.test.ts index 693249f6016..b8f518189ec 100644 --- a/shared/src/business/entities/cases/Case.isUserIdRepresentedByPrivatePractitioner.test.ts +++ b/shared/src/business/entities/cases/Case.isUserIdRepresentedByPrivatePractitioner.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('isUserIdRepresentedByPrivatePractitioner', () => { let caseEntity; @@ -21,7 +21,7 @@ describe('isUserIdRepresentedByPrivatePractitioner', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); }); @@ -53,7 +53,7 @@ describe('isUserIdRepresentedByPrivatePractitioner', () => { privatePractitioners: undefined, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.markAsSentToIRS.test.ts b/shared/src/business/entities/cases/Case.markAsSentToIRS.test.ts index 10642a80ea0..4a98d4e76b8 100644 --- a/shared/src/business/entities/cases/Case.markAsSentToIRS.test.ts +++ b/shared/src/business/entities/cases/Case.markAsSentToIRS.test.ts @@ -4,7 +4,7 @@ import { MOCK_CASE, MOCK_CASE_WITH_SECONDARY_OTHERS, } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('markAsSentToIRS', () => { it('updates case status to general docket not at issue', () => { @@ -13,7 +13,7 @@ describe('markAsSentToIRS', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); caseRecord.markAsSentToIRS(); @@ -26,7 +26,7 @@ describe('markAsSentToIRS', () => { ...MOCK_CASE_WITH_SECONDARY_OTHERS, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -46,7 +46,7 @@ describe('markAsSentToIRS', () => { ...MOCK_CASE_WITH_SECONDARY_OTHERS, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.removeConsolidation.test.ts b/shared/src/business/entities/cases/Case.removeConsolidation.test.ts index 77ad0f178af..43559f39d03 100644 --- a/shared/src/business/entities/cases/Case.removeConsolidation.test.ts +++ b/shared/src/business/entities/cases/Case.removeConsolidation.test.ts @@ -1,7 +1,7 @@ import { CASE_STATUS_TYPES } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('removeConsolidation', () => { it('Should unset the leadDocketNumber on the given case', () => { @@ -13,7 +13,7 @@ describe('removeConsolidation', () => { procedureType: 'Regular', status: CASE_STATUS_TYPES.submitted, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const result = caseEntity.removeConsolidation(); diff --git a/shared/src/business/entities/cases/Case.removeFromHearing.test.ts b/shared/src/business/entities/cases/Case.removeFromHearing.test.ts index dea2e1c0c0b..4a89549b8d3 100644 --- a/shared/src/business/entities/cases/Case.removeFromHearing.test.ts +++ b/shared/src/business/entities/cases/Case.removeFromHearing.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { TrialSession } from '../trialSessions/TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('removeFromHearing', () => { it('removes the hearing from the case', () => { @@ -21,7 +21,7 @@ describe('removeFromHearing', () => { hearings: [trialSessionHearing], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); caseToUpdate.removeFromHearing(trialSessionHearing.trialSessionId); diff --git a/shared/src/business/entities/cases/Case.removeFromTrial.test.ts b/shared/src/business/entities/cases/Case.removeFromTrial.test.ts index 94add8c3dc9..dc50e186da8 100644 --- a/shared/src/business/entities/cases/Case.removeFromTrial.test.ts +++ b/shared/src/business/entities/cases/Case.removeFromTrial.test.ts @@ -2,7 +2,7 @@ import { CASE_STATUS_TYPES, CHIEF_JUDGE } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { TrialSession } from '../trialSessions/TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('removeFromTrial', () => { it('removes the case from trial, unsetting trial details and setting status to general docket ready for trial', () => { @@ -11,7 +11,7 @@ describe('removeFromTrial', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const trialSession = new TrialSession({ @@ -61,7 +61,7 @@ describe('removeFromTrial', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const trialSession = new TrialSession({ @@ -96,7 +96,7 @@ describe('removeFromTrial', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const trialSession = new TrialSession({ diff --git a/shared/src/business/entities/cases/Case.removeFromTrialWithAssociatedJudge.test.ts b/shared/src/business/entities/cases/Case.removeFromTrialWithAssociatedJudge.test.ts index 298cfa7831f..3f66e82b0dd 100644 --- a/shared/src/business/entities/cases/Case.removeFromTrialWithAssociatedJudge.test.ts +++ b/shared/src/business/entities/cases/Case.removeFromTrialWithAssociatedJudge.test.ts @@ -2,7 +2,7 @@ import { CASE_STATUS_TYPES } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { TrialSession } from '../trialSessions/TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('removeFromTrialWithAssociatedJudge', () => { it('removes the case from trial, updating the associated judge if one is passed in', () => { @@ -11,7 +11,7 @@ describe('removeFromTrialWithAssociatedJudge', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const trialSession = new TrialSession({ @@ -53,7 +53,7 @@ describe('removeFromTrialWithAssociatedJudge', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const trialSession = new TrialSession({ diff --git a/shared/src/business/entities/cases/Case.removeIrsPractitioner.test.ts b/shared/src/business/entities/cases/Case.removeIrsPractitioner.test.ts index 2949a1cb00e..4bb76e28c24 100644 --- a/shared/src/business/entities/cases/Case.removeIrsPractitioner.test.ts +++ b/shared/src/business/entities/cases/Case.removeIrsPractitioner.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { IrsPractitioner } from '../IrsPractitioner'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('removeIrsPractitioner', () => { it('does not remove a practitioner if not found in irsPractitioners array', () => { @@ -13,7 +13,7 @@ describe('removeIrsPractitioner', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -33,7 +33,7 @@ describe('removeIrsPractitioner', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.removePetitioner.test.ts b/shared/src/business/entities/cases/Case.removePetitioner.test.ts index 7b90cdf5e96..30cf26d6b22 100644 --- a/shared/src/business/entities/cases/Case.removePetitioner.test.ts +++ b/shared/src/business/entities/cases/Case.removePetitioner.test.ts @@ -1,10 +1,12 @@ import { Case, getContactPrimary } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockAdmissionsClerkUser } from '@shared/test/mockAuthUsers'; describe('removePetitioner', () => { it('should remove the petitioner by contactId from the petitioners array', () => { - const caseEntity = new Case(MOCK_CASE, { applicationContext }); + const caseEntity = new Case(MOCK_CASE, { + authorizedUser: mockAdmissionsClerkUser, + }); const numberOfPetitionersOnCase = caseEntity.petitioners.length; expect(caseEntity.petitioners.length).toEqual(numberOfPetitionersOnCase); diff --git a/shared/src/business/entities/cases/Case.removePrivatePractitioner.test.ts b/shared/src/business/entities/cases/Case.removePrivatePractitioner.test.ts index 9ee30840187..53324d8b77e 100644 --- a/shared/src/business/entities/cases/Case.removePrivatePractitioner.test.ts +++ b/shared/src/business/entities/cases/Case.removePrivatePractitioner.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { PrivatePractitioner } from '../PrivatePractitioner'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockAdmissionsClerkUser } from '@shared/test/mockAuthUsers'; describe('removePrivatePractitioner', () => { it('does not remove a practitioner if not found in the associated case privatePractioners array', () => { @@ -13,7 +13,7 @@ describe('removePrivatePractitioner', () => { ], }, { - applicationContext, + authorizedUser: mockAdmissionsClerkUser, }, ); @@ -34,7 +34,7 @@ describe('removePrivatePractitioner', () => { ], }, { - applicationContext, + authorizedUser: mockAdmissionsClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.removeRepresentingFromPractitioners.test.ts b/shared/src/business/entities/cases/Case.removeRepresentingFromPractitioners.test.ts index 7cc46975fc6..1d7ebb92b1f 100644 --- a/shared/src/business/entities/cases/Case.removeRepresentingFromPractitioners.test.ts +++ b/shared/src/business/entities/cases/Case.removeRepresentingFromPractitioners.test.ts @@ -1,5 +1,5 @@ import { Case } from './Case'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockAdmissionsClerkUser } from '@shared/test/mockAuthUsers'; describe('removeRepresentingFromPractitioners', () => { it('does not remove a practitioner if not found in the associated case privatePractioners array', () => { @@ -18,7 +18,7 @@ describe('removeRepresentingFromPractitioners', () => { ], }, { - applicationContext, + authorizedUser: mockAdmissionsClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.setAdditionalNameOnPetitioners.test.ts b/shared/src/business/entities/cases/Case.setAdditionalNameOnPetitioners.test.ts index 6c064579d9f..75834b3554d 100644 --- a/shared/src/business/entities/cases/Case.setAdditionalNameOnPetitioners.test.ts +++ b/shared/src/business/entities/cases/Case.setAdditionalNameOnPetitioners.test.ts @@ -2,11 +2,10 @@ import { CASE_STATUS_TYPES, CONTACT_TYPES, PARTY_TYPES, - ROLES, } from '../EntityConstants'; import { Case, getContactPrimary } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('setAdditionalNameOnPetitioners', () => { const mockSecondaryName = 'Test Secondary Name'; @@ -24,12 +23,6 @@ describe('setAdditionalNameOnPetitioners', () => { PARTY_TYPES.trust, ]; - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); - }); - partyTypesWithSecondaryName.forEach(partyType => { it(`should set additionalName as secondaryName when party type is ${partyType}`, () => { const myCase = new Case( @@ -45,7 +38,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBe(mockSecondaryName); @@ -67,7 +60,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBe( @@ -90,7 +83,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBe(mockSecondaryName); @@ -111,7 +104,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toEqual(''); @@ -131,7 +124,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBe(`c/o ${mockInCareOf}`); @@ -151,7 +144,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBe(mockSecondaryName); @@ -171,7 +164,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBe(mockSecondaryName); @@ -191,7 +184,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBe(`c/o ${mockInCareOf}`); @@ -211,7 +204,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBe(`c/o ${mockInCareOf}`); @@ -234,7 +227,7 @@ describe('setAdditionalNameOnPetitioners', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBe( diff --git a/shared/src/business/entities/cases/Case.setAsBlocked.test.ts b/shared/src/business/entities/cases/Case.setAsBlocked.test.ts index 3e5a09e1229..769283469ba 100644 --- a/shared/src/business/entities/cases/Case.setAsBlocked.test.ts +++ b/shared/src/business/entities/cases/Case.setAsBlocked.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('setAsBlocked', () => { it('sets the case as blocked with a blocked reason', () => { @@ -9,7 +9,7 @@ describe('setAsBlocked', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.setAsCalendared.test.ts b/shared/src/business/entities/cases/Case.setAsCalendared.test.ts index 726a7e5b479..797b07e18f4 100644 --- a/shared/src/business/entities/cases/Case.setAsCalendared.test.ts +++ b/shared/src/business/entities/cases/Case.setAsCalendared.test.ts @@ -2,12 +2,12 @@ import { CASE_STATUS_TYPES, CHIEF_JUDGE } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { TrialSession } from '../trialSessions/TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('setAsCalendared', () => { it('should set case as calendared with only judge and trialSessionId if the trial session is calendared', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); myCase.setAsCalendared({ isCalendared: true, @@ -26,7 +26,7 @@ describe('setAsCalendared', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const trialSession = new TrialSession({ @@ -56,7 +56,7 @@ describe('setAsCalendared', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const trialSession = new TrialSession({ diff --git a/shared/src/business/entities/cases/Case.setAsHighPriority.test.ts b/shared/src/business/entities/cases/Case.setAsHighPriority.test.ts index 8681723bc25..744731c35c5 100644 --- a/shared/src/business/entities/cases/Case.setAsHighPriority.test.ts +++ b/shared/src/business/entities/cases/Case.setAsHighPriority.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('setAsHighPriority', () => { it('sets the case as high priority with a high priority reason', () => { @@ -9,7 +9,7 @@ describe('setAsHighPriority', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.setAsUnsealed.test.ts b/shared/src/business/entities/cases/Case.setAsUnsealed.test.ts index 41e666af182..edcfbb5737e 100644 --- a/shared/src/business/entities/cases/Case.setAsUnsealed.test.ts +++ b/shared/src/business/entities/cases/Case.setAsUnsealed.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('setAsUnsealed', () => { it('should set isSealed to false and sealedDate to undefined', () => { @@ -9,7 +9,7 @@ describe('setAsUnsealed', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.setCaseCaption.test.ts b/shared/src/business/entities/cases/Case.setCaseCaption.test.ts index 7c8f03aa283..a89a0667076 100644 --- a/shared/src/business/entities/cases/Case.setCaseCaption.test.ts +++ b/shared/src/business/entities/cases/Case.setCaseCaption.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('setCaseCaption', () => { it('should set the case caption and update the case title', () => { @@ -9,7 +9,7 @@ describe('setCaseCaption', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.setCaseStatus.test.ts b/shared/src/business/entities/cases/Case.setCaseStatus.test.ts index 9c1ee103e15..ce2e3a2a5e7 100644 --- a/shared/src/business/entities/cases/Case.setCaseStatus.test.ts +++ b/shared/src/business/entities/cases/Case.setCaseStatus.test.ts @@ -5,8 +5,8 @@ import { } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { createISODateString } from '../../utilities/DateHandler'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; jest.mock('../../utilities/DateHandler', () => { const originalModule = jest.requireActual('../../utilities/DateHandler'); @@ -27,7 +27,7 @@ describe('setCaseStatus', () => { associatedJudgeId: 'judge_user_id', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -49,7 +49,7 @@ describe('setCaseStatus', () => { associatedJudgeId: 'judge_user_id', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -73,7 +73,7 @@ describe('setCaseStatus', () => { associatedJudgeId: 'judge_user_id', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -95,7 +95,7 @@ describe('setCaseStatus', () => { associatedJudgeId: 'judge_user_id', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -117,7 +117,7 @@ describe('setCaseStatus', () => { status: CLOSED_CASE_STATUSES[0], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -139,7 +139,7 @@ describe('setCaseStatus', () => { status: CLOSED_CASE_STATUSES[0], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.setLeadCase.test.ts b/shared/src/business/entities/cases/Case.setLeadCase.test.ts index 2ed31bf7566..afa7f4f84eb 100644 --- a/shared/src/business/entities/cases/Case.setLeadCase.test.ts +++ b/shared/src/business/entities/cases/Case.setLeadCase.test.ts @@ -1,7 +1,7 @@ import { CASE_STATUS_TYPES } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('setLeadCase', () => { it('Should set the leadDocketNumber on the given case', () => { @@ -13,7 +13,7 @@ describe('setLeadCase', () => { procedureType: 'Regular', status: CASE_STATUS_TYPES.submitted, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const result = caseEntity.setLeadCase(leadDocketNumber); diff --git a/shared/src/business/entities/cases/Case.setNoticeOfTrialDate.test.ts b/shared/src/business/entities/cases/Case.setNoticeOfTrialDate.test.ts index f5623c8eaae..73d558d59ee 100644 --- a/shared/src/business/entities/cases/Case.setNoticeOfTrialDate.test.ts +++ b/shared/src/business/entities/cases/Case.setNoticeOfTrialDate.test.ts @@ -1,26 +1,27 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { createISODateString } from '@shared/business/utilities/DateHandler'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('setNoticeOfTrialDate', () => { it('should set noticeOfTrialDate on the given case', () => { - const caseEntity = new Case(MOCK_CASE, { applicationContext }); + const caseEntity = new Case(MOCK_CASE, { + authorizedUser: mockDocketClerkUser, + }); const result = caseEntity.setNoticeOfTrialDate(); expect(result.isValid()).toBeTruthy(); }); it('should set noticeOfTrialDate when passed through Case constructor', () => { - const isoDateString = applicationContext - .getUtilities() - .createISODateString(); + const isoDateString = createISODateString(); const caseEntity = new Case( { ...MOCK_CASE, noticeOfTrialDate: isoDateString, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(caseEntity.isValid()).toBeTruthy(); diff --git a/shared/src/business/entities/cases/Case.setQcCompleteForTrial.test.ts b/shared/src/business/entities/cases/Case.setQcCompleteForTrial.test.ts index e92fe0ad000..dbf51768870 100644 --- a/shared/src/business/entities/cases/Case.setQcCompleteForTrial.test.ts +++ b/shared/src/business/entities/cases/Case.setQcCompleteForTrial.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('setQcCompleteForTrial', () => { it('should set qcCompleteForTrial on the given case for the given trial session id', () => { @@ -9,7 +9,7 @@ describe('setQcCompleteForTrial', () => { ...MOCK_CASE, qcCompleteForTrial: { 'd6fdd6e7-8dfa-463a-8a17-ed4512d1a68d': false }, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const result = caseEntity.setQcCompleteForTrial({ qcCompleteForTrial: true, @@ -28,7 +28,7 @@ describe('setQcCompleteForTrial', () => { { ...MOCK_CASE, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(caseEntity.isValid()).toBeTruthy(); @@ -41,7 +41,7 @@ describe('setQcCompleteForTrial', () => { ...MOCK_CASE, qcCompleteForTrial: { '80950eee-7efd-4374-a642-65a8262135ab': true }, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(caseEntity.isValid()).toBeTruthy(); diff --git a/shared/src/business/entities/cases/Case.shouldGenerateNoticesForCase.test.ts b/shared/src/business/entities/cases/Case.shouldGenerateNoticesForCase.test.ts index a6505a6fd49..52dbaab8d74 100644 --- a/shared/src/business/entities/cases/Case.shouldGenerateNoticesForCase.test.ts +++ b/shared/src/business/entities/cases/Case.shouldGenerateNoticesForCase.test.ts @@ -1,8 +1,8 @@ import { CASE_STATUS_TYPES } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { calculateISODate } from '../../utilities/DateHandler'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('shouldGenerateNoticesForCase', () => { it('checks if the case is eligible for service (true)', () => { @@ -12,7 +12,7 @@ describe('shouldGenerateNoticesForCase', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -26,7 +26,7 @@ describe('shouldGenerateNoticesForCase', () => { status: CASE_STATUS_TYPES.new, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -41,7 +41,7 @@ describe('shouldGenerateNoticesForCase', () => { status: CASE_STATUS_TYPES.closed, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -59,7 +59,7 @@ describe('shouldGenerateNoticesForCase', () => { status: CASE_STATUS_TYPES.closed, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.test.ts b/shared/src/business/entities/cases/Case.test.ts index 08f853a1eef..aa283dbd36b 100644 --- a/shared/src/business/entities/cases/Case.test.ts +++ b/shared/src/business/entities/cases/Case.test.ts @@ -10,22 +10,20 @@ import { OTHER_FILER_TYPES, PARTY_TYPES, PAYMENT_STATUS, - ROLES, SERVICE_INDICATOR_TYPES, UNIQUE_OTHER_FILER_TYPE, } from '../EntityConstants'; import { Case, getContactPrimary } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { createISODateString } from '../../utilities/DateHandler'; import { - docketClerkUser, - irsSuperuserUser, - petitionerUser, - petitionsClerkUser, - privatePractitionerUser, -} from '../../../test/mockUsers'; + mockDocketClerkUser, + mockIrsSuperuser, + mockPetitionerUser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; jest.mock('../../utilities/DateHandler', () => { const originalModule = jest.requireActual('../../utilities/DateHandler'); @@ -39,19 +37,18 @@ jest.mock('../../utilities/DateHandler', () => { describe('Case entity', () => { describe('init', () => { it('should add case status information including the internal users NAME to the `caseStatusHistory` if a new case is created by an internal user', () => { - applicationContext.getCurrentUser.mockReturnValueOnce(docketClerkUser); const mockCreateIsoDateString = createISODateString as jest.Mock; mockCreateIsoDateString.mockReturnValue('2019-08-25T05:00:00.000Z'); const expectedCaseStatus = { - changedBy: docketClerkUser.name, + changedBy: mockDocketClerkUser.name, date: createISODateString(), updatedCaseStatus: CASE_STATUS_TYPES.new, }; const myCase = new Case( { ...MOCK_CASE, isPaper: true, status: undefined }, { - applicationContext, + authorizedUser: mockDocketClerkUser, isNewCase: true, }, ); @@ -62,7 +59,6 @@ describe('Case entity', () => { }); it('should add case status information including the petitioners ROLE to the `caseStatusHistory` if a new case is created by an petitioner', () => { - applicationContext.getCurrentUser.mockReturnValueOnce(petitionerUser); const mockCreateIsoDateString = createISODateString as jest.Mock; mockCreateIsoDateString.mockReturnValue('2019-08-25T05:00:00.000Z'); @@ -74,7 +70,7 @@ describe('Case entity', () => { const myCase = new Case( { ...MOCK_CASE, isPaper: false, status: undefined }, { - applicationContext, + authorizedUser: mockPetitionerUser, isNewCase: true, }, ); @@ -85,9 +81,6 @@ describe('Case entity', () => { }); it('should add case status information including a private practitioners ROLE to the `caseStatusHistory` if a new case is created by an private practitioners', () => { - applicationContext.getCurrentUser.mockReturnValueOnce( - privatePractitionerUser, - ); const mockCreateIsoDateString = createISODateString as jest.Mock; mockCreateIsoDateString.mockReturnValue('2019-08-25T05:00:00.000Z'); @@ -99,7 +92,7 @@ describe('Case entity', () => { const myCase = new Case( { ...MOCK_CASE, isPaper: false, status: undefined }, { - applicationContext, + authorizedUser: mockPrivatePractitionerUser, isNewCase: true, }, ); @@ -109,12 +102,9 @@ describe('Case entity', () => { }); }); }); - it('should throw an error if app context is not passed in', () => { - expect(() => new Case({}, {} as any)).toThrow(); - }); it('defaults the orders to false', () => { - const myCase = new Case(MOCK_CASE, { applicationContext }); + const myCase = new Case(MOCK_CASE, { authorizedUser: mockDocketClerkUser }); expect(myCase).toMatchObject({ isSealed: false, @@ -143,7 +133,7 @@ describe('Case entity', () => { orderToShowCause: true, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -168,7 +158,7 @@ describe('Case entity', () => { { filingDate: '2019-01-05T01:02:03.004Z' }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.correspondence).toMatchObject([ @@ -191,7 +181,7 @@ describe('Case entity', () => { ], status: CASE_STATUS_TYPES.new, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBeUndefined(); @@ -216,7 +206,7 @@ describe('Case entity', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.petitioners[0].additionalName).toBeDefined(); @@ -249,7 +239,7 @@ describe('Case entity', () => { ...MOCK_CASE, hearings: [mockhearing1, mockhearing2, mockhearing3], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(newCase.hearings[0].createdAt).toEqual(mockhearing2.createdAt); @@ -262,7 +252,7 @@ describe('Case entity', () => { { ...MOCK_CASE, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(newCase.hearings).toEqual([]); @@ -271,8 +261,6 @@ describe('Case entity', () => { describe('filtered', () => { it('does not return private data if filtered is true and the user is external', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - const myCase = new Case( { ...MOCK_CASE, @@ -281,7 +269,7 @@ describe('Case entity', () => { associatedJudgeId: 'CHIEF_JUDGE_ID', }, { - applicationContext, + authorizedUser: mockPetitionerUser, filtered: true, }, ); @@ -292,8 +280,6 @@ describe('Case entity', () => { }); it('returns private data if filtered is true and the user is internal', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const myCase = new Case( { ...MOCK_CASE, @@ -302,7 +288,7 @@ describe('Case entity', () => { associatedJudgeId: 'CHIEF_JUDGE_ID', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, filtered: true, }, ); @@ -313,8 +299,6 @@ describe('Case entity', () => { }); it('returns private data if filtered is false and the user is external', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - const myCase = new Case( { ...MOCK_CASE, @@ -322,7 +306,7 @@ describe('Case entity', () => { associatedJudgeId: 'CHIEF_JUDGE_ID', }, { - applicationContext, + authorizedUser: mockPetitionerUser, filtered: false, }, ); @@ -332,8 +316,6 @@ describe('Case entity', () => { }); it('returns private data if filtered is false and the user is internal', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const myCase = new Case( { ...MOCK_CASE, @@ -341,7 +323,7 @@ describe('Case entity', () => { associatedJudgeId: 'CHIEF_JUDGE_ID', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, filtered: false, }, ); @@ -351,12 +333,10 @@ describe('Case entity', () => { }); it('returns STIN docket entry if filtered is false and the user is docketclerk', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const myCase = new Case( { ...MOCK_CASE }, { - applicationContext, + authorizedUser: mockDocketClerkUser, filtered: false, }, ); @@ -368,12 +348,10 @@ describe('Case entity', () => { }); it('returns STIN docket entry if filtered is true and the user is IRS superuser', () => { - applicationContext.getCurrentUser.mockReturnValue(irsSuperuserUser); - const myCase = new Case( { ...MOCK_CASE }, { - applicationContext, + authorizedUser: mockIrsSuperuser, filtered: true, }, ); @@ -385,12 +363,10 @@ describe('Case entity', () => { }); it('returns STIN docket entry if filtered is true and the user is petitionsclerk and the petition is not served', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - const myCase = new Case( { ...MOCK_CASE }, { - applicationContext, + authorizedUser: mockPetitionsClerkUser, filtered: true, }, ); @@ -402,12 +378,10 @@ describe('Case entity', () => { }); it('does not return STIN docket entry if filtered is true and the user is docketclerk and the petition is not served', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const myCase = new Case( { ...MOCK_CASE }, { - applicationContext, + authorizedUser: mockDocketClerkUser, filtered: true, }, ); @@ -419,8 +393,6 @@ describe('Case entity', () => { }); it('does not return STIN docket entry if filtered is true and the user is petitionsclerk and the petition is served', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - const myCase = new Case( { ...MOCK_CASE, @@ -447,7 +419,7 @@ describe('Case entity', () => { ], }, { - applicationContext, + authorizedUser: mockPetitionsClerkUser, filtered: true, }, ); @@ -500,7 +472,7 @@ describe('Case entity', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -520,7 +492,7 @@ describe('Case entity', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -529,16 +501,13 @@ describe('Case entity', () => { }); it('creates a valid case without a petition docket entry and does not throw an error', () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - }); const myCase = new Case( { ...MOCK_CASE, docketEntries: [MOCK_CASE.docketEntries[1]], }, { - applicationContext, + authorizedUser: mockPetitionsClerkUser, filtered: true, }, ); @@ -548,7 +517,7 @@ describe('Case entity', () => { it('Creates a valid case from an already existing case json', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(myCase.getFormattedValidationErrors()).toEqual(null); @@ -558,7 +527,7 @@ describe('Case entity', () => { const myCase = new Case( { ...MOCK_CASE, docketNumber: '00101-20' }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -574,7 +543,7 @@ describe('Case entity', () => { trialSessionId: undefined, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -591,7 +560,7 @@ describe('Case entity', () => { petitioners: [{}], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -610,7 +579,7 @@ describe('Case entity', () => { petitioners: [{ name: 'Test Petitioner' }], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -623,7 +592,7 @@ describe('Case entity', () => { docketEntries: [], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -634,7 +603,7 @@ describe('Case entity', () => { const myCase = new Case( {}, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -647,7 +616,7 @@ describe('Case entity', () => { petitioners: [], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -675,7 +644,7 @@ describe('Case entity', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -696,7 +665,7 @@ describe('Case entity', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -710,7 +679,7 @@ describe('Case entity', () => { trialTime: '91:30', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -724,7 +693,7 @@ describe('Case entity', () => { blocked: true, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -739,7 +708,7 @@ describe('Case entity', () => { blockedDate: '2019-03-01T21:42:29.073Z', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -755,7 +724,7 @@ describe('Case entity', () => { blockedReason: 'something', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(myCase.isValid()).toBeFalsy(); @@ -768,7 +737,7 @@ describe('Case entity', () => { blocked: false, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -784,7 +753,7 @@ describe('Case entity', () => { blockedReason: 'something', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -798,7 +767,7 @@ describe('Case entity', () => { trialTime: '9:30', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -814,7 +783,7 @@ describe('Case entity', () => { automaticBlockedReason: AUTOMATIC_BLOCKED_REASONS.pending, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -830,7 +799,7 @@ describe('Case entity', () => { automaticBlockedReason: 'Some Other Reason Not Valid', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -844,7 +813,7 @@ describe('Case entity', () => { highPriority: true, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -859,7 +828,7 @@ describe('Case entity', () => { highPriorityReason: 'something', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -873,7 +842,7 @@ describe('Case entity', () => { status: CASE_STATUS_TYPES.closed, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -890,7 +859,7 @@ describe('Case entity', () => { status: CASE_STATUS_TYPES.closedDismissed, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -908,7 +877,7 @@ describe('Case entity', () => { status: CASE_STATUS_TYPES.closed, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -922,7 +891,7 @@ describe('Case entity', () => { sealedDate: '2019-09-19T16:42:00.000Z', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -937,7 +906,7 @@ describe('Case entity', () => { petitionPaymentStatus: PAYMENT_STATUS.PAID, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -954,7 +923,7 @@ describe('Case entity', () => { petitionPaymentStatus: PAYMENT_STATUS.WAIVED, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -973,7 +942,7 @@ describe('Case entity', () => { petitionPaymentStatus: PAYMENT_STATUS.PAID, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -990,7 +959,7 @@ describe('Case entity', () => { petitionPaymentWaivedDate: '2050-10-01T21:40:46.415Z', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1004,7 +973,7 @@ describe('Case entity', () => { it('should do nothing if valid', () => { expect(() => new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }).validate(), ).not.toThrow(); }); @@ -1014,7 +983,7 @@ describe('Case entity', () => { new Case( {}, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).validate(), ).toThrow(); @@ -1028,7 +997,7 @@ describe('Case entity', () => { petitioners: [], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1068,7 +1037,7 @@ describe('Case entity', () => { petitioners: [], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1098,7 +1067,7 @@ describe('Case entity', () => { consolidatedCases: [invalidConsolidatedCase], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1114,7 +1083,7 @@ describe('Case entity', () => { associatedJudgeId: undefined, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1130,7 +1099,7 @@ describe('Case entity', () => { associatedJudgeId: undefined, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1146,7 +1115,7 @@ describe('Case entity', () => { associatedJudgeId: 'dabbad02-18d0-43ec-bafb-654e83405416', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1162,7 +1131,7 @@ describe('Case entity', () => { associatedJudgeId: 'uuid', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1179,7 +1148,7 @@ describe('Case entity', () => { associatedJudgeId: undefined, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1196,7 +1165,9 @@ describe('Case entity', () => { ...MOCK_CASE, trialSessionId: '0762e545-8cbc-4a18-ab7a-27d205c83f60', }; - const myCase = new Case(blockedCalendaredCase, { applicationContext }); + const myCase = new Case(blockedCalendaredCase, { + authorizedUser: mockDocketClerkUser, + }); expect(myCase.getFormattedValidationErrors()).toEqual({ trialDate: '"trialDate" is required', }); @@ -1208,7 +1179,9 @@ describe('Case entity', () => { status: CASE_STATUS_TYPES.calendared, trialDate: '2019-03-01T21:40:46.415Z', }; - const myCase = new Case(blockedCalendaredCase, { applicationContext }); + const myCase = new Case(blockedCalendaredCase, { + authorizedUser: mockDocketClerkUser, + }); expect(myCase.getFormattedValidationErrors()).toEqual({ trialSessionId: '"trialSessionId" is required', }); @@ -1221,7 +1194,9 @@ describe('Case entity', () => { trialDate: undefined, trialSessionId: undefined, }; - const myCase = new Case(blockedCalendaredCase, { applicationContext }); + const myCase = new Case(blockedCalendaredCase, { + authorizedUser: mockDocketClerkUser, + }); expect(myCase.getFormattedValidationErrors()).toBe(null); }); @@ -1232,7 +1207,9 @@ describe('Case entity', () => { trialDate: '2019-03-01T21:40:46.415Z', trialSessionId: '0762e545-8cbc-4a18-ab7a-27d205c83f60', }; - const myCase = new Case(blockedCalendaredCase, { applicationContext }); + const myCase = new Case(blockedCalendaredCase, { + authorizedUser: mockDocketClerkUser, + }); expect(myCase.getFormattedValidationErrors()).toBe(null); }); }); @@ -1241,7 +1218,7 @@ describe('Case entity', () => { const myCase = new Case( {}, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1265,7 +1242,7 @@ describe('Case entity', () => { statistics: [], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1282,7 +1259,7 @@ describe('Case entity', () => { hasVerifiedIrsNotice: false, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1297,7 +1274,7 @@ describe('Case entity', () => { hasVerifiedIrsNotice: true, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -1307,7 +1284,10 @@ describe('Case entity', () => { describe('secondary contact', () => { it('does not create a secondary contact when one is not needed by the party type', () => { - const myCase = new Case({ ...MOCK_CASE }, { applicationContext }); + const myCase = new Case( + { ...MOCK_CASE }, + { authorizedUser: mockDocketClerkUser }, + ); expect(myCase.getContactSecondary()).toBeUndefined(); }); @@ -1318,7 +1298,7 @@ describe('Case entity', () => { ...MOCK_CASE, partyType: PARTY_TYPES.petitionerSpouse, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.getFormattedValidationErrors()).toMatchObject({ @@ -1346,7 +1326,7 @@ describe('Case entity', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase.getFormattedValidationErrors()).toMatchObject({ @@ -1366,7 +1346,7 @@ describe('Case entity', () => { const myCase = new Case( { ...MOCK_CASE, judgeUserId: mockJudgeUserId }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(myCase).toMatchObject({ @@ -1376,7 +1356,9 @@ describe('Case entity', () => { }); it('does not fail validation without a judgeUserId', () => { - const myCase = new Case(MOCK_CASE, { applicationContext }); + const myCase = new Case(MOCK_CASE, { + authorizedUser: mockDocketClerkUser, + }); expect(myCase.judgeUserId).toBeUndefined(); expect(myCase.getFormattedValidationErrors()).toEqual(null); @@ -1397,7 +1379,9 @@ describe('Case entity', () => { trialSessionId: mockTrialSessionId, }; - const myCase = new Case(blockedCalendaredCase, { applicationContext }); + const myCase = new Case(blockedCalendaredCase, { + authorizedUser: mockDocketClerkUser, + }); expect(myCase.getFormattedValidationErrors()).toEqual({ blocked: '"blocked" contains an invalid value', @@ -1413,7 +1397,9 @@ describe('Case entity', () => { trialSessionId: mockTrialSessionId, }; - const myCase = new Case(calendaredCase, { applicationContext }); + const myCase = new Case(calendaredCase, { + authorizedUser: mockDocketClerkUser, + }); expect(myCase.getFormattedValidationErrors()).toBe(null); }); @@ -1430,7 +1416,7 @@ describe('Case entity', () => { }; const myCase = new Case(blockedReadyForTrialCase, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(myCase.getFormattedValidationErrors()).toBe(null); diff --git a/shared/src/business/entities/cases/Case.toRawObject.test.ts b/shared/src/business/entities/cases/Case.toRawObject.test.ts index 0bac37bd23b..cacf6c28280 100644 --- a/shared/src/business/entities/cases/Case.toRawObject.test.ts +++ b/shared/src/business/entities/cases/Case.toRawObject.test.ts @@ -1,5 +1,5 @@ import { Case } from './Case'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('toRawObject', () => { beforeEach(() => { @@ -11,7 +11,7 @@ describe('toRawObject', () => { }); it('calls own function to update values after decorated toRawObject', () => { - const myCase = new Case({}, { applicationContext }); + const myCase = new Case({}, { authorizedUser: mockDocketClerkUser }); const result = myCase.toRawObject(); @@ -20,7 +20,7 @@ describe('toRawObject', () => { }); it('does not call own function to update values if flag is set to false after decorated toRawObject', () => { - const myCase = new Case({}, { applicationContext }); + const myCase = new Case({}, { authorizedUser: mockDocketClerkUser }); const result = myCase.toRawObject(false); expect(Case.prototype.doesHavePendingItems).not.toHaveBeenCalled(); diff --git a/shared/src/business/entities/cases/Case.unsetAsBlocked.test.ts b/shared/src/business/entities/cases/Case.unsetAsBlocked.test.ts index ab804ed6ec7..d94c6f811ca 100644 --- a/shared/src/business/entities/cases/Case.unsetAsBlocked.test.ts +++ b/shared/src/business/entities/cases/Case.unsetAsBlocked.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('unsetAsBlocked', () => { it('unsets the case as blocked', () => { @@ -11,7 +11,7 @@ describe('unsetAsBlocked', () => { blockedReason: 'because reasons', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.unsetAsHighPriority.test.ts b/shared/src/business/entities/cases/Case.unsetAsHighPriority.test.ts index 7212e503a16..7f099dbadc7 100644 --- a/shared/src/business/entities/cases/Case.unsetAsHighPriority.test.ts +++ b/shared/src/business/entities/cases/Case.unsetAsHighPriority.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('unsetAsHighPriority', () => { it('unsets the case as high priority', () => { @@ -11,7 +11,7 @@ describe('unsetAsHighPriority', () => { highPriorityReason: 'because reasons', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.updateAutomaticBlocked.test.ts b/shared/src/business/entities/cases/Case.updateAutomaticBlocked.test.ts index 84f444629ff..171f7435acd 100644 --- a/shared/src/business/entities/cases/Case.updateAutomaticBlocked.test.ts +++ b/shared/src/business/entities/cases/Case.updateAutomaticBlocked.test.ts @@ -1,7 +1,7 @@ import { AUTOMATIC_BLOCKED_REASONS } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE, MOCK_CASE_WITHOUT_PENDING } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateAutomaticBlocked', () => { it('sets the case as automaticBlocked with a valid blocked reason', () => { @@ -10,7 +10,7 @@ describe('updateAutomaticBlocked', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -34,7 +34,7 @@ describe('updateAutomaticBlocked', () => { automaticBlockedReason: 'because reasons', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.updateCaseCaptionDocketRecord.test.ts b/shared/src/business/entities/cases/Case.updateCaseCaptionDocketRecord.test.ts index 5b127e4cfef..4d360048cb1 100644 --- a/shared/src/business/entities/cases/Case.updateCaseCaptionDocketRecord.test.ts +++ b/shared/src/business/entities/cases/Case.updateCaseCaptionDocketRecord.test.ts @@ -1,6 +1,5 @@ import { CASE_STATUS_TYPES } from '../EntityConstants'; import { Case } from './Case'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateCaseCaptionDocketRecord', () => { @@ -8,7 +7,7 @@ describe('updateCaseCaptionDocketRecord', () => { const caseToVerify = new Case( {}, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).updateCaseCaptionDocketRecord({ authorizedUser: mockDocketClerkUser, @@ -22,7 +21,7 @@ describe('updateCaseCaptionDocketRecord', () => { caseCaption: 'Caption', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).updateCaseCaptionDocketRecord({ authorizedUser: mockDocketClerkUser, @@ -37,7 +36,7 @@ describe('updateCaseCaptionDocketRecord', () => { initialCaption: 'Caption', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).updateCaseCaptionDocketRecord({ authorizedUser: mockDocketClerkUser, @@ -53,7 +52,7 @@ describe('updateCaseCaptionDocketRecord', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).updateCaseCaptionDocketRecord({ authorizedUser: mockDocketClerkUser, @@ -83,7 +82,7 @@ describe('updateCaseCaptionDocketRecord', () => { initialCaption: 'Caption', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).updateCaseCaptionDocketRecord({ authorizedUser: mockDocketClerkUser, @@ -113,7 +112,7 @@ describe('updateCaseCaptionDocketRecord', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ).updateCaseCaptionDocketRecord({ authorizedUser: mockDocketClerkUser, diff --git a/shared/src/business/entities/cases/Case.updateCorrespondence.test.ts b/shared/src/business/entities/cases/Case.updateCorrespondence.test.ts index 9fc2bfb1e63..df323ad4c91 100644 --- a/shared/src/business/entities/cases/Case.updateCorrespondence.test.ts +++ b/shared/src/business/entities/cases/Case.updateCorrespondence.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { Correspondence } from '../Correspondence'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateCorrespondence', () => { it('should update a correspondence document', () => { @@ -13,7 +13,7 @@ describe('updateCorrespondence', () => { const myCase = new Case( { ...MOCK_CASE, correspondence: [mockCorrespondence] }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -38,7 +38,7 @@ describe('updateCorrespondence', () => { const myCase = new Case( { ...MOCK_CASE, correspondence: [mockCorrespondence] }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.updateDocketEntry.test.ts b/shared/src/business/entities/cases/Case.updateDocketEntry.test.ts index 142a7b91e4a..698e70647d1 100644 --- a/shared/src/business/entities/cases/Case.updateDocketEntry.test.ts +++ b/shared/src/business/entities/cases/Case.updateDocketEntry.test.ts @@ -2,12 +2,12 @@ import { Case } from './Case'; import { DOCUMENT_PROCESSING_STATUS_OPTIONS } from '../EntityConstants'; import { MOCK_CASE } from '../../../test/mockCase'; import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateDocketEntry', () => { it('should replace the docket entry with the exact object provided', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); myCase.updateDocketEntry({ @@ -27,7 +27,7 @@ describe('updateDocketEntry', () => { it('should not change any docketEntries if no match is found', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); myCase.updateDocketEntry({ diff --git a/shared/src/business/entities/cases/Case.updateDocketNumberRecord.test.ts b/shared/src/business/entities/cases/Case.updateDocketNumberRecord.test.ts index 0f2c6fade67..05554b389e4 100644 --- a/shared/src/business/entities/cases/Case.updateDocketNumberRecord.test.ts +++ b/shared/src/business/entities/cases/Case.updateDocketNumberRecord.test.ts @@ -1,7 +1,6 @@ import { CASE_STATUS_TYPES, DOCKET_NUMBER_SUFFIXES } from '../EntityConstants'; import { Case } from './Case'; import { DocketEntry } from '@shared/business/entities/DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateDocketNumberRecord records suffix changes', () => { @@ -14,7 +13,7 @@ describe('updateDocketNumberRecord records suffix changes', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(caseToVerify.initialDocketNumberSuffix).toEqual('S'); @@ -40,7 +39,7 @@ describe('updateDocketNumberRecord records suffix changes', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(caseToVerify.initialDocketNumberSuffix).toEqual('_'); @@ -54,7 +53,7 @@ describe('updateDocketNumberRecord records suffix changes', () => { const caseToVerify = new Case( { docketNumber: '123-19' }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); expect(caseToVerify.initialDocketNumberSuffix).toEqual('_'); @@ -86,7 +85,7 @@ describe('updateDocketNumberRecord records suffix changes', () => { status: CASE_STATUS_TYPES.generalDocket, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); caseToVerify.docketNumberSuffix = DOCKET_NUMBER_SUFFIXES.WHISTLEBLOWER; diff --git a/shared/src/business/entities/cases/Case.updateIrsPractitioner.test.ts b/shared/src/business/entities/cases/Case.updateIrsPractitioner.test.ts index 612d8cdda66..b4582cdfdc1 100644 --- a/shared/src/business/entities/cases/Case.updateIrsPractitioner.test.ts +++ b/shared/src/business/entities/cases/Case.updateIrsPractitioner.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { IrsPractitioner } from '../IrsPractitioner'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateIrsPractitioner', () => { let myCase; @@ -13,7 +13,7 @@ describe('updateIrsPractitioner', () => { irsPractitioners: [{ name: 'Christopher Walken', userId: '123' }], privatePractitioners: [{ name: 'Slim Shady', userId: '567' }], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); }); @@ -28,7 +28,7 @@ describe('updateIrsPractitioner', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.updatePetitioner.test.ts b/shared/src/business/entities/cases/Case.updatePetitioner.test.ts index 240efa03c86..5aff3f80dd9 100644 --- a/shared/src/business/entities/cases/Case.updatePetitioner.test.ts +++ b/shared/src/business/entities/cases/Case.updatePetitioner.test.ts @@ -1,7 +1,7 @@ import { CONTACT_TYPES, PARTY_TYPES } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updatePetitioner', () => { it('should throw an error when the petitioner to update is not found on the case', () => { @@ -9,7 +9,7 @@ describe('updatePetitioner', () => { { ...MOCK_CASE, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(() => myCase.updatePetitioner({ contactId: 'badId' })).toThrow( @@ -22,7 +22,7 @@ describe('updatePetitioner', () => { { ...MOCK_CASE, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); myCase.updatePetitioner({ @@ -35,7 +35,7 @@ describe('updatePetitioner', () => { // send back through the constructor so contacts are recreated as entities const updatedCaseEntity = new Case(updatedCaseRaw, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(updatedCaseEntity.petitioners[0]).toMatchObject({ @@ -61,7 +61,7 @@ describe('updatePetitioner', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); myCase.updatePetitioner({ @@ -74,7 +74,7 @@ describe('updatePetitioner', () => { // send back through the constructor so contacts are recreated as entities const updatedCaseEntity = new Case(updatedCaseRaw, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); expect(updatedCaseEntity.isValid()).toBeFalsy(); diff --git a/shared/src/business/entities/cases/Case.updatePrivatePractitioner.test.ts b/shared/src/business/entities/cases/Case.updatePrivatePractitioner.test.ts index d3c35963480..fa83f3c091f 100644 --- a/shared/src/business/entities/cases/Case.updatePrivatePractitioner.test.ts +++ b/shared/src/business/entities/cases/Case.updatePrivatePractitioner.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { PrivatePractitioner } from '../PrivatePractitioner'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updatePrivatePractitioner', () => { let myCase; @@ -13,7 +13,7 @@ describe('updatePrivatePractitioner', () => { irsPractitioners: [{ name: 'Christopher Walken', userId: '123' }], privatePractitioners: [{ name: 'Slim Shady', userId: '567' }], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); }); @@ -28,7 +28,7 @@ describe('updatePrivatePractitioner', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/shared/src/business/entities/cases/Case.updateStatistic.test.ts b/shared/src/business/entities/cases/Case.updateStatistic.test.ts index 0d27a1bd31f..e8e54688b05 100644 --- a/shared/src/business/entities/cases/Case.updateStatistic.test.ts +++ b/shared/src/business/entities/cases/Case.updateStatistic.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { Statistic } from '../Statistic'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateStatistic', () => { it('should successfully update a statistic', () => { @@ -22,7 +22,7 @@ describe('updateStatistic', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const statisticToUpdate = new Statistic({ @@ -57,7 +57,7 @@ describe('updateStatistic', () => { ...MOCK_CASE, statistics: [originalStatistic], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const statisticToUpdate = new Statistic({ diff --git a/shared/src/business/entities/cases/Case.updateTrialSessionInformation.test.ts b/shared/src/business/entities/cases/Case.updateTrialSessionInformation.test.ts index 5d608580aaa..ad96e765950 100644 --- a/shared/src/business/entities/cases/Case.updateTrialSessionInformation.test.ts +++ b/shared/src/business/entities/cases/Case.updateTrialSessionInformation.test.ts @@ -2,14 +2,14 @@ import { CASE_STATUS_TYPES, CHIEF_JUDGE } from '../EntityConstants'; import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { TrialSession } from '../trialSessions/TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('updateTrialSessionInformation', () => { it('should not change the status of the case', () => { const myCase = new Case( { ...MOCK_CASE, status: CASE_STATUS_TYPES.closed }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); myCase.updateTrialSessionInformation({ @@ -24,7 +24,7 @@ describe('updateTrialSessionInformation', () => { it('should set only judge and trialSessionId if the trial session is calendared', () => { const myCase = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); myCase.updateTrialSessionInformation({ isCalendared: false, @@ -42,7 +42,7 @@ describe('updateTrialSessionInformation', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const trialSession = new TrialSession({ @@ -71,7 +71,7 @@ describe('updateTrialSessionInformation', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const trialSession = new TrialSession({ diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index 9e2ca83d150..2231c3dc30d 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -69,3 +69,10 @@ export const mockIrsPractitionerUser: AuthUser = { role: ROLES.irsPractitioner, userId: '4eb0a70d-ed4c-4715-a95f-261cb1441db9', }; + +export const mockIrsSuperuser: AuthUser = { + email: 'mockIrsSuperUser@example.com', + name: 'Iris Iguana', + role: ROLES.irsSuperuser, + userId: '192b629a-aa9c-4a7d-9379-b2a1331a6848', +}; From ffc6a82e3802602a86a1d6120ab3800208eaa047 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 3 Jul 2024 16:02:11 -0700 Subject: [PATCH 070/523] 10417: WIP Transition Case away from appContext --- docs/remove-get-current-user.md | 6 +++-- .../business/entities/cases/CaseQC.test.ts | 13 +++++----- shared/src/business/entities/cases/CaseQC.ts | 11 ++++++-- ...lSession.manuallyAddCaseToCalendar.test.ts | 6 +++-- .../canConsolidateInteractor.ts | 4 ++- ...eneratePrintableFilingReceiptInteractor.ts | 6 +++-- .../useCases/getCaseDeadlinesInteractor.ts | 7 ++++- .../business/useCases/getCaseInteractor.ts | 15 +++-------- .../getDownloadPolicyUrlInteractor.ts | 2 +- .../useCases/prioritizeCaseInteractor.ts | 4 +-- .../removeCasePendingItemInteractor.ts | 2 +- .../removePdfFromDocketEntryInteractor.ts | 4 +-- ...ovePetitionerAndUpdateCaptionInteractor.ts | 6 +++-- .../removeSignatureFromDocumentInteractor.ts | 4 ++- .../saveCaseDetailInternalEditInteractor.ts | 8 +++--- .../useCases/saveSignedDocumentInteractor.ts | 2 +- .../sealCaseContactAddressInteractor.ts | 4 +-- .../business/useCases/sealCaseInteractor.ts | 6 +++-- .../unblockCaseFromTrialInteractor.ts | 4 +-- .../useCases/unprioritizeCaseInteractor.ts | 4 +-- .../business/useCases/unsealCaseInteractor.ts | 6 +++-- .../useCases/updateCaseContextInteractor.ts | 4 +-- .../useCases/updateCaseDetailsInteractor.ts | 8 +++--- .../updateCaseTrialSortTagsInteractor.test.ts | 4 ++- .../updateCaseTrialSortTagsInteractor.ts | 2 +- .../useCases/updateContactInteractor.ts | 4 +-- .../updateQcCompleteForTrialInteractor.ts | 6 +++-- .../useCases/validateCaseDetailInteractor.ts | 4 +-- .../utilities/getFormattedCaseDetail.ts | 4 ++- .../utilities/serveCaseDocument.test.ts | 9 ++++--- .../shouldAppendClinicLetter.test.ts | 5 ++-- ...DocketEntryForSystemGeneratedOrder.test.ts | 2 +- .../updateCaseAutomaticBlock.test.ts | 17 +++++++----- .../addExistingUserToCase.test.ts | 19 +++++++++----- .../associateIrsPractitionerToCase.ts | 4 ++- .../associatePrivatePractitionerToCase.ts | 4 ++- .../createCaseAndAssociations.test.ts | 7 ++--- .../createCaseAndAssociations.ts | 4 ++- .../createUserForContact.test.ts | 26 +++++++------------ ...removeCounselFromRemovedPetitioner.test.ts | 10 ++++--- .../updateCaseAndAssociations.test.ts | 9 ++++--- .../updateCaseAndAssociations.ts | 12 +++++---- ...essionForEnteredAndServedDocuments.test.ts | 13 +++++----- .../createAndServeNoticeDocketEntry.test.ts | 5 ++-- .../fileAndServeDocumentOnOneCase.test.ts | 11 ++++---- .../fileAndServeDocumentOnOneCase.ts | 4 ++- 46 files changed, 185 insertions(+), 136 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index c177dead7fd..31833e1225f 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -2,6 +2,10 @@ - DO NOT REFACTOR - If something seems questionable or gives a moment of pause mark with a comment: // TODO 10417 +# TODO +- Go back to all // TODO 10417 +- Look for 'extends' Classname + # Web-Client Steps to transition getCurrentUser() in web-client 1. Find applicationContext.getCurrentUser() and replace with get(state.user); @@ -12,8 +16,6 @@ For Interactors that are still in shared follow the steps in the `Web-Api` secti For DocketEntry, Case, PublicCase -TODO: Look for 'extends' Classname - # Web-Api Steps To transition an interactor away from getCurrentUser() 1. Make Interactor accept a 3rd paramater called authorizedUser: UnknownAuthUser diff --git a/shared/src/business/entities/cases/CaseQC.test.ts b/shared/src/business/entities/cases/CaseQC.test.ts index 9d8b6eb6c17..3c065cf42a8 100644 --- a/shared/src/business/entities/cases/CaseQC.test.ts +++ b/shared/src/business/entities/cases/CaseQC.test.ts @@ -1,15 +1,14 @@ import { CaseQC } from './CaseQC'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('CaseQC entity', () => { describe('validation', () => { - it('throws an exception when not provided an application context', () => { - expect(() => new CaseQC({}, {} as any)).toThrow(); - }); - it('returns the expected set of errors for an empty object', () => { - const caseQcEntity = new CaseQC({}, { applicationContext }); + const caseQcEntity = new CaseQC( + {}, + { authorizedUser: mockDocketClerkUser }, + ); expect(caseQcEntity.getFormattedValidationErrors()).toEqual({ caseCaption: 'Enter a case caption', @@ -28,7 +27,7 @@ describe('CaseQC entity', () => { ...MOCK_CASE, hasVerifiedIrsNotice: false, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); expect(caseQcEntity.getFormattedValidationErrors()).toEqual(null); diff --git a/shared/src/business/entities/cases/CaseQC.ts b/shared/src/business/entities/cases/CaseQC.ts index fc930d68b0b..7f9dfcb404b 100644 --- a/shared/src/business/entities/cases/CaseQC.ts +++ b/shared/src/business/entities/cases/CaseQC.ts @@ -1,11 +1,18 @@ import { Case } from './Case'; import { JoiValidationConstants } from '../JoiValidationConstants'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import joi from 'joi'; export class CaseQC extends Case { - constructor(rawCase, { applicationContext, filtered = false }) { + constructor( + rawCase, + { + authorizedUser, + filtered = false, + }: { authorizedUser: UnknownAuthUser; filtered?: boolean }, + ) { super(rawCase, { - applicationContext, + authorizedUser, filtered, }); this.entityName = 'CaseQC'; diff --git a/shared/src/business/entities/trialSessions/TrialSession.manuallyAddCaseToCalendar.test.ts b/shared/src/business/entities/trialSessions/TrialSession.manuallyAddCaseToCalendar.test.ts index cf0711f8863..c82f261f2c2 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.manuallyAddCaseToCalendar.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.manuallyAddCaseToCalendar.test.ts @@ -2,11 +2,13 @@ import { Case } from '../cases/Case'; import { MOCK_CASE } from '../../../test/mockCase'; import { MOCK_TRIAL_INPERSON } from '../../../test/mockTrial'; import { TrialSession } from './TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('TrialSession entity', () => { describe('manuallyAddCaseToCalendar', () => { - const mockCaseEntity = new Case(MOCK_CASE, { applicationContext }); + const mockCaseEntity = new Case(MOCK_CASE, { + authorizedUser: mockDocketClerkUser, + }); const dateRegex = /^\d*-\d*-\d*T\d*:\d*:\d*.\d*Z$/g; let trialSession: TrialSession; diff --git a/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.ts b/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.ts index bd35b5211a7..740292d4773 100644 --- a/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.ts +++ b/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.ts @@ -15,7 +15,9 @@ export const canConsolidateInteractor = ( currentCase, }: { caseToConsolidate: Case; currentCase: Case }, ) => { - const caseEntity = new Case(currentCase, { applicationContext }); + const caseEntity = new Case(currentCase, { + authorizedUser: applicationContext.getCurrentUser(), + }); const results = caseEntity.getConsolidationStatus({ caseEntity: caseToConsolidate, diff --git a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts index 9c489620b5e..49cffd460be 100644 --- a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts +++ b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts @@ -58,7 +58,9 @@ export const generatePrintableFilingReceiptInteractor = async ( docketNumber, }); - let caseEntity = new Case(caseRecord, { applicationContext }).validate(); + let caseEntity = new Case(caseRecord, { + authorizedUser: applicationContext.getCurrentUser(), + }).validate(); if (fileAcrossConsolidatedGroup && !caseRecord.leadDocketNumber) { throw new Error( @@ -79,7 +81,7 @@ export const generatePrintableFilingReceiptInteractor = async ( .sort((a, b) => a.sortableDocketNumber - b.sortableDocketNumber) .map(consolidatedCaseRecord => consolidatedCaseRecord.docketNumber); caseEntity = new Case(leadCase, { - applicationContext, + authorizedUser: applicationContext.getCurrentUser(), }).validate(); } diff --git a/shared/src/business/useCases/getCaseDeadlinesInteractor.ts b/shared/src/business/useCases/getCaseDeadlinesInteractor.ts index 62e5fea1abc..4ff9b266748 100644 --- a/shared/src/business/useCases/getCaseDeadlinesInteractor.ts +++ b/shared/src/business/useCases/getCaseDeadlinesInteractor.ts @@ -83,7 +83,12 @@ const getCasesByDocketNumbers = async ({ }); return caseData - .map(caseRecord => new Case(caseRecord, { applicationContext })) + .map( + caseRecord => + new Case(caseRecord, { + authorizedUser: applicationContext.getCurrentUser(), + }), + ) .filter(caseEntity => { try { caseEntity.validate(); diff --git a/shared/src/business/useCases/getCaseInteractor.ts b/shared/src/business/useCases/getCaseInteractor.ts index bd2c98ce06f..6a348121a17 100644 --- a/shared/src/business/useCases/getCaseInteractor.ts +++ b/shared/src/business/useCases/getCaseInteractor.ts @@ -24,12 +24,10 @@ import { } from '../utilities/caseFilter'; const getSealedCase = ({ - applicationContext, authorizedUser, caseRecord, isAssociatedWithCase, }: { - applicationContext: IApplicationContext; caseRecord: RawCase; isAssociatedWithCase: boolean; authorizedUser: AuthUser; @@ -51,9 +49,7 @@ const getSealedCase = ({ } if (isAuthorizedToViewSealedCase || isAssociatedWithCase) { - return new Case(caseRecord, { applicationContext }) - .validate() - .toRawObject(); + return new Case(caseRecord, { authorizedUser }).validate().toRawObject(); } else { caseRecord = caseSealedFormatter(caseRecord); @@ -66,16 +62,13 @@ const getSealedCase = ({ }; const getCaseForExternalUser = ({ - applicationContext, authorizedUser, caseRecord, isAssociatedWithCase, isAuthorizedToGetCase, }) => { if (isAuthorizedToGetCase && isAssociatedWithCase) { - return new Case(caseRecord, { applicationContext }) - .validate() - .toRawObject(); + return new Case(caseRecord, { authorizedUser }).validate().toRawObject(); } else { return new PublicCase(caseRecord, { authorizedUser, @@ -178,7 +171,6 @@ export const getCaseInteractor = async ( if (isSealedCase) { caseDetailRaw = await getSealedCase({ - applicationContext, authorizedUser, caseRecord, isAssociatedWithCase, @@ -188,12 +180,11 @@ export const getCaseInteractor = async ( const isInternalUser = User.isInternalUser(userRole); if (isInternalUser) { - caseDetailRaw = new Case(caseRecord, { applicationContext }) + caseDetailRaw = new Case(caseRecord, { authorizedUser }) .validate() .toRawObject(); } else { caseDetailRaw = await getCaseForExternalUser({ - applicationContext, authorizedUser, caseRecord, isAssociatedWithCase, diff --git a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.ts b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.ts index f6cf391cf21..7c363b4cb60 100644 --- a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.ts +++ b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.ts @@ -29,7 +29,7 @@ export const getDownloadPolicyUrlInteractor = async ( throw new NotFoundError(`Case ${docketNumber} was not found.`); } - const caseEntity = new Case(caseData, { applicationContext }); + const caseEntity = new Case(caseData, { authorizedUser }); const docketEntryEntity = caseEntity.getDocketEntryById({ docketEntryId: key, }); diff --git a/shared/src/business/useCases/prioritizeCaseInteractor.ts b/shared/src/business/useCases/prioritizeCaseInteractor.ts index c835af35e20..2756ea0fa2e 100644 --- a/shared/src/business/useCases/prioritizeCaseInteractor.ts +++ b/shared/src/business/useCases/prioritizeCaseInteractor.ts @@ -32,7 +32,7 @@ export const prioritizeCase = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); if (caseEntity.isCalendared()) { throw new Error('Cannot set a calendared case as high priority'); @@ -60,7 +60,7 @@ export const prioritizeCase = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const prioritizeCaseInteractor = withLocking( diff --git a/shared/src/business/useCases/removeCasePendingItemInteractor.ts b/shared/src/business/useCases/removeCasePendingItemInteractor.ts index 716e3104b28..c5cd6d67004 100644 --- a/shared/src/business/useCases/removeCasePendingItemInteractor.ts +++ b/shared/src/business/useCases/removeCasePendingItemInteractor.ts @@ -34,7 +34,7 @@ export const removeCasePendingItem = async ( } }); - let updatedCaseEntity = new Case(caseToUpdate, { applicationContext }); + let updatedCaseEntity = new Case(caseToUpdate, { authorizedUser: user }); updatedCaseEntity = await applicationContext .getUseCaseHelpers() diff --git a/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts b/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts index 0d72fce748e..c04bd0601bc 100644 --- a/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts +++ b/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts @@ -32,7 +32,7 @@ export const removePdfFromDocketEntry = async ( }); const caseEntity = new Case(caseRecord, { - applicationContext, + authorizedUser, }); const docketEntry = caseEntity.getDocketEntryById({ docketEntryId }); @@ -53,7 +53,7 @@ export const removePdfFromDocketEntry = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).toRawObject(); + return new Case(updatedCase, { authorizedUser }).toRawObject(); } }; diff --git a/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts b/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts index f07b47d90c2..91e5614389a 100644 --- a/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts +++ b/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts @@ -37,7 +37,7 @@ export const removePetitionerAndUpdateCaption = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - let caseEntity = new Case(caseToUpdate, { applicationContext }); + let caseEntity = new Case(caseToUpdate, { authorizedUser: user }); if (caseToUpdate.status === CASE_STATUS_TYPES.new) { throw new Error( @@ -76,7 +76,9 @@ export const removePetitionerAndUpdateCaption = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const removePetitionerAndUpdateCaptionInteractor = withLocking( diff --git a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts index 6c07f630e34..388b1e6c4a3 100644 --- a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts +++ b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts @@ -19,7 +19,9 @@ export const removeSignatureFromDocumentInteractor = async ( applicationContext, docketNumber, }); - const caseEntity = new Case(caseRecord, { applicationContext }); + const caseEntity = new Case(caseRecord, { + authorizedUser: applicationContext.getCurrentUser(), + }); const docketEntryToUnsign = caseEntity.getDocketEntryById({ docketEntryId, }); diff --git a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts index fbcd8483f8e..b02b5b20ab8 100644 --- a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts +++ b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts @@ -45,7 +45,7 @@ export const saveCaseDetailInternalEdit = async ( docketNumber, }); - const originalCaseEntity = new Case(caseRecord, { applicationContext }); + const originalCaseEntity = new Case(caseRecord, { authorizedUser }); const editableFields = { caseCaption: caseToUpdate.caseCaption, @@ -89,7 +89,7 @@ export const saveCaseDetailInternalEdit = async ( }; const caseEntityWithFormEdits = new Case(caseWithFormEdits, { - applicationContext, + authorizedUser, }); if (!isEmpty(caseToUpdate.contactPrimary)) { @@ -125,7 +125,7 @@ export const saveCaseDetailInternalEdit = async ( } const caseEntity = new Case(caseEntityWithFormEdits, { - applicationContext, + authorizedUser, }); if (caseEntity.isPaper) { @@ -165,7 +165,7 @@ export const saveCaseDetailInternalEdit = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).toRawObject(); + return new Case(updatedCase, { authorizedUser }).toRawObject(); }; export const saveCaseDetailInternalEditInteractor = withLocking( diff --git a/shared/src/business/useCases/saveSignedDocumentInteractor.ts b/shared/src/business/useCases/saveSignedDocumentInteractor.ts index 67d7f9fc98e..140eb2655c1 100644 --- a/shared/src/business/useCases/saveSignedDocumentInteractor.ts +++ b/shared/src/business/useCases/saveSignedDocumentInteractor.ts @@ -78,7 +78,7 @@ export const saveSignedDocumentInteractor = async ( applicationContext, docketNumber, }); - const caseEntity = new Case(caseRecord, { applicationContext }); + const caseEntity = new Case(caseRecord, { authorizedUser: user }); const originalDocketEntryEntity = caseEntity.docketEntries.find( docketEntry => docketEntry.docketEntryId === originalDocketEntryId, ); diff --git a/shared/src/business/useCases/sealCaseContactAddressInteractor.ts b/shared/src/business/useCases/sealCaseContactAddressInteractor.ts index 32107234165..2ccbec9b6fa 100644 --- a/shared/src/business/useCases/sealCaseContactAddressInteractor.ts +++ b/shared/src/business/useCases/sealCaseContactAddressInteractor.ts @@ -37,7 +37,7 @@ export const sealCaseContactAddress = async ( }); const caseEntity = new Case(caseRecord, { - applicationContext, + authorizedUser, }); const contactToSeal = caseEntity.getPetitionerById(contactId); @@ -56,7 +56,7 @@ export const sealCaseContactAddress = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).toRawObject(); + return new Case(updatedCase, { authorizedUser }).toRawObject(); }; export const sealCaseContactAddressInteractor = withLocking( diff --git a/shared/src/business/useCases/sealCaseInteractor.ts b/shared/src/business/useCases/sealCaseInteractor.ts index 9a77ecc20a3..511fa8404c7 100644 --- a/shared/src/business/useCases/sealCaseInteractor.ts +++ b/shared/src/business/useCases/sealCaseInteractor.ts @@ -27,7 +27,7 @@ export const sealCase = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { applicationContext }); + const newCase = new Case(oldCase, { authorizedUser: user }); newCase.setAsSealed(); @@ -42,7 +42,9 @@ export const sealCase = async ( .getDispatchers() .sendNotificationOfSealing(applicationContext, { docketNumber }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const sealCaseInteractor = withLocking( diff --git a/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts b/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts index 834f5a9aa02..9f862561670 100644 --- a/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts +++ b/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts @@ -30,7 +30,7 @@ export const unblockCaseFromTrial = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); caseEntity.unsetAsBlocked(); @@ -51,7 +51,7 @@ export const unblockCaseFromTrial = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const unblockCaseFromTrialInteractor = withLocking( diff --git a/shared/src/business/useCases/unprioritizeCaseInteractor.ts b/shared/src/business/useCases/unprioritizeCaseInteractor.ts index 2f80d601470..8eb9ce61501 100644 --- a/shared/src/business/useCases/unprioritizeCaseInteractor.ts +++ b/shared/src/business/useCases/unprioritizeCaseInteractor.ts @@ -30,7 +30,7 @@ export const unprioritizeCase = async ( docketNumber, }); - let caseEntity = new Case(caseToUpdate, { applicationContext }); + let caseEntity = new Case(caseToUpdate, { authorizedUser }); caseEntity.unsetAsHighPriority(); @@ -62,7 +62,7 @@ export const unprioritizeCase = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const unprioritizeCaseInteractor = withLocking( diff --git a/shared/src/business/useCases/unsealCaseInteractor.ts b/shared/src/business/useCases/unsealCaseInteractor.ts index c03d0971598..ae0230de4d0 100644 --- a/shared/src/business/useCases/unsealCaseInteractor.ts +++ b/shared/src/business/useCases/unsealCaseInteractor.ts @@ -27,7 +27,7 @@ export const unsealCase = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { applicationContext }); + const newCase = new Case(oldCase, { authorizedUser: user }); newCase.setAsUnsealed(); @@ -38,7 +38,9 @@ export const unsealCase = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const unsealCaseInteractor = withLocking( diff --git a/shared/src/business/useCases/updateCaseContextInteractor.ts b/shared/src/business/useCases/updateCaseContextInteractor.ts index a68e7e11859..6e15faba1f9 100644 --- a/shared/src/business/useCases/updateCaseContextInteractor.ts +++ b/shared/src/business/useCases/updateCaseContextInteractor.ts @@ -36,7 +36,7 @@ export const updateCaseContext = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { applicationContext }); + const newCase = new Case(oldCase, { authorizedUser: user }); if (caseCaption) { newCase.setCaseCaption(caseCaption); @@ -116,7 +116,7 @@ export const updateCaseContext = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { applicationContext }).toRawObject(); + return new Case(updatedCase, { authorizedUser: user }).toRawObject(); }; export const updateCaseContextInteractor = withLocking( diff --git a/shared/src/business/useCases/updateCaseDetailsInteractor.ts b/shared/src/business/useCases/updateCaseDetailsInteractor.ts index e13aa0a8eee..a02a8c7ed9a 100644 --- a/shared/src/business/useCases/updateCaseDetailsInteractor.ts +++ b/shared/src/business/useCases/updateCaseDetailsInteractor.ts @@ -66,7 +66,7 @@ export const updateCaseDetails = async ( ? editableFields.petitionPaymentWaivedDate : null, }, - { applicationContext }, + { authorizedUser: user }, ); if (oldCase.petitionPaymentStatus === PAYMENT_STATUS.UNPAID) { @@ -108,7 +108,7 @@ export const updateCaseDetails = async ( } if (newCaseEntity.getShouldHaveTrialSortMappingRecords()) { - const oldCaseEntity = new Case(oldCase, { applicationContext }); + const oldCaseEntity = new Case(oldCase, { authorizedUser: user }); const oldTrialSortTag = oldCaseEntity.getShouldHaveTrialSortMappingRecords() ? oldCaseEntity.generateTrialSortTags() : { nonHybrid: undefined }; @@ -135,7 +135,9 @@ export const updateCaseDetails = async ( caseToUpdate: newCaseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const updateCaseDetailsInteractor = withLocking( diff --git a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.ts b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.ts index 62a2b6dcdbc..80e88d8f96a 100644 --- a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.ts +++ b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.ts @@ -3,6 +3,7 @@ import { Case } from '../entities/cases/Case'; import { MOCK_CASE } from '../../test/mockCase'; import { User } from '../entities/User'; import { applicationContext } from '../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; import { updateCaseTrialSortTagsInteractor } from './updateCaseTrialSortTagsInteractor'; @@ -79,7 +80,8 @@ describe('Update case trial sort tags', () => { applicationContext .getPersistenceGateway() .updateCase.mockImplementation( - ({ caseToUpdate }) => new Case(caseToUpdate, { applicationContext }), + ({ caseToUpdate }) => + new Case(caseToUpdate, { authorizedUser: mockDocketClerkUser }), ); await expect( diff --git a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.ts b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.ts index 9ca331456d5..a09709c990f 100644 --- a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.ts +++ b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.ts @@ -29,7 +29,7 @@ export const updateCaseTrialSortTagsInteractor = async ( throw new NotFoundError(`Case ${docketNumber} was not found.`); } - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser: user }); if (!isAuthorized(user, ROLE_PERMISSIONS.UPDATE_CASE)) { throw new UnauthorizedError('Unauthorized for update case'); diff --git a/shared/src/business/useCases/updateContactInteractor.ts b/shared/src/business/useCases/updateContactInteractor.ts index ec8d9b8f421..1f61c233259 100644 --- a/shared/src/business/useCases/updateContactInteractor.ts +++ b/shared/src/business/useCases/updateContactInteractor.ts @@ -56,7 +56,7 @@ export const updateContact = async ( { ...caseToUpdate, }, - { applicationContext }, + { authorizedUser: user }, ); const oldCaseContact = cloneDeep( @@ -75,7 +75,7 @@ export const updateContact = async ( } const rawUpdatedCase = caseEntity.validate().toRawObject(); - caseEntity = new Case(rawUpdatedCase, { applicationContext }); + caseEntity = new Case(rawUpdatedCase, { authorizedUser: user }); const updatedPetitioner = caseEntity.getPetitionerById(contactInfo.contactId); diff --git a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts index b42aaeccde1..59108d5693b 100644 --- a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts +++ b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts @@ -39,7 +39,7 @@ export const updateQcCompleteForTrial = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { applicationContext }); + const newCase = new Case(oldCase, { authorizedUser: user }); newCase.setQcCompleteForTrial({ qcCompleteForTrial, trialSessionId }); @@ -50,7 +50,9 @@ export const updateQcCompleteForTrial = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const updateQcCompleteForTrialInteractor = withLocking( diff --git a/shared/src/business/useCases/validateCaseDetailInteractor.ts b/shared/src/business/useCases/validateCaseDetailInteractor.ts index c31bd1ad51a..351d3de8cd9 100644 --- a/shared/src/business/useCases/validateCaseDetailInteractor.ts +++ b/shared/src/business/useCases/validateCaseDetailInteractor.ts @@ -18,10 +18,10 @@ export const validateCaseDetailInteractor = ( ): Record | null => { if (useCaseEntity) { return new Case(caseDetail, { - applicationContext, + authorizedUser: applicationContext.getCurrentUser(), }).getFormattedValidationErrors(); } return new CaseQC(caseDetail, { - applicationContext, + authorizedUser: applicationContext.getCurrentUser(), }).getFormattedValidationErrors(); }; diff --git a/shared/src/business/utilities/getFormattedCaseDetail.ts b/shared/src/business/utilities/getFormattedCaseDetail.ts index bc17cefe9ff..884191d4c73 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.ts +++ b/shared/src/business/utilities/getFormattedCaseDetail.ts @@ -375,7 +375,9 @@ export const formatCase = (applicationContext, caseDetail) => { } result.filingFee = `${caseDetail.petitionPaymentStatus} ${paymentDate} ${paymentMethod}`; - const caseEntity = new Case(caseDetail, { applicationContext }); + const caseEntity = new Case(caseDetail, { + authorizedUser: applicationContext.getCurrentUser(), + }); result.canConsolidate = caseEntity.canConsolidate(); result.canUnconsolidate = !!caseEntity.leadDocketNumber; result.irsSendDate = caseEntity.getIrsSendDate(); diff --git a/shared/src/business/utilities/serveCaseDocument.test.ts b/shared/src/business/utilities/serveCaseDocument.test.ts index 19fb2d25b4d..00e060eed3c 100644 --- a/shared/src/business/utilities/serveCaseDocument.test.ts +++ b/shared/src/business/utilities/serveCaseDocument.test.ts @@ -1,13 +1,14 @@ import { Case } from '../entities/cases/Case'; import { MOCK_CASE } from '../../test/mockCase'; import { applicationContext } from '../test/createTestApplicationContext'; +import { mockPetitionerUser } from '@shared/test/mockAuthUsers'; import { serveCaseDocument } from './serveCaseDocument'; describe('serveCaseDocument', () => { let mockCase; beforeEach(() => { - mockCase = new Case(MOCK_CASE, { applicationContext }); + mockCase = new Case(MOCK_CASE, { authorizedUser: mockPetitionerUser }); }); it('should not set as served or send service email for RQT when a file is not attached', async () => { @@ -29,7 +30,7 @@ describe('serveCaseDocument', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockPetitionerUser }, ); await serveCaseDocument({ @@ -63,7 +64,7 @@ describe('serveCaseDocument', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockPetitionerUser }, ); await serveCaseDocument({ @@ -93,7 +94,7 @@ describe('serveCaseDocument', () => { ...MOCK_CASE, docketEntries: [MOCK_CASE.docketEntries[1]], }, - { applicationContext }, + { authorizedUser: mockPetitionerUser }, ); await serveCaseDocument({ diff --git a/shared/src/business/utilities/shouldAppendClinicLetter.test.ts b/shared/src/business/utilities/shouldAppendClinicLetter.test.ts index b5d749c9a06..1744e794e81 100644 --- a/shared/src/business/utilities/shouldAppendClinicLetter.test.ts +++ b/shared/src/business/utilities/shouldAppendClinicLetter.test.ts @@ -3,6 +3,7 @@ import { MOCK_CASE } from '../../test/mockCase'; import { MOCK_TRIAL_INPERSON } from '../../test/mockTrial'; import { applicationContext } from '../test/createTestApplicationContext'; import { getClinicLetterKey } from './getClinicLetterKey'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { shouldAppendClinicLetter } from './shouldAppendClinicLetter'; jest.mock('./getClinicLetterKey'); @@ -15,7 +16,7 @@ describe('shouldAppendClinicLetter', () => { ...MOCK_CASE, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -67,7 +68,7 @@ describe('shouldAppendClinicLetter', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.test.ts b/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.test.ts index 02efb5c4e4d..49af6d6d77e 100644 --- a/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.test.ts +++ b/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.test.ts @@ -8,7 +8,7 @@ import { addDocketEntryForSystemGeneratedOrder } from './addDocketEntryForSystem import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; describe('addDocketEntryForSystemGeneratedOrder', () => { - const caseEntity = new Case(MOCK_CASE, { applicationContext }); + const caseEntity = new Case(MOCK_CASE, { authorizedUser: undefined }); const { noticeOfAttachmentsInNatureOfEvidence, diff --git a/web-api/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts b/web-api/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts index 2fc129c07db..664d19b8d40 100644 --- a/web-api/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts +++ b/web-api/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts @@ -11,6 +11,7 @@ import { MOCK_USERS } from '../../../../../shared/src/test/mockUsers'; import { PENDING_DOCKET_ENTRY } from '../../../../../shared/src/test/mockDocketEntry'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { updateCaseAutomaticBlock } from './updateCaseAutomaticBlock'; describe('updateCaseAutomaticBlock', () => { @@ -29,7 +30,9 @@ describe('updateCaseAutomaticBlock', () => { .getCaseDeadlinesByDocketNumber.mockReturnValue([]); mockCase.docketEntries = [PENDING_DOCKET_ENTRY]; - const caseEntity = new Case(mockCase, { applicationContext }); + const caseEntity = new Case(mockCase, { + authorizedUser: mockDocketClerkUser, + }); const updatedCase = await updateCaseAutomaticBlock({ applicationContext, caseEntity, @@ -54,7 +57,7 @@ describe('updateCaseAutomaticBlock', () => { ]); const caseEntity = new Case(MOCK_CASE_WITHOUT_PENDING, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); const updatedCase = await updateCaseAutomaticBlock({ applicationContext, @@ -86,7 +89,7 @@ describe('updateCaseAutomaticBlock', () => { trialDate: '2021-03-01T21:40:46.415Z', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const updatedCase = await updateCaseAutomaticBlock({ @@ -114,7 +117,7 @@ describe('updateCaseAutomaticBlock', () => { trialDate: undefined, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const updatedCase = await updateCaseAutomaticBlock({ @@ -135,7 +138,7 @@ describe('updateCaseAutomaticBlock', () => { .getCaseDeadlinesByDocketNumber.mockReturnValue([]); const caseEntity = new Case(MOCK_CASE_WITHOUT_PENDING, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); const updatedCase = await updateCaseAutomaticBlock({ applicationContext, @@ -164,7 +167,7 @@ describe('updateCaseAutomaticBlock', () => { status: CASE_STATUS_TYPES.generalDocketReadyForTrial, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); const updatedCase = await updateCaseAutomaticBlock({ @@ -195,7 +198,7 @@ describe('updateCaseAutomaticBlock', () => { status: CASE_STATUS_TYPES.generalDocketReadyForTrial, }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.test.ts index 190f57ae46a..f1e7e048247 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.test.ts @@ -10,6 +10,7 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { addExistingUserToCase } from './addExistingUserToCase'; import { admissionsClerkUser, petitionerUser } from '@shared/test/mockUsers'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('addExistingUserToCase', () => { const mockUserId = '674fdded-1d17-4081-b9fa-950abc677cee'; @@ -32,7 +33,9 @@ describe('addExistingUserToCase', () => { await expect( addExistingUserToCase({ applicationContext, - caseEntity: new Case(MOCK_CASE, { applicationContext }), + caseEntity: new Case(MOCK_CASE, { + authorizedUser: mockDocketClerkUser, + }), contactId: mockContactId, email: 'testing@example.com', name: 'Bob Ross', @@ -47,7 +50,9 @@ describe('addExistingUserToCase', () => { await expect( addExistingUserToCase({ applicationContext, - caseEntity: new Case(MOCK_CASE, { applicationContext }), + caseEntity: new Case(MOCK_CASE, { + authorizedUser: mockDocketClerkUser, + }), contactId: mockContactId, email: 'testing@example.com', name: 'Bob Ross', @@ -63,7 +68,7 @@ describe('addExistingUserToCase', () => { applicationContext.getCurrentUser.mockReturnValue(admissionsClerkUser); const caseEntity = new Case( { ...MOCK_CASE, petitioners: [mockExistingUser] }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); await expect( @@ -92,7 +97,7 @@ describe('addExistingUserToCase', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); await addExistingUserToCase({ @@ -155,7 +160,7 @@ describe('addExistingUserToCase', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); await addExistingUserToCase({ @@ -209,7 +214,7 @@ describe('addExistingUserToCase', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); await addExistingUserToCase({ @@ -245,7 +250,7 @@ describe('addExistingUserToCase', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); await addExistingUserToCase({ diff --git a/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts b/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts index 642a5c51368..6efa4c84dc5 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts @@ -49,7 +49,9 @@ export const associateIrsPractitionerToCase = async ({ userId: user.userId, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { + authorizedUser: applicationContext.getCurrentUser(), + }); caseEntity.attachIrsPractitioner( new IrsPractitioner({ ...user, serviceIndicator }), diff --git a/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts b/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts index b03e501d036..33d264b3530 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts @@ -57,7 +57,9 @@ export const associatePrivatePractitionerToCase = async ({ userId: user.userId, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { + authorizedUser: applicationContext.getCurrentUser(), + }); const { petitioners } = caseEntity; diff --git a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts index 07315e03ff3..1f8ec480741 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts @@ -3,6 +3,7 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_DOCUMENTS } from '../../../../../shared/src/test/mockDocketEntry'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createCaseAndAssociations } from './createCaseAndAssociations'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('createCaseAndAssociations', () => { let createCaseMock = jest.fn(); @@ -27,7 +28,7 @@ describe('createCaseAndAssociations', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ) .validate() .toRawObject(); @@ -104,7 +105,7 @@ describe('createCaseAndAssociations', () => { ...MOCK_CASE, irsPractitioners: [practitioner], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); it('throws an error if IRS practitioners are invalid', async () => { @@ -151,7 +152,7 @@ describe('createCaseAndAssociations', () => { ...MOCK_CASE, privatePractitioners: [practitioner], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); it('throws an error if IRS practitioners are invalid', async () => { diff --git a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts index e2698ba8048..8c6ff311c46 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts @@ -106,7 +106,9 @@ export const createCaseAndAssociations = async ({ }) => { const caseEntity = caseToCreate.validate ? caseToCreate - : new Case(caseToCreate, { applicationContext }); + : new Case(caseToCreate, { + authorizedUser: applicationContext.getCurrentUser(), + }); const validRawCaseEntity = caseEntity.validate().toRawObject(); diff --git a/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.test.ts index f6957cbe799..d492c41caa8 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.test.ts @@ -10,6 +10,10 @@ import { import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createUserForContact } from './createUserForContact'; +import { + mockAdmissionsClerkUser, + mockDocketClerkUser, +} from '@shared/test/mockAuthUsers'; describe('createUserForContact', () => { const USER_ID = '674fdded-1d17-4081-b9fa-950abc677cee'; @@ -24,7 +28,9 @@ describe('createUserForContact', () => { await expect( createUserForContact({ applicationContext, - caseEntity: new Case(MOCK_CASE, { applicationContext }), + caseEntity: new Case(MOCK_CASE, { + authorizedUser: mockDocketClerkUser, + }), contactId: USER_ID, email: 'testing@example.com', name: 'Bob Ross', @@ -35,10 +41,6 @@ describe('createUserForContact', () => { it('should call createNewPetitionerUser with the new user entity', async () => { const UPDATED_EMAIL = 'testing@example.com'; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.admissionsClerk, - }); - const caseEntity = new Case( { ...MOCK_CASE, @@ -53,7 +55,7 @@ describe('createUserForContact', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ); await createUserForContact({ @@ -79,10 +81,6 @@ describe('createUserForContact', () => { it('should return the caseEntity', async () => { const UPDATED_EMAIL = 'testing@example.com'; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.admissionsClerk, - }); - const caseEntity = new Case( { ...MOCK_CASE, @@ -96,7 +94,7 @@ describe('createUserForContact', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ); const updatedCase = await createUserForContact({ @@ -113,10 +111,6 @@ describe('createUserForContact', () => { it('should call associateUserWithCase', async () => { const UPDATED_EMAIL = 'testing@example.com'; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.admissionsClerk, - }); - const caseEntity = new Case( { ...MOCK_CASE, @@ -130,7 +124,7 @@ describe('createUserForContact', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ); await createUserForContact({ diff --git a/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts index 59813d4ad57..6e844654f56 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts @@ -10,6 +10,10 @@ import { petitionsClerkUser, } from '../../../../../shared/src/test/mockUsers'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { removeCounselFromRemovedPetitioner } from './removeCounselFromRemovedPetitioner'; describe('removeCounselFromRemovedPetitioner', () => { @@ -30,7 +34,7 @@ describe('removeCounselFromRemovedPetitioner', () => { await expect( removeCounselFromRemovedPetitioner({ applicationContext, - caseEntity: new Case(MOCK_CASE, { applicationContext }), + caseEntity: new Case(MOCK_CASE, { authorizedUser: mockPetitionerUser }), petitionerContactId: mockContactPrimaryId, }), ).rejects.toThrow('Unauthorized'); @@ -56,7 +60,7 @@ describe('removeCounselFromRemovedPetitioner', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); const updatedCase = await removeCounselFromRemovedPetitioner({ @@ -99,7 +103,7 @@ describe('removeCounselFromRemovedPetitioner', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); const updatedCase = await removeCounselFromRemovedPetitioner({ diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts index 40bb5f1624b..fa3155f4a69 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts @@ -16,6 +16,7 @@ import { Message } from '../../../../../shared/src/business/entities/Message'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { updateCaseAndAssociations } from './updateCaseAndAssociations'; import { v4 as uuidv4 } from 'uuid'; @@ -44,7 +45,7 @@ describe('updateCaseAndAssociations', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ) .validate() .toRawObject(); @@ -352,7 +353,7 @@ describe('updateCaseAndAssociations', () => { it('the docket docketNumberWithSuffix is updated because the case type has changed', async () => { updatedCase.caseType = CASE_TYPES_MAP.whistleblower; - // updatedCase.docketNumberSuffix = DOCKET_NUMBER_SUFFIXES.WHISTLEBLOWER; + await updateCaseAndAssociations({ applicationContext, caseToUpdate: updatedCase, @@ -595,7 +596,7 @@ describe('updateCaseAndAssociations', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); beforeAll(() => { @@ -713,7 +714,7 @@ describe('updateCaseAndAssociations', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); beforeAll(() => { diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts index c938b93fffb..6cc777e3f29 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts @@ -377,9 +377,7 @@ const updateCaseWorkItems = async ({ trialLocation: caseToUpdate.trialLocation || null, })); - const validWorkItems = WorkItem.validateRawCollection(updatedWorkItems, { - applicationContext, - }); + const validWorkItems = WorkItem.validateRawCollection(updatedWorkItems); // TODO: 10417, go look at validateRawCollection as a whole. return validWorkItems.map( validWorkItem => @@ -451,7 +449,9 @@ export const updateCaseAndAssociations = async ({ }): Promise => { const caseEntity: Case = caseToUpdate.validate ? caseToUpdate - : new Case(caseToUpdate, { applicationContext }); + : new Case(caseToUpdate, { + authorizedUser: applicationContext.getCurrentUser(), + }); const oldCaseEntity = await applicationContext .getPersistenceGateway() @@ -462,7 +462,9 @@ export const updateCaseAndAssociations = async ({ const validRawCaseEntity = caseEntity.validate().toRawObject(); - const validRawOldCaseEntity = new Case(oldCaseEntity, { applicationContext }) + const validRawOldCaseEntity = new Case(oldCaseEntity, { + authorizedUser: applicationContext.getCurrentUser(), + }) .validate() .toRawObject(); diff --git a/web-api/src/business/useCaseHelper/docketEntry/closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments.test.ts b/web-api/src/business/useCaseHelper/docketEntry/closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments.test.ts index 43f566b96a1..dc334ad67b4 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments.test.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments.test.ts @@ -9,6 +9,7 @@ import { MOCK_TRIAL_REGULAR } from '../../../../../shared/src/test/mockTrial'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments } from './closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments', () => { let mockCaseEntity; @@ -21,7 +22,7 @@ describe('closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments', () => { beforeEach(() => { mockCaseEntity = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); }); @@ -73,7 +74,7 @@ describe('closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments', () => { applicationContext, caseEntity: new Case( { ...MOCK_CASE, trialSessionId: undefined }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ), eventCode, }); @@ -98,7 +99,7 @@ describe('closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments', () => { applicationContext, caseEntity: new Case( { ...MOCK_CASE, trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ), eventCode, }); @@ -121,7 +122,7 @@ describe('closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments', () => { applicationContext, caseEntity: new Case( { ...MOCK_CASE, trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ), eventCode, }); @@ -144,7 +145,7 @@ describe('closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments', () => { applicationContext, caseEntity: new Case( { ...MOCK_CASE, trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ), eventCode, }), @@ -167,7 +168,7 @@ describe('closeCaseAndUpdateTrialSessionForEnteredAndServedDocuments', () => { applicationContext, caseEntity: new Case( { ...MOCK_CASE, trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ), eventCode, }); diff --git a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.test.ts b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.test.ts index 7bf155796b0..b0b3d0a0832 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.test.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.test.ts @@ -9,6 +9,7 @@ import { import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createAndServeNoticeDocketEntry } from './createAndServeNoticeDocketEntry'; import { docketClerk1User } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('createAndServeDocketEntry', () => { const mockDocketEntryId = '85a5b1c81eed44b6932a967af060597a'; @@ -18,7 +19,7 @@ describe('createAndServeDocketEntry', () => { { ...MOCK_CASE, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); beforeEach(() => { @@ -92,7 +93,7 @@ describe('createAndServeDocketEntry', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); await createAndServeNoticeDocketEntry(applicationContext, { diff --git a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts index f9e63fe9e8b..bac981e91e4 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts @@ -21,6 +21,7 @@ import { judgeUser, } from '../../../../../shared/src/test/mockUsers'; import { fileAndServeDocumentOnOneCase } from './fileAndServeDocumentOnOneCase'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('fileAndServeDocumentOnOneCase', () => { let mockCaseEntity; @@ -67,7 +68,7 @@ describe('fileAndServeDocumentOnOneCase', () => { beforeEach(() => { mockCaseEntity = new Case(MOCK_CASE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); applicationContext @@ -230,7 +231,7 @@ describe('fileAndServeDocumentOnOneCase', () => { caseEntity: new Case( { ...MOCK_CASE, leadDocketNumber: MOCK_CASE.docketNumber }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ), docketEntryEntity: mockDocketEntry, @@ -250,7 +251,7 @@ describe('fileAndServeDocumentOnOneCase', () => { caseEntity: new Case( { ...MOCK_CASE, leadDocketNumber: MOCK_CASE.docketNumber }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ), docketEntryEntity: mockDocketEntry, @@ -274,7 +275,7 @@ describe('fileAndServeDocumentOnOneCase', () => { caseEntity: new Case( { ...MOCK_CASE, leadDocketNumber: MOCK_CASE.docketNumber }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ), docketEntryEntity: mockDocketEntry, @@ -385,7 +386,7 @@ describe('fileAndServeDocumentOnOneCase', () => { trialLocation: 'Lubbock, Texas', }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts index 740bb99287e..66a6a4d63d4 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts @@ -90,7 +90,9 @@ export const fileAndServeDocumentOnOneCase = async ({ caseToUpdate: caseEntity, }); - return new Case(validRawCaseEntity, { applicationContext }); + return new Case(validRawCaseEntity, { + authorizedUser: applicationContext.getCurrentUser(), + }); }; const completeWorkItem = async ({ From fbe49cdbccca2363376a4ccb2525b1a352009613 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 09:59:53 -0700 Subject: [PATCH 071/523] 10417: Transition Case away from appContext --- .../generateChangeOfAddressHelper.ts | 4 ++- .../updateInitialFilingDocuments.test.ts | 32 ++++++++----------- ...serveDocumentAndGetPaperServicePdf.test.ts | 16 +++++----- .../service/createChangeItems.test.ts | 17 ++++++---- .../sendIrsSuperuserPetitionEmail.test.ts | 14 ++++---- .../service/sendServedPartiesEmails.test.ts | 17 +++++----- ...addDraftStampOrderDocketEntryInteractor.ts | 2 +- .../generateStampedCoversheetInteractor.ts | 4 ++- .../serveGeneratedNoticesOnCase.test.ts | 2 +- .../setNoticeOfChangeOfTrialJudge.test.ts | 2 +- ...NoticeOfChangeToInPersonProceeding.test.ts | 3 +- ...etNoticeOfChangeToRemoteProceeding.test.ts | 3 +- .../useCases/addCoversheetInteractor.test.ts | 9 ++++-- .../useCases/addCoversheetInteractor.ts | 6 ++-- .../useCases/addPetitionerToCaseInteractor.ts | 4 +-- .../archiveDraftDocumentInteractor.ts | 4 +-- .../useCases/blockCaseFromTrialInteractor.ts | 4 +-- .../deleteCounselFromCaseInteractor.test.ts | 5 +-- .../deleteCounselFromCaseInteractor.ts | 2 +- .../updateCounselOnCaseInteractor.ts | 6 ++-- .../addConsolidatedCaseInteractor.ts | 2 +- .../removeConsolidatedCasesInteractor.ts | 6 ++-- .../createCaseDeadlineInteractor.ts | 2 +- .../deleteCaseDeadlineInteractor.ts | 2 +- .../caseNote/deleteCaseNoteInteractor.ts | 2 +- .../caseNote/saveCaseNoteInteractor.ts | 4 +-- .../addDeficiencyStatisticInteractor.ts | 4 +-- .../deleteDeficiencyStatisticInteractor.ts | 6 ++-- .../updateDeficiencyStatisticInteractor.ts | 6 ++-- .../updateOtherStatisticsInteractor.ts | 6 ++-- .../checkForReadyForTrialCasesInteractor.ts | 4 ++- ...archiveCorrespondenceDocumentInteractor.ts | 2 +- .../fileCorrespondenceDocumentInteractor.ts | 2 +- .../updateCorrespondenceDocumentInteractor.ts | 2 +- ...leAndServeCourtIssuedDocumentInteractor.ts | 4 +-- .../serveCourtIssuedDocumentInteractor.ts | 4 +-- .../fileCourtIssuedOrderInteractor.ts | 2 +- .../updateCourtIssuedOrderInteractor.ts | 4 +-- .../useCases/createCaseFromPaperInteractor.ts | 4 +-- .../business/useCases/createCaseInteractor.ts | 4 +-- .../docketEntry/addPaperFilingInteractor.ts | 2 +- .../completeDocketEntryQCInteractor.ts | 2 +- .../docketEntry/editPaperFilingInteractor.ts | 9 ++++-- .../fileCourtIssuedDocketEntryInteractor.ts | 6 ++-- .../docketEntry/sealDocketEntryInteractor.ts | 2 +- .../strikeDocketEntryInteractor.ts | 2 +- .../unsealDocketEntryInteractor.ts | 2 +- .../updateCourtIssuedDocketEntryInteractor.ts | 2 +- .../updateDocketEntryMetaInteractor.ts | 4 +-- .../batchDownloadDocketEntriesInteractor.ts | 2 +- .../serveExternallyFiledDocumentInteractor.ts | 4 +-- .../fileExternalDocumentInteractor.ts | 4 +-- .../generateDocketRecordPdfInteractor.ts | 4 +-- .../getPublicDownloadPolicyUrlInteractor.ts | 4 ++- ...tor.addDocketEntryForPaymentStatus.test.ts | 5 +-- .../serveCaseToIrsInteractor.ts | 2 +- .../addCaseToTrialSessionInteractor.ts | 6 ++-- .../deleteTrialSessionInteractor.ts | 2 +- ...esForCaseTrialSessionCalendarInteractor.ts | 2 +- .../removeCaseFromTrialInteractor.ts | 6 ++-- .../serveThirtyDayNoticeInteractor.ts | 2 +- .../trialSessions/setForHearingInteractor.ts | 2 +- .../setTrialSessionCalendarInteractor.ts | 8 +++-- .../updateTrialSessionInteractor.ts | 2 +- .../user/updateAssociatedCaseWorker.ts | 8 +++-- .../updatePetitionerInformationInteractor.ts | 4 +-- .../workItems/completeWorkItemInteractor.ts | 2 +- .../workItems/setWorkItemAsReadInteractor.ts | 2 +- 68 files changed, 183 insertions(+), 147 deletions(-) diff --git a/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts b/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts index cb07c97a904..8f5eb7a3b82 100644 --- a/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts +++ b/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts @@ -52,7 +52,9 @@ export const generateChangeOfAddressHelper = async ({ applicationContext, docketNumber, }); - let caseEntity = new Case(userCase, { applicationContext }); + let caseEntity = new Case(userCase, { + authorizedUser: applicationContext.getCurrentUser(), + }); const practitionerName = updatedName || user.name; const practitionerObject = caseEntity.privatePractitioners diff --git a/web-api/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.test.ts b/web-api/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.test.ts index d277174b033..8edbe0dc25c 100644 --- a/web-api/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.test.ts +++ b/web-api/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.test.ts @@ -2,7 +2,6 @@ import { CONTACT_TYPES, INITIAL_DOCUMENT_TYPES, PARTY_TYPES, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { Case, @@ -11,6 +10,7 @@ import { import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_DOCUMENTS } from '../../../../../shared/src/test/mockDocketEntry'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; import { updateInitialFilingDocuments } from './updateInitialFilingDocuments'; describe('addNewInitialFilingToCase', () => { @@ -38,16 +38,10 @@ describe('addNewInitialFilingToCase', () => { let mockOriginalCase; let mockCaseToUpdate; - const petitionsClerkUser = { - name: 'petitions clerk', - role: ROLES.petitionsClerk, - userId: '54cddcd9-d012-4874-b74f-73732c95d42b', - }; - it('should add a new initial filing document to the case when the document does not exist on the original case', async () => { mockOriginalCase = new Case( { ...MOCK_CASE, docketEntries: [mockPetition] }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); mockCaseToUpdate = { @@ -57,7 +51,7 @@ describe('addNewInitialFilingToCase', () => { await updateInitialFilingDocuments({ applicationContext, - authorizedUser: petitionsClerkUser, + authorizedUser: mockPetitionsClerkUser, caseEntity: mockOriginalCase, caseToUpdate: mockCaseToUpdate, }); @@ -72,7 +66,7 @@ describe('addNewInitialFilingToCase', () => { it('should add a new STIN to the case when one does not exist on the original case', async () => { mockOriginalCase = new Case( { ...MOCK_CASE, docketEntries: [mockPetition] }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); mockCaseToUpdate = { @@ -82,7 +76,7 @@ describe('addNewInitialFilingToCase', () => { await updateInitialFilingDocuments({ applicationContext, - authorizedUser: petitionsClerkUser, + authorizedUser: mockPetitionsClerkUser, caseEntity: mockOriginalCase, caseToUpdate: mockCaseToUpdate, }); @@ -97,7 +91,7 @@ describe('addNewInitialFilingToCase', () => { it('should set isFileAttached and isPaper to true', async () => { mockOriginalCase = new Case( { ...MOCK_CASE, docketEntries: [mockPetition] }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); mockCaseToUpdate = { @@ -107,7 +101,7 @@ describe('addNewInitialFilingToCase', () => { await updateInitialFilingDocuments({ applicationContext, - authorizedUser: petitionsClerkUser, + authorizedUser: mockPetitionsClerkUser, caseEntity: mockOriginalCase, caseToUpdate: mockCaseToUpdate, }); @@ -135,7 +129,7 @@ describe('addNewInitialFilingToCase', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); mockCaseToUpdate = { @@ -154,7 +148,7 @@ describe('addNewInitialFilingToCase', () => { await updateInitialFilingDocuments({ applicationContext, - authorizedUser: petitionsClerkUser, + authorizedUser: mockPetitionsClerkUser, caseEntity: mockOriginalCase, caseToUpdate: mockCaseToUpdate, }); @@ -175,12 +169,12 @@ describe('addNewInitialFilingToCase', () => { ...MOCK_CASE, docketEntries: [...MOCK_CASE.docketEntries, mockRQT], }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await updateInitialFilingDocuments({ applicationContext, - authorizedUser: petitionsClerkUser, + authorizedUser: mockPetitionsClerkUser, caseEntity: mockOriginalCase, caseToUpdate: mockCaseToUpdate, }); @@ -194,7 +188,7 @@ describe('addNewInitialFilingToCase', () => { it('should remove the original document and add the new one to the case when the document has been re-added', async () => { mockOriginalCase = new Case( { ...MOCK_CASE, docketEntries: [...MOCK_CASE.docketEntries, mockRQT] }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); const mockNewRQT = { @@ -208,7 +202,7 @@ describe('addNewInitialFilingToCase', () => { await updateInitialFilingDocuments({ applicationContext, - authorizedUser: petitionsClerkUser, + authorizedUser: mockPetitionsClerkUser, caseEntity: mockOriginalCase, caseToUpdate: mockCaseToUpdate, }); diff --git a/web-api/src/business/useCaseHelper/serveDocumentAndGetPaperServicePdf.test.ts b/web-api/src/business/useCaseHelper/serveDocumentAndGetPaperServicePdf.test.ts index b93a93ac537..d41cefa08d7 100644 --- a/web-api/src/business/useCaseHelper/serveDocumentAndGetPaperServicePdf.test.ts +++ b/web-api/src/business/useCaseHelper/serveDocumentAndGetPaperServicePdf.test.ts @@ -1,5 +1,3 @@ -import { testPdfDoc } from '../../../../shared/src/business/test/getFakeFile'; - import { Case, getContactPrimary, @@ -10,7 +8,9 @@ import { } from '../../../../shared/src/test/mockCase'; import { SERVICE_INDICATOR_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { serveDocumentAndGetPaperServicePdf } from './serveDocumentAndGetPaperServicePdf'; +import { testPdfDoc } from '../../../../shared/src/business/test/getFakeFile'; describe('serveDocumentAndGetPaperServicePdf', () => { let caseEntity; @@ -19,7 +19,7 @@ describe('serveDocumentAndGetPaperServicePdf', () => { const mockDocketEntryId = 'cf105788-5d34-4451-aa8d-dfd9a851b675'; beforeEach(() => { - caseEntity = new Case(MOCK_CASE, { applicationContext }); + caseEntity = new Case(MOCK_CASE, { authorizedUser: mockDocketClerkUser }); applicationContext.getStorageClient().getObject.mockReturnValue({ promise: () => ({ @@ -87,7 +87,7 @@ describe('serveDocumentAndGetPaperServicePdf', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const result = await serveDocumentAndGetPaperServicePdf({ @@ -129,11 +129,11 @@ describe('serveDocumentAndGetPaperServicePdf', () => { { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER }, ], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); const secondCaseEntity = new Case(MOCK_LEAD_CASE_WITH_PAPER_SERVICE, { - applicationContext, + authorizedUser: mockDocketClerkUser, }); const result = await serveDocumentAndGetPaperServicePdf({ @@ -181,7 +181,7 @@ describe('serveDocumentAndGetPaperServicePdf', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); @@ -214,7 +214,7 @@ describe('serveDocumentAndGetPaperServicePdf', () => { ], }, { - applicationContext, + authorizedUser: mockDocketClerkUser, }, ); diff --git a/web-api/src/business/useCaseHelper/service/createChangeItems.test.ts b/web-api/src/business/useCaseHelper/service/createChangeItems.test.ts index 1308ca3b8da..e80f337e5e6 100644 --- a/web-api/src/business/useCaseHelper/service/createChangeItems.test.ts +++ b/web-api/src/business/useCaseHelper/service/createChangeItems.test.ts @@ -6,6 +6,7 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generateAndServeDocketEntry } from './createChangeItems'; +import { mockAdmissionsClerkUser } from '@shared/test/mockAuthUsers'; describe('generateAndServeDocketEntry', () => { let testCaseEntity; @@ -17,7 +18,9 @@ describe('generateAndServeDocketEntry', () => { name: 'Test Admissionsclerk', role: 'Admissionsclerk', }; - testCaseEntity = new Case(MOCK_CASE, { applicationContext }); + testCaseEntity = new Case(MOCK_CASE, { + authorizedUser: mockAdmissionsClerkUser, + }); testArguments = { applicationContext, barNumber: 'DD44444', @@ -104,7 +107,7 @@ describe('generateAndServeDocketEntry', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ), privatePractitionersRepresentingContact: true, user: testUser, @@ -127,7 +130,7 @@ describe('generateAndServeDocketEntry', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ), privatePractitionersRepresentingContact: true, user: testUser, @@ -150,7 +153,7 @@ describe('generateAndServeDocketEntry', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ), user: { ...testUser, @@ -176,7 +179,7 @@ describe('generateAndServeDocketEntry', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ), user: { ...testUser, @@ -202,7 +205,7 @@ describe('generateAndServeDocketEntry', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ), user: { ...testUser, @@ -236,7 +239,7 @@ describe('generateAndServeDocketEntry', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockAdmissionsClerkUser }, ), docketMeta: undefined, user: { diff --git a/web-api/src/business/useCaseHelper/service/sendIrsSuperuserPetitionEmail.test.ts b/web-api/src/business/useCaseHelper/service/sendIrsSuperuserPetitionEmail.test.ts index 7cc888f1e6b..cefe2fbb1ff 100644 --- a/web-api/src/business/useCaseHelper/service/sendIrsSuperuserPetitionEmail.test.ts +++ b/web-api/src/business/useCaseHelper/service/sendIrsSuperuserPetitionEmail.test.ts @@ -44,7 +44,7 @@ describe('sendIrsSuperuserPetitionEmail', () => { preferredTrialCity: 'Somecity, ST', privatePractitioners: [], }, - { applicationContext }, + { authorizedUser: undefined }, ); await sendIrsSuperuserPetitionEmail({ @@ -103,7 +103,7 @@ describe('sendIrsSuperuserPetitionEmail', () => { ], procedureType: 'Regular', }, - { applicationContext }, + { authorizedUser: undefined }, ); await sendIrsSuperuserPetitionEmail({ @@ -155,7 +155,7 @@ describe('sendIrsSuperuserPetitionEmail', () => { }, ], }, - { applicationContext }, + { authorizedUser: undefined }, ); await sendIrsSuperuserPetitionEmail({ @@ -197,7 +197,7 @@ describe('sendIrsSuperuserPetitionEmail', () => { ], privatePractitioners: [], }, - { applicationContext }, + { authorizedUser: undefined }, ); await sendIrsSuperuserPetitionEmail({ @@ -235,7 +235,7 @@ describe('sendIrsSuperuserPetitionEmail', () => { preferredTrialCity: 'Fake Trial Location, ST', privatePractitioners: [], }, - { applicationContext }, + { authorizedUser: undefined }, ); await sendIrsSuperuserPetitionEmail({ @@ -273,7 +273,7 @@ describe('sendIrsSuperuserPetitionEmail', () => { preferredTrialCity: '', privatePractitioners: [], }, - { applicationContext }, + { authorizedUser: undefined }, ); await sendIrsSuperuserPetitionEmail({ @@ -310,7 +310,7 @@ describe('sendIrsSuperuserPetitionEmail', () => { preferredTrialCity: '', privatePractitioners: [], }, - { applicationContext }, + { authorizedUser: undefined }, ); await expect( diff --git a/web-api/src/business/useCaseHelper/service/sendServedPartiesEmails.test.ts b/web-api/src/business/useCaseHelper/service/sendServedPartiesEmails.test.ts index c10d2837eb7..7150d3b22d7 100644 --- a/web-api/src/business/useCaseHelper/service/sendServedPartiesEmails.test.ts +++ b/web-api/src/business/useCaseHelper/service/sendServedPartiesEmails.test.ts @@ -7,6 +7,7 @@ import { import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; import { sendServedPartiesEmails } from './sendServedPartiesEmails'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -40,7 +41,7 @@ describe('sendServedPartiesEmails', () => { petitioners: MOCK_CASE.petitioners, status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await sendServedPartiesEmails({ @@ -85,7 +86,7 @@ describe('sendServedPartiesEmails', () => { petitioners: MOCK_CASE.petitioners, status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await sendServedPartiesEmails({ @@ -126,7 +127,7 @@ describe('sendServedPartiesEmails', () => { docketNumberWithSuffix: '123-20L', status: CASE_STATUS_TYPES.new, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await sendServedPartiesEmails({ @@ -166,7 +167,7 @@ describe('sendServedPartiesEmails', () => { docketNumberWithSuffix: '123-20L', status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await sendServedPartiesEmails({ @@ -204,7 +205,7 @@ describe('sendServedPartiesEmails', () => { procedureType: 'Regular', status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await sendServedPartiesEmails({ @@ -236,7 +237,7 @@ describe('sendServedPartiesEmails', () => { docketNumberWithSuffix: '123-20L', status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await expect( @@ -274,7 +275,7 @@ describe('sendServedPartiesEmails', () => { procedureType: 'Regular', status: CASE_STATUS_TYPES.generalDocket, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); const servedParties = { @@ -328,7 +329,7 @@ describe('sendServedPartiesEmails', () => { docketNumberWithSuffix: '123-20L', status: CASE_STATUS_TYPES.new, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await sendServedPartiesEmails({ diff --git a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts index 66f63525a66..c452094d5af 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts @@ -58,7 +58,7 @@ export const addDraftStampOrderDocketEntry = async ( applicationContext, docketNumber, }); - const caseEntity = new Case(caseRecord, { applicationContext }); + const caseEntity = new Case(caseRecord, { authorizedUser: user }); const originalDocketEntryEntity = caseEntity.docketEntries.find( docketEntry => docketEntry.docketEntryId === originalDocketEntryId, ); diff --git a/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.ts b/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.ts index d5c2ab3341a..50ef482ca1e 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.ts @@ -66,7 +66,9 @@ export const generateStampedCoversheetInteractor = async ( docketNumber, }); - const caseEntity = new Case(caseRecord, { applicationContext }); + const caseEntity = new Case(caseRecord, { + authorizedUser: applicationContext.getCurrentUser(), + }); const motionDocketEntryEntity = caseEntity.getDocketEntryById({ docketEntryId, diff --git a/web-api/src/business/useCaseHelper/trialSessions/serveGeneratedNoticesOnCase.test.ts b/web-api/src/business/useCaseHelper/trialSessions/serveGeneratedNoticesOnCase.test.ts index c1181620342..6aaa23b6680 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/serveGeneratedNoticesOnCase.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/serveGeneratedNoticesOnCase.test.ts @@ -10,7 +10,7 @@ import { applicationContext } from '../../../../../shared/src/business/test/crea import { serveGeneratedNoticesOnCase } from './serveGeneratedNoticesOnCase'; describe('serveGeneratedNoticesOnCase', () => { - const mockOpenCaseEntity = new Case(MOCK_CASE, { applicationContext }); + const mockOpenCaseEntity = new Case(MOCK_CASE, { authorizedUser: undefined }); const mockNoticeDocketEntryEntity = new DocketEntry( { diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts index d201b559bf2..d1226209197 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts @@ -39,7 +39,7 @@ describe('setNoticeOfChangeOfTrialJudge', () => { trialDate: '2019-03-01T21:42:29.073Z', trialSessionId, }, - { applicationContext }, + { authorizedUser: undefined }, ); beforeEach(() => { diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts index 040122ae8f6..8e9edd108c1 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts @@ -4,6 +4,7 @@ import { MOCK_TRIAL_INPERSON } from '../../../../../shared/src/test/mockTrial'; import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getFakeFile } from '../../../../../shared/src/business/test/getFakeFile'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { petitionsClerkUser } from '../../../../../shared/src/test/mockUsers'; import { setNoticeOfChangeToInPersonProceeding } from './setNoticeOfChangeToInPersonProceeding'; @@ -22,7 +23,7 @@ describe('setNoticeOfChangeToInPersonProceeding', () => { trialDate: '2019-03-01T21:42:29.073Z', trialSessionId: mockTrialSessionId, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); beforeEach(() => { diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts index d7ea86828e9..6f33a8c7ffc 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts @@ -6,6 +6,7 @@ import { } from '../../../../../shared/src/test/mockTrial'; import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { petitionsClerkUser } from '../../../../../shared/src/test/mockUsers'; import { setNoticeOfChangeToRemoteProceeding } from './setNoticeOfChangeToRemoteProceeding'; @@ -19,7 +20,7 @@ describe('setNoticeOfChangeToRemoteProceeding', () => { trialDate: '2019-03-01T21:42:29.073Z', trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId, }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ); beforeEach(() => { diff --git a/web-api/src/business/useCases/addCoversheetInteractor.test.ts b/web-api/src/business/useCases/addCoversheetInteractor.test.ts index 4df920a48a2..a69894f0700 100644 --- a/web-api/src/business/useCases/addCoversheetInteractor.test.ts +++ b/web-api/src/business/useCases/addCoversheetInteractor.test.ts @@ -10,6 +10,7 @@ import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { addCoverToPdf } from './addCoverToPdf'; import { addCoversheetInteractor } from './addCoversheetInteractor'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { testPdfDoc } from '../../../../shared/src/business/test/getFakeFile'; jest.mock('./addCoverToPdf', () => ({ @@ -183,7 +184,9 @@ describe('addCoversheetInteractor', () => { it('should not call getCaseByDocketNumber if case entity is passed in', async () => { await addCoversheetInteractor(applicationContext, { - caseEntity: new Case(testingCaseData, { applicationContext }), + caseEntity: new Case(testingCaseData, { + authorizedUser: mockDocketClerkUser, + }), docketEntryId: mockDocketEntryId, docketNumber: MOCK_CASE.docketNumber, } as any); @@ -321,7 +324,7 @@ describe('addCoversheetInteractor', () => { ...testingCaseData, eventCode: SIMULTANEOUS_DOCUMENT_EVENT_CODES[0], }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ), docketEntryId: mockDocketEntryId, docketNumber: MOCK_CASE.docketNumber, @@ -378,7 +381,7 @@ describe('addCoversheetInteractor', () => { ...testingCaseData, documentTitle: 'Super Duper Simultaneous but not really', }, - { applicationContext }, + { authorizedUser: mockDocketClerkUser }, ), docketEntryId: mockDocketEntryId, docketNumber: MOCK_CASE.docketNumber, diff --git a/web-api/src/business/useCases/addCoversheetInteractor.ts b/web-api/src/business/useCases/addCoversheetInteractor.ts index e0d31f6f6d9..cb12900d9c0 100644 --- a/web-api/src/business/useCases/addCoversheetInteractor.ts +++ b/web-api/src/business/useCases/addCoversheetInteractor.ts @@ -40,7 +40,9 @@ export const addCoversheetInteractor = async ( docketNumber, }); - caseEntity = new Case(caseRecord, { applicationContext }); + caseEntity = new Case(caseRecord, { + authorizedUser: applicationContext.getCurrentUser(), + }); } let pdfData; @@ -105,7 +107,7 @@ export const addCoversheetInteractor = async ( docketNumber: caseDocketNumber, }); consolidatedCaseEntity = new Case(caseRecord, { - applicationContext, + authorizedUser: applicationContext.getCurrentUser(), }); } diff --git a/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts b/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts index 7729e8836bd..9ec3fe176a7 100644 --- a/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts +++ b/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts @@ -38,7 +38,7 @@ export const addPetitionerToCase = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); if (caseEntity.status === CASE_STATUS_TYPES.new) { throw new Error( @@ -59,7 +59,7 @@ export const addPetitionerToCase = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const addPetitionerToCaseInteractor = withLocking( diff --git a/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts b/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts index e55c02fd3c0..47d1b156775 100644 --- a/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts +++ b/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts @@ -35,7 +35,7 @@ export const archiveDraftDocument = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const docketEntryToArchive = caseEntity.getDocketEntryById({ docketEntryId, @@ -59,7 +59,7 @@ export const archiveDraftDocument = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const archiveDraftDocumentInteractor = withLocking( diff --git a/web-api/src/business/useCases/blockCaseFromTrialInteractor.ts b/web-api/src/business/useCases/blockCaseFromTrialInteractor.ts index 01882ae76d9..28a20e54493 100644 --- a/web-api/src/business/useCases/blockCaseFromTrialInteractor.ts +++ b/web-api/src/business/useCases/blockCaseFromTrialInteractor.ts @@ -32,7 +32,7 @@ export const blockCaseFromTrial = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); caseEntity.setAsBlocked(reason); @@ -50,7 +50,7 @@ export const blockCaseFromTrial = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const blockCaseFromTrialInteractor = withLocking( diff --git a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts index 98ea12947f9..db5f5151a26 100644 --- a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts +++ b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts @@ -12,6 +12,7 @@ import { deleteCounselFromCaseInteractor, setupServiceIndicatorForUnrepresentedPetitioners, } from './deleteCounselFromCaseInteractor'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { petitionerUser } from '@shared/test/mockUsers'; describe('deleteCounselFromCaseInteractor', () => { @@ -374,7 +375,7 @@ describe('deleteCounselFromCaseInteractor', () => { }; const result = setupServiceIndicatorForUnrepresentedPetitioners( - new Case(mockCase, { applicationContext }), + new Case(mockCase, { authorizedUser: mockDocketClerkUser }), ); expect(result.petitioners[0].serviceIndicator).toBeUndefined(); @@ -402,7 +403,7 @@ describe('deleteCounselFromCaseInteractor', () => { }; const result = setupServiceIndicatorForUnrepresentedPetitioners( - new Case(mockCase, { applicationContext }), + new Case(mockCase, { authorizedUser: mockDocketClerkUser }), ); expect(result.petitioners[0].serviceIndicator).toEqual( diff --git a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts index b4b3804b959..1f63e2c392e 100644 --- a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts +++ b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts @@ -33,7 +33,7 @@ export const deleteCounselFromCase = async ( userId, }); - let caseEntity = new Case(caseToUpdate, { applicationContext }); + let caseEntity = new Case(caseToUpdate, { authorizedUser: user }); if (userToDelete.role === ROLES.privatePractitioner) { caseEntity.removePrivatePractitioner(userToDelete); diff --git a/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts b/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts index 53b38f78e6f..6bb247f80ca 100644 --- a/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts +++ b/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts @@ -54,7 +54,7 @@ const updateCounselOnCase = async ( userId, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser: user }); if (userToUpdate.role === ROLES.privatePractitioner) { caseEntity.updatePrivatePractitioner({ @@ -90,7 +90,9 @@ const updateCounselOnCase = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const updateCounselOnCaseInteractor = withLocking( diff --git a/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts b/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts index 4fc650f4e33..7d18b45f680 100644 --- a/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts +++ b/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts @@ -86,7 +86,7 @@ export const addConsolidatedCase = async ( const updateCasePromises: Promise[] = []; casesToUpdate.forEach(caseInCasesToUpdate => { - const caseEntity = new Case(caseInCasesToUpdate, { applicationContext }); + const caseEntity = new Case(caseInCasesToUpdate, { authorizedUser: user }); caseEntity.setLeadCase(newLeadCase.docketNumber); updateCasePromises.push( diff --git a/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts b/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts index 2079135d7bf..ae65c392523 100644 --- a/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts +++ b/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts @@ -61,7 +61,7 @@ export const removeConsolidatedCases = async ( for (let newConsolidatedCaseToUpdate of newConsolidatedCases) { const caseEntity = new Case(newConsolidatedCaseToUpdate, { - applicationContext, + authorizedUser: user, }); caseEntity.setLeadCase(newLeadCase.docketNumber); @@ -75,7 +75,7 @@ export const removeConsolidatedCases = async ( } else if (newConsolidatedCases.length == 1) { // a case cannot be consolidated with itself const caseEntity = new Case(newConsolidatedCases[0], { - applicationContext, + authorizedUser: user, }); caseEntity.removeConsolidation(); @@ -101,7 +101,7 @@ export const removeConsolidatedCases = async ( ); } - const caseEntity = new Case(caseToRemove, { applicationContext }); + const caseEntity = new Case(caseToRemove, { authorizedUser: user }); caseEntity.removeConsolidation(); updateCasePromises.push( diff --git a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts index df116ae6fa4..b2dac81a89e 100644 --- a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts +++ b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts @@ -24,7 +24,7 @@ export const createCaseDeadline = async ( applicationContext, docketNumber: caseDeadline.docketNumber, }); - let caseEntity = new Case(caseDetail, { applicationContext }); + let caseEntity = new Case(caseDetail, { authorizedUser: user }); const newCaseDeadline = new CaseDeadline( { diff --git a/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts b/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts index 396fe93da7b..06c6cb0408b 100644 --- a/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts +++ b/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts @@ -33,7 +33,7 @@ export const deleteCaseDeadline = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - let updatedCase = new Case(caseToUpdate, { applicationContext }); + let updatedCase = new Case(caseToUpdate, { authorizedUser: user }); await applicationContext.getPersistenceGateway().deleteCaseDeadline({ applicationContext, diff --git a/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.ts b/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.ts index b498695e62f..0191920b3a1 100644 --- a/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.ts +++ b/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.ts @@ -41,7 +41,7 @@ export const deleteCaseNote = async ( caseToUpdate: caseRecord, }); - return new Case(result, { applicationContext }).validate().toRawObject(); + return new Case(result, { authorizedUser: user }).validate().toRawObject(); }; export const deleteCaseNoteInteractor = withLocking( diff --git a/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts b/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts index 7be7e75a943..26d6dde1f65 100644 --- a/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts +++ b/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts @@ -35,7 +35,7 @@ export const saveCaseNote = async ( const caseToUpdate = new Case( { ...caseRecord, caseNote }, { - applicationContext, + authorizedUser: user, }, ) .validate() @@ -48,7 +48,7 @@ export const saveCaseNote = async ( caseToUpdate, }); - return new Case(result, { applicationContext }).validate().toRawObject(); + return new Case(result, { authorizedUser: user }).validate().toRawObject(); }; export const saveCaseNoteInteractor = withLocking( diff --git a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts index 3a7d4663687..510b5c956e7 100644 --- a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts @@ -73,7 +73,7 @@ export const addDeficiencyStatistic = async ( yearOrPeriod, }).validate(); - const newCase = new Case(oldCase, { applicationContext }); + const newCase = new Case(oldCase, { authorizedUser }); newCase.addStatistic(statisticEntity); const updatedCase = await applicationContext @@ -83,7 +83,7 @@ export const addDeficiencyStatistic = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const addDeficiencyStatisticInteractor = withLocking( diff --git a/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.ts b/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.ts index f538b3a1c4a..fcac8f0a09c 100644 --- a/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.ts @@ -30,7 +30,7 @@ export const deleteDeficiencyStatistic = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { applicationContext }); + const newCase = new Case(oldCase, { authorizedUser: user }); newCase.deleteStatistic(statisticId); const updatedCase = await applicationContext @@ -40,7 +40,9 @@ export const deleteDeficiencyStatistic = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const deleteDeficiencyStatisticInteractor = withLocking( diff --git a/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts b/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts index 73fdac65af3..20a847dcbfc 100644 --- a/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts @@ -77,7 +77,7 @@ export const updateDeficiencyStatistic = async ( yearOrPeriod, }).validate(); - const newCase = new Case(oldCase, { applicationContext }); + const newCase = new Case(oldCase, { authorizedUser: user }); newCase.updateStatistic(statisticEntity, statisticId); const updatedCase = await applicationContext @@ -87,7 +87,9 @@ export const updateDeficiencyStatistic = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const updateDeficiencyStatisticInteractor = withLocking( diff --git a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts index 428861ce94b..55bda9e9311 100644 --- a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts @@ -37,7 +37,7 @@ export const updateOtherStatistics = async ( const newCase = new Case( { ...oldCase, damages, litigationCosts }, - { applicationContext }, + { authorizedUser: user }, ); const updatedCase = await applicationContext @@ -47,7 +47,9 @@ export const updateOtherStatistics = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const updateOtherStatisticsInteractor = withLocking( diff --git a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts index e9d0241e660..e3f8ea1970c 100644 --- a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts +++ b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts @@ -80,7 +80,9 @@ export const checkForReadyForTrialCasesInteractor = async ( }); if (caseToCheck) { - const caseEntity = new Case(caseToCheck, { applicationContext }); + const caseEntity = new Case(caseToCheck, { + authorizedUser: applicationContext.getCurrentUser(), + }); if (caseEntity.status === CASE_STATUS_TYPES.generalDocket) { caseEntity.checkForReadyForTrial(); if ( diff --git a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts index 7d5cd7f7108..9d9fd4b11ff 100644 --- a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts +++ b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts @@ -38,7 +38,7 @@ export const archiveCorrespondenceDocument = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser: user }); const correspondenceToArchiveEntity = caseEntity.correspondence.find( c => c.correspondenceId === correspondenceId, ); diff --git a/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.ts b/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.ts index 97b05446386..c413b9545c6 100644 --- a/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.ts +++ b/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.ts @@ -45,7 +45,7 @@ export const fileCorrespondenceDocumentInteractor = async ( throw new NotFoundError(`Case ${docketNumber} was not found`); } - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const correspondenceEntity = new Correspondence({ ...documentMetadata, diff --git a/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.ts b/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.ts index 061a1fc1382..f3811b63d9c 100644 --- a/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.ts +++ b/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.ts @@ -33,7 +33,7 @@ export const updateCorrespondenceDocumentInteractor = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const currentCorrespondenceDocument = caseEntity.getCorrespondenceById({ correspondenceId: documentMetadata.correspondenceId, diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts index 95ee0b24f93..362e2bb1e38 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts @@ -66,7 +66,7 @@ export const fileAndServeCourtIssuedDocument = async ( docketNumber: subjectCaseDocketNumber, }); - const subjectCaseEntity = new Case(subjectCase, { applicationContext }); + const subjectCaseEntity = new Case(subjectCase, { authorizedUser }); const docketEntryToServe = subjectCaseEntity.getDocketEntryById({ docketEntryId, @@ -139,7 +139,7 @@ export const fileAndServeCourtIssuedDocument = async ( docketNumber, }); - caseEntities.push(new Case(caseToUpdate, { applicationContext })); + caseEntities.push(new Case(caseToUpdate, { authorizedUser })); } caseEntities = await Promise.all( diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts index 24c847163e1..5aa30cf023e 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts @@ -58,7 +58,7 @@ export const serveCourtIssuedDocument = async ( throw new NotFoundError(`Case ${subjectCaseDocketNumber} was not found.`); } - const subjectCaseEntity = new Case(subjectCase, { applicationContext }); + const subjectCaseEntity = new Case(subjectCase, { authorizedUser }); const docketEntryToServe = subjectCaseEntity.getDocketEntryById({ docketEntryId, @@ -132,7 +132,7 @@ export const serveCourtIssuedDocument = async ( docketNumber, }); - caseEntities.push(new Case(caseToUpdate, { applicationContext })); + caseEntities.push(new Case(caseToUpdate, { authorizedUser })); } caseEntities = await Promise.all( diff --git a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts index 544c278ecc4..69529362fa5 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts @@ -43,7 +43,7 @@ export const fileCourtIssuedOrder = async ( applicationContext, docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const shouldScrapePDFContents = !documentMetadata.documentContents; diff --git a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts index 3c073ac03d2..869cbb6424e 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts @@ -43,7 +43,7 @@ export const updateCourtIssuedOrder = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const currentDocument = caseEntity.getDocketEntryById({ docketEntryId: docketEntryIdToEdit, @@ -133,7 +133,7 @@ export const updateCourtIssuedOrder = async ( caseToUpdate: caseEntity, }); - return new Case(result, { applicationContext }).validate().toRawObject(); + return new Case(result, { authorizedUser }).validate().toRawObject(); }; export const updateCourtIssuedOrderInteractor = withLocking( diff --git a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts index 626ef02b810..bffe767e5b7 100644 --- a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts +++ b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts @@ -109,7 +109,7 @@ export const createCaseFromPaperInteractor = async ( userId: user.userId, }, { - applicationContext, + authorizedUser, isNewCase: true, }, ); @@ -294,5 +294,5 @@ export const createCaseFromPaperInteractor = async ( }), ]); - return new Case(caseToAdd, { applicationContext }).toRawObject(); + return new Case(caseToAdd, { authorizedUser }).toRawObject(); }; diff --git a/web-api/src/business/useCases/createCaseInteractor.ts b/web-api/src/business/useCases/createCaseInteractor.ts index 6fe55552abd..fec6318eaf9 100644 --- a/web-api/src/business/useCases/createCaseInteractor.ts +++ b/web-api/src/business/useCases/createCaseInteractor.ts @@ -136,7 +136,7 @@ export const createCaseInteractor = async ( privatePractitioners, }, { - applicationContext, + authorizedUser, isNewCase: true, }, ); @@ -294,5 +294,5 @@ export const createCaseInteractor = async ( docketNumber: caseToAdd.docketNumber, }); - return new Case(caseToAdd, { applicationContext }).toRawObject(); + return new Case(caseToAdd, { authorizedUser }).toRawObject(); }; diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts index 4aff505b950..2cf9857c7b4 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts @@ -92,7 +92,7 @@ export const addPaperFiling = async ( docketNumber, }); - let caseEntity = new Case(rawCase, { applicationContext }); + let caseEntity = new Case(rawCase, { authorizedUser }); const docketEntryEntity = new DocketEntry( { diff --git a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts index 5af74de9f72..41659230568 100644 --- a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts @@ -90,7 +90,7 @@ const completeDocketEntryQC = async ( docketNumber, }); - let caseEntity = new Case(caseToUpdate, { applicationContext }); + let caseEntity = new Case(caseToUpdate, { authorizedUser }); const { index: docketRecordIndexUpdated } = caseEntity.docketEntries.find( record => record.docketEntryId === docketEntryId, ); diff --git a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts index 4a188c045c8..0c870254a31 100644 --- a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts @@ -164,7 +164,10 @@ const multiDocketServeStrategy = async ({ ); const consolidatedCaseEntities = consolidatedCaseRecords.map( - consolidatedCase => new Case(consolidatedCase, { applicationContext }), + consolidatedCase => + new Case(consolidatedCase, { + authorizedUser: applicationContext.getCurrentUser(), + }), ); validateMultiDocketPaperFilingRequest({ @@ -494,7 +497,9 @@ const getDocketEntryToEdit = async ({ docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { + authorizedUser: applicationContext.getCurrentUser(), + }); const docketEntryEntity = caseEntity.getDocketEntryById({ docketEntryId, diff --git a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts index 83cbbf4bae8..d297533c10e 100644 --- a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts @@ -50,7 +50,7 @@ export const fileCourtIssuedDocketEntry = async ( }); let subjectCaseToUpdateEntity = new Case(subjectCaseToUpdate, { - applicationContext, + authorizedUser, }); const subjectDocketEntry = subjectCaseToUpdateEntity.getDocketEntryById({ @@ -84,7 +84,7 @@ export const fileCourtIssuedDocketEntry = async ( docketNumber, }); - let caseEntity = new Case(caseToUpdate, { applicationContext }); + let caseEntity = new Case(caseToUpdate, { authorizedUser }); const docketEntryEntity = new DocketEntry( { @@ -201,7 +201,7 @@ export const fileCourtIssuedDocketEntry = async ( }); const subjectCase = new Case(rawSubjectCase, { - applicationContext, + authorizedUser, }).validate(); return subjectCase.toRawObject(); }; diff --git a/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.ts index b531b6ae923..0f727a17493 100644 --- a/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.ts @@ -49,7 +49,7 @@ export const sealDocketEntryInteractor = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const docketEntryEntity = caseEntity.getDocketEntryById({ docketEntryId, diff --git a/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.ts index 4f3c342446d..b26b58767dd 100644 --- a/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.ts @@ -40,7 +40,7 @@ export const strikeDocketEntryInteractor = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const docketEntryEntity = caseEntity.getDocketEntryById({ docketEntryId, diff --git a/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.ts index b7ac244a246..3023d54006c 100644 --- a/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/unsealDocketEntryInteractor.ts @@ -40,7 +40,7 @@ export const unsealDocketEntryInteractor = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const docketEntryEntity = caseEntity.getDocketEntryById({ docketEntryId, diff --git a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts index 0983d77f9a6..c59d95dd698 100644 --- a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts @@ -38,7 +38,7 @@ export const updateCourtIssuedDocketEntry = async ( docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const currentDocketEntry = caseEntity.getDocketEntryById({ docketEntryId, diff --git a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts index f5c266cd1d8..2dfa4e94c1f 100644 --- a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts @@ -46,7 +46,7 @@ export const updateDocketEntryMeta = async ( throw new NotFoundError(`Case ${docketNumber} was not found.`); } - let caseEntity = new Case(caseToUpdate, { applicationContext }); + let caseEntity = new Case(caseToUpdate, { authorizedUser: user }); const originalDocketEntry: RawDocketEntry = caseEntity.getDocketEntryById({ docketEntryId: docketEntryMeta.docketEntryId, @@ -192,7 +192,7 @@ export const updateDocketEntryMeta = async ( caseToUpdate: caseEntity, }); - return new Case(result, { applicationContext }).validate().toRawObject(); + return new Case(result, { authorizedUser: user }).validate().toRawObject(); }; export const shouldGenerateCoversheetForDocketEntry = ({ diff --git a/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts b/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts index d179bdc68d5..062bab0faad 100644 --- a/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts +++ b/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts @@ -56,7 +56,7 @@ const batchDownloadDocketEntriesHelper = async ( const caseFolder = `${docketNumber}, ${caseTitle}`; const zipName = `${caseFolder}.zip`; - const caseEntity = new Case(caseToBatch, { applicationContext }); + const caseEntity = new Case(caseToBatch, { authorizedUser }); const documentsToProcess = documentsSelectedForDownload.map(docketEntryId => caseEntity.getDocketEntryById({ diff --git a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts index e78051a7bad..1c77358f795 100644 --- a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts +++ b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts @@ -57,7 +57,7 @@ export const serveExternallyFiledDocument = async ( docketNumber: subjectCaseDocketNumber, }); - const subjectCaseEntity = new Case(subjectCase, { applicationContext }); + const subjectCaseEntity = new Case(subjectCase, { authorizedUser }); const originalSubjectDocketEntry = subjectCaseEntity.getDocketEntryById({ docketEntryId, @@ -128,7 +128,7 @@ export const serveExternallyFiledDocument = async ( }); const caseEntity = new Case(rawCaseToUpdate, { - applicationContext, + authorizedUser, }); const isSubjectCase = diff --git a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts index ca085244e59..70224b11122 100644 --- a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts +++ b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts @@ -47,7 +47,7 @@ export const fileExternalDocument = async ( docketNumber, }); - let currentCaseEntity = new Case(currentCase, { applicationContext }); + let currentCaseEntity = new Case(currentCase, { authorizedUser }); const { consolidatedCasesToFileAcross, @@ -132,7 +132,7 @@ export const fileExternalDocument = async ( docketNumber: individualDocumentMetadata.docketNumber, }); - let caseEntity = new Case(caseToUpdate, { applicationContext }); + let caseEntity = new Case(caseToUpdate, { authorizedUser }); const servedParties = aggregatePartiesForService(caseEntity); diff --git a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts index 1cd4be2637c..2a8e77d45cd 100644 --- a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts +++ b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts @@ -64,7 +64,7 @@ export const generateDocketRecordPdfInteractor = async ( isDirectlyAssociated || isIndirectlyAssociated ) { - caseEntity = new Case(caseSource, { applicationContext }); + caseEntity = new Case(caseSource, { authorizedUser: user }); } else { // unassociated user viewing sealed case throw new UnauthorizedError('Unauthorized to view sealed case.'); @@ -74,7 +74,7 @@ export const generateDocketRecordPdfInteractor = async ( throw new UnauthorizedError('Unauthorized to view sealed case.'); } } else { - caseEntity = new Case(caseSource, { applicationContext }); + caseEntity = new Case(caseSource, { authorizedUser: user }); } const formattedCaseDetail = applicationContext diff --git a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts index 2a6dbbfaa50..fca62f5aa88 100644 --- a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts +++ b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts @@ -29,7 +29,9 @@ export const getPublicDownloadPolicyUrlInteractor = async ( throw new NotFoundError(`Case ${docketNumber} was not found.`); } - const caseEntity = new Case(caseToCheck, { applicationContext }); + const caseEntity = new Case(caseToCheck, { + authorizedUser: applicationContext.getCurrentUser(), + }); const docketEntryEntity = caseEntity.getDocketEntryById({ docketEntryId: key, diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.addDocketEntryForPaymentStatus.test.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.addDocketEntryForPaymentStatus.test.ts index c43873cdf06..23f9342a931 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.addDocketEntryForPaymentStatus.test.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.addDocketEntryForPaymentStatus.test.ts @@ -3,6 +3,7 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { PAYMENT_STATUS } from '../../../../../shared/src/business/entities/EntityConstants'; import { addDocketEntryForPaymentStatus } from './serveCaseToIrsInteractor'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; describe('addDocketEntryForPaymentStatus', () => { let user; @@ -18,7 +19,7 @@ describe('addDocketEntryForPaymentStatus', () => { petitionPaymentDate: 'Today', petitionPaymentStatus: PAYMENT_STATUS.PAID, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await addDocketEntryForPaymentStatus({ applicationContext, @@ -43,7 +44,7 @@ describe('addDocketEntryForPaymentStatus', () => { petitionPaymentWaivedDate: 'Today', petitioners: undefined, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); await addDocketEntryForPaymentStatus({ applicationContext, diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts index da3bfc0f565..61c59272149 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts @@ -489,7 +489,7 @@ export const serveCaseToIrs = async ( docketNumber, }); - let caseEntity = new Case(caseToBatch, { applicationContext }); + let caseEntity = new Case(caseToBatch, { authorizedUser: user }); caseEntity.markAsSentToIRS(); diff --git a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts index 0c5464c14f6..5939b856adc 100644 --- a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts @@ -54,7 +54,7 @@ export const addCaseToTrialSession = async ( docketNumber, }); - const caseEntity = new Case(caseDetails, { applicationContext }); + const caseEntity = new Case(caseDetails, { authorizedUser: user }); const trialSessionEntity = new TrialSession(trialSession); @@ -100,7 +100,9 @@ export const addCaseToTrialSession = async ( trialSessionToUpdate: trialSessionEntity.validate().toRawObject(), }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const addCaseToTrialSessionInteractor = withLocking( diff --git a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts index 0f17942a7af..74c57ab2481 100644 --- a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts @@ -67,7 +67,7 @@ export const deleteTrialSessionInteractor = async ( docketNumber: order.docketNumber, }); - const caseEntity = new Case(myCase, { applicationContext }); + const caseEntity = new Case(myCase, { authorizedUser: user }); caseEntity.removeFromTrial({}); diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index 70b32991478..4edb4e2fefe 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -128,7 +128,7 @@ const setNoticeForCase = async ({ trialSessionEntity, user, }) => { - const caseEntity = new Case(caseRecord, { applicationContext }); + const caseEntity = new Case(caseRecord, { authorizedUser: user }); const { procedureType } = caseRecord; let noticeOfTrialIssued = await applicationContext diff --git a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts index b59a06d6ff5..20ffa2b369a 100644 --- a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts @@ -64,7 +64,7 @@ export const removeCaseFromTrial = async ( docketNumber, }); - const caseEntity = new Case(myCase, { applicationContext }); + const caseEntity = new Case(myCase, { authorizedUser: user }); if (!caseEntity.isHearing(trialSessionId)) { caseEntity.removeFromTrial({ @@ -104,7 +104,9 @@ export const removeCaseFromTrial = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { applicationContext }).validate().toRawObject(); + return new Case(updatedCase, { authorizedUser: user }) + .validate() + .toRawObject(); }; export const removeCaseFromTrialInteractor = withLocking( diff --git a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts index 1c3359959f4..36c89cafa1b 100644 --- a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts @@ -104,7 +104,7 @@ export const serveThirtyDayNoticeInteractor = async ( docketNumber: aCase.docketNumber, }); - const caseEntity = new Case(rawCase, { applicationContext }); + const caseEntity = new Case(rawCase, { authorizedUser: currentUser }); let clinicLetter; const clinicLetterKey = getClinicLetterKey({ diff --git a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts index de25936ec78..8bbc552eb8a 100644 --- a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts @@ -50,7 +50,7 @@ export const setForHearingInteractor = async ( docketNumber, }); - const caseEntity = new Case(caseDetails, { applicationContext }); + const caseEntity = new Case(caseDetails, { authorizedUser: user }); const trialSessionEntity = new TrialSession(trialSession); diff --git a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts index ca1fc645042..140f4cde47a 100644 --- a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts @@ -102,7 +102,7 @@ export const setTrialSessionCalendarInteractor = async ( * @returns {Promise} the promise of the updateCase call */ const setManuallyAddedCaseAsCalendared = caseRecord => { - const caseEntity = new Case(caseRecord, { applicationContext }); + const caseEntity = new Case(caseRecord, { authorizedUser: user }); caseEntity.setAsCalendared(trialSessionEntity); @@ -126,7 +126,7 @@ export const setTrialSessionCalendarInteractor = async ( * @returns {Promise} the promises of the updateCase and deleteCaseTrialSortMappingRecords calls */ const setTrialSessionCalendarForEligibleCase = caseRecord => { - const caseEntity = new Case(caseRecord, { applicationContext }); + const caseEntity = new Case(caseRecord, { authorizedUser: user }); caseEntity.setAsCalendared(trialSessionEntity); trialSessionEntity.addCaseToCalendar(caseEntity); @@ -195,7 +195,9 @@ const removeManuallyAddedCaseFromTrialSession = ({ docketNumber: caseRecord.docketNumber, }); - const caseEntity = new Case(caseRecord, { applicationContext }); + const caseEntity = new Case(caseRecord, { + authorizedUser: applicationContext.getCurrentUser(), + }); caseEntity.removeFromTrialWithAssociatedJudge(); diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index 7de8a73246d..4fac8f6597b 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -235,7 +235,7 @@ const updateCasesAndSetNoticeOfChange = async ({ applicationContext, docketNumber: c.docketNumber, }); - return new Case(aCase, { applicationContext }); + return new Case(aCase, { authorizedUser: user }); }), ); const casesThatShouldReceiveNotices = calendaredCaseEntities diff --git a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts index f0c9f378041..4f25b2630f0 100644 --- a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts +++ b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts @@ -90,7 +90,9 @@ export const updatePractitionerCase = async ({ docketNumber, }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); + const caseEntity = new Case(caseToUpdate, { + authorizedUser: applicationContext.getCurrentUser(), + }); const practitionerObject = [ ...caseEntity.privatePractitioners, ...caseEntity.irsPractitioners, @@ -109,7 +111,7 @@ export const updatePractitionerCase = async ({ // we do this again so that it will convert '' to null const validatedCaseToUpdate = new Case(caseEntity, { - applicationContext, + authorizedUser: applicationContext.getCurrentUser(), }).validate(); await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ @@ -128,7 +130,7 @@ const updateCaseEntityAndGenerateChange = async ({ user: RawUser; }): Promise => { const caseEntity = new Case(rawCaseData, { - applicationContext, + authorizedUser: applicationContext.getCurrentUser(), }); const petitionerObject = caseEntity.getPetitionerById(user.userId); diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts index 6c5d8c91685..cd88a921088 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts @@ -175,7 +175,7 @@ export const updatePetitionerInformation = async ( { ...oldCase, }, - { applicationContext }, + { authorizedUser: user }, ); caseToUpdateContacts.updatePetitioner({ @@ -196,7 +196,7 @@ export const updatePetitionerInformation = async ( { ...caseToUpdateContacts.toRawObject(), }, - { applicationContext }, + { authorizedUser: user }, ).validate(); const servedParties = aggregatePartiesForService(caseEntity); diff --git a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts index 2b24e50123a..cd484d5a40a 100644 --- a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts +++ b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts @@ -70,7 +70,7 @@ export const completeWorkItem = async ( docketNumber: completedWorkItem.docketNumber, }); - const caseToUpdate = new Case(caseObject, { applicationContext }); + const caseToUpdate = new Case(caseObject, { authorizedUser: user }); const workItemEntity = new WorkItem(completedWorkItem); diff --git a/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.ts b/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.ts index a15699bbdf6..50bbe94c7e1 100644 --- a/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.ts +++ b/web-api/src/business/useCases/workItems/setWorkItemAsReadInteractor.ts @@ -38,7 +38,7 @@ export const setWorkItemAsReadInteractor = async ( docketNumber, }); - const caseEntity = new Case(caseRecord, { applicationContext }); + const caseEntity = new Case(caseRecord, { authorizedUser }); const docketEntryEntity = caseEntity.getDocketEntryById({ docketEntryId, From d56fe96514cbba66e2d030c452433ae987da59c8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 10:05:56 -0700 Subject: [PATCH 072/523] 10417: Transition PaperPetition away from appContext --- .../entities/cases/PaperPetition.test.ts | 85 ++++++++++--------- .../business/entities/cases/PaperPetition.ts | 11 +-- .../validatePetitionFromPaperInteractor.ts | 2 +- .../useCases/createCaseFromPaperInteractor.ts | 2 +- 4 files changed, 51 insertions(+), 49 deletions(-) diff --git a/shared/src/business/entities/cases/PaperPetition.test.ts b/shared/src/business/entities/cases/PaperPetition.test.ts index 27276f2bdd5..d4cdd7c909c 100644 --- a/shared/src/business/entities/cases/PaperPetition.test.ts +++ b/shared/src/business/entities/cases/PaperPetition.test.ts @@ -8,16 +8,17 @@ import { } from '../EntityConstants'; import { Correspondence } from '../Correspondence'; import { PaperPetition } from './PaperPetition'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { createISODateString } from '@shared/business/utilities/DateHandler'; +import { getUniqueId } from '@shared/sharedAppContext'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; describe('paperPetition entity', () => { describe('validation', () => { - it('throws an exception when not provided an application context', () => { - expect(() => new PaperPetition({}, {} as any)).toThrow(); - }); - it('returns the expected set of errors for an empty object', () => { - const paperPetition = new PaperPetition({}, { applicationContext }); + const paperPetition = new PaperPetition( + {}, + { authorizedUser: mockPetitionsClerkUser }, + ); expect(paperPetition.getFormattedValidationErrors()).toEqual({ caseCaption: 'Enter a case caption', caseType: 'Select a case type', @@ -58,7 +59,7 @@ describe('paperPetition entity', () => { ], preferredTrialCity: 'Boise, Idaho', procedureType: 'Small', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), requestForPlaceOfTrialFile: { anObject: true }, requestForPlaceOfTrialFileSize: 1, statistics: [ @@ -70,7 +71,7 @@ describe('paperPetition entity', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect(paperPetition.getFormattedValidationErrors()).toEqual(null); @@ -113,7 +114,7 @@ describe('paperPetition entity', () => { ], preferredTrialCity: 'Boise, Idaho', procedureType: 'Small', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), requestForPlaceOfTrialFile: { anObject: true }, requestForPlaceOfTrialFileSize: 1, statistics: [ @@ -125,7 +126,7 @@ describe('paperPetition entity', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect(paperPetition.getFormattedValidationErrors()).toEqual(null); @@ -162,9 +163,9 @@ describe('paperPetition entity', () => { }, ], procedureType: 'Small', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect(paperPetition.getFormattedValidationErrors()).toEqual(null); @@ -200,9 +201,9 @@ describe('paperPetition entity', () => { }, ], procedureType: 'Small', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect(paperPetition.getFormattedValidationErrors()).toEqual(null); @@ -217,7 +218,7 @@ describe('paperPetition entity', () => { petitionFileSize: 1, receivedAt: '9999-01-01T00:00:00.000Z', }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect(paperPetition.getFormattedValidationErrors()).not.toEqual(null); }); @@ -227,9 +228,9 @@ describe('paperPetition entity', () => { { caseCaption: 'Dr. Leo Marvin, Petitioner', petitionFile: new File([], 'test.pdf'), - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -242,9 +243,9 @@ describe('paperPetition entity', () => { { caseCaption: 'Dr. Leo Marvin, Petitioner', petitionPaymentStatus: PAYMENT_STATUS.WAIVED, - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -258,7 +259,7 @@ describe('paperPetition entity', () => { { partyType: PARTY_TYPES.corporation, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -272,7 +273,7 @@ describe('paperPetition entity', () => { orderForCds: false, partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -285,9 +286,9 @@ describe('paperPetition entity', () => { { applicationForWaiverOfFilingFeeFile: new File([], 'test.pdf'), caseCaption: 'Dr. Leo Marvin, Petitioner', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -300,10 +301,10 @@ describe('paperPetition entity', () => { const paperPetition = new PaperPetition( { caseCaption: 'Dr. Leo Marvin, Petitioner', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), stinFile: new File([], 'test.pdf'), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -316,9 +317,9 @@ describe('paperPetition entity', () => { { attachmentToPetitionFile: new File([], 'test.pdf'), caseCaption: 'Dr. Leo Marvin, Petitioner', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -332,9 +333,9 @@ describe('paperPetition entity', () => { { caseCaption: 'Dr. Leo Marvin, Petitioner', corporateDisclosureFile: new File([], 'test.pdf'), - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -347,10 +348,10 @@ describe('paperPetition entity', () => { const paperPetition = new PaperPetition( { caseCaption: 'Dr. Leo Marvin, Petitioner', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), requestForPlaceOfTrialFile: new File([], 'test.pdf'), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -363,10 +364,10 @@ describe('paperPetition entity', () => { const paperPetition = new PaperPetition( { caseCaption: 'Dr. Leo Marvin, Petitioner', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), requestForPlaceOfTrialFile: new File([], 'test.pdf'), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -379,9 +380,9 @@ describe('paperPetition entity', () => { { caseCaption: 'Dr. Guy Fieri, Petitioner', preferredTrialCity: 'Flavortown, AR', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect( @@ -419,11 +420,11 @@ describe('paperPetition entity', () => { }, ], procedureType: 'Small', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), stinFile: { anObject: true }, stinFileSize: 1, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect(paperPetition.isValid()).toEqual(false); @@ -463,11 +464,11 @@ describe('paperPetition entity', () => { }, ], procedureType: 'Small', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), stinFile: { anObject: true }, stinFileSize: 1, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect(paperPetition.isValid()).toEqual(false); @@ -479,7 +480,7 @@ describe('paperPetition entity', () => { }); it('should populate archivedCorrespondences', () => { - const mockGuid = applicationContext.getUniqueId(); + const mockGuid = getUniqueId(); const mockCorrespondence = new Correspondence({ correspondenceId: mockGuid, documentTitle: 'My Correspondence', @@ -513,7 +514,7 @@ describe('paperPetition entity', () => { ], preferredTrialCity: 'Boise, Idaho', procedureType: 'Small', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), requestForPlaceOfTrialFile: { anObject: true }, requestForPlaceOfTrialFileSize: 1, statistics: [ @@ -525,7 +526,7 @@ describe('paperPetition entity', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect(paperPetition.getFormattedValidationErrors()).toEqual(null); diff --git a/shared/src/business/entities/cases/PaperPetition.ts b/shared/src/business/entities/cases/PaperPetition.ts index 0b0c197b362..1207a7aec2a 100644 --- a/shared/src/business/entities/cases/PaperPetition.ts +++ b/shared/src/business/entities/cases/PaperPetition.ts @@ -14,6 +14,7 @@ import { DocketEntry } from '../DocketEntry'; import { JoiValidationConstants } from '../JoiValidationConstants'; import { JoiValidationEntity } from '../JoiValidationEntity'; import { Statistic } from '../Statistic'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import joi from 'joi'; /** @@ -63,10 +64,10 @@ export class PaperPetition extends JoiValidationEntity { public archivedCorrespondences: any; public docketEntries: DocketEntry[]; - constructor(rawProps, { applicationContext }) { - if (!applicationContext) { - throw new TypeError('applicationContext must be defined'); - } + constructor( + rawProps, + { authorizedUser }: { authorizedUser: UnknownAuthUser }, + ) { super('PaperPetition'); this.attachmentToPetitionFile = rawProps.attachmentToPetitionFile; this.attachmentToPetitionFileSize = rawProps.attachmentToPetitionFileSize; @@ -123,7 +124,7 @@ export class PaperPetition extends JoiValidationEntity { ? rawProps.archivedDocketEntries.map( doc => new DocketEntry(doc, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }), ) : []; diff --git a/shared/src/business/useCases/validatePetitionFromPaperInteractor.ts b/shared/src/business/useCases/validatePetitionFromPaperInteractor.ts index 26a18d48276..22c73461d13 100644 --- a/shared/src/business/useCases/validatePetitionFromPaperInteractor.ts +++ b/shared/src/business/useCases/validatePetitionFromPaperInteractor.ts @@ -13,7 +13,7 @@ export const validatePetitionFromPaperInteractor = ( { petition }: { petition: any }, ) => { const errors = new PaperPetition(petition, { - applicationContext, + authorizedUser: applicationContext.getCurrentUser(), }).getFormattedValidationErrors(); return errors || null; }; diff --git a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts index bffe767e5b7..e3525c443e8 100644 --- a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts +++ b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts @@ -91,7 +91,7 @@ export const createCaseFromPaperInteractor = async ( .getUserById({ applicationContext, userId: authorizedUser.userId }); const petitionEntity = new PaperPetition(petitionMetadata, { - applicationContext, + authorizedUser, }).validate(); const docketNumber = From 96397df85f67daf0b55319ba98c17e7634d40e05 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 10:16:12 -0700 Subject: [PATCH 073/523] 10417: Update docs --- docs/remove-get-current-user.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index 31833e1225f..92e4530ed09 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -4,7 +4,7 @@ # TODO - Go back to all // TODO 10417 -- Look for 'extends' Classname +- Look at validateRawCollection() # Web-Client Steps to transition getCurrentUser() in web-client From 8b688cf053340a9e478cb1b7bbf5a5ed708c7a13 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 11:15:35 -0700 Subject: [PATCH 074/523] 10417: Remove getCurrentUser from shared --- .../useCases/generateDocumentIds.test.ts | 147 +++++++------ .../business/useCases/generateDocumentIds.ts | 8 +- ...tePrintableFilingReceiptInteractor.test.ts | 195 ++++++++++-------- ...eneratePrintableFilingReceiptInteractor.ts | 24 ++- .../generatePrintableFilingReceiptLambda.ts | 20 +- .../src/presenter/actions/createCaseAction.ts | 10 +- .../actions/createCaseFromPaperAction.ts | 11 +- web-client/src/presenter/state.ts | 4 +- 8 files changed, 240 insertions(+), 179 deletions(-) diff --git a/shared/src/business/useCases/generateDocumentIds.test.ts b/shared/src/business/useCases/generateDocumentIds.test.ts index 5f00d952764..d399abfb900 100644 --- a/shared/src/business/useCases/generateDocumentIds.test.ts +++ b/shared/src/business/useCases/generateDocumentIds.test.ts @@ -1,6 +1,9 @@ -import { ROLES } from '../entities/EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; import { generateDocumentIds } from './generateDocumentIds'; +import { + mockIrsPractitionerUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('generateDocumentIds', () => { let petitionMetadata: object; @@ -16,42 +19,34 @@ describe('generateDocumentIds', () => { }); beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'petitioner', - }); petitionMetadata = {}; }); - it('throws an error when a null user tries to access the case', async () => { - applicationContext.getCurrentUser.mockReturnValue(null); - - await expect( - generateDocumentIds(applicationContext, {} as any), - ).rejects.toThrow(); - }); it('throws an error when an unauthorized user tries to access the case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: 'irsPractitioner', - }); - await expect( - generateDocumentIds(applicationContext, { - petitionFile: null, - petitionMetadata: null, - } as any), + generateDocumentIds( + applicationContext, + { + petitionFile: null, + petitionMetadata: null, + } as any, + mockIrsPractitionerUser, + ), ).rejects.toThrow(); }); it('calls upload on a Petition file', async () => { - await generateDocumentIds(applicationContext, { - petitionMetadata, - petitionUploadProgress: { - file: mockFile, - uploadProgress: jest.fn(), - }, - } as any); + await generateDocumentIds( + applicationContext, + { + petitionMetadata, + petitionUploadProgress: { + file: mockFile, + uploadProgress: jest.fn(), + }, + } as any, + mockPetitionerUser, + ); expect( applicationContext.getUseCases().uploadDocumentAndMakeSafeInteractor.mock @@ -60,17 +55,21 @@ describe('generateDocumentIds', () => { }); it('uploads a Petition file and a STIN file', async () => { - await generateDocumentIds(applicationContext, { - petitionMetadata, - petitionUploadProgress: { - file: mockFile, - uploadProgress: jest.fn(), - }, - stinUploadProgress: { - file: mockFile, - uploadProgress: jest.fn(), - }, - } as any); + await generateDocumentIds( + applicationContext, + { + petitionMetadata, + petitionUploadProgress: { + file: mockFile, + uploadProgress: jest.fn(), + }, + stinUploadProgress: { + file: mockFile, + uploadProgress: jest.fn(), + }, + } as any, + mockPetitionerUser, + ); expect( applicationContext.getUseCases().uploadDocumentAndMakeSafeInteractor.mock @@ -79,17 +78,21 @@ describe('generateDocumentIds', () => { }); it('uploads a Corporate Disclosure Statement file and a petition', async () => { - await generateDocumentIds(applicationContext, { - corporateDisclosureUploadProgress: { - file: mockFile, - uploadProgress: jest.fn(), - }, - petitionMetadata, - petitionUploadProgress: { - file: mockFile, - uploadProgress: jest.fn(), - }, - } as any); + await generateDocumentIds( + applicationContext, + { + corporateDisclosureUploadProgress: { + file: mockFile, + uploadProgress: jest.fn(), + }, + petitionMetadata, + petitionUploadProgress: { + file: mockFile, + uploadProgress: jest.fn(), + }, + } as any, + mockPetitionerUser, + ); expect( applicationContext.getUseCases().uploadDocumentAndMakeSafeInteractor.mock @@ -98,17 +101,21 @@ describe('generateDocumentIds', () => { }); it('uploads Attachment to Petition file and a Petition file', async () => { - await generateDocumentIds(applicationContext, { - attachmentToPetitionUploadProgress: { - file: mockFile, - uploadProgress: jest.fn(), - }, - petitionMetadata, - petitionUploadProgress: { - file: mockFile, - uploadProgress: jest.fn(), - }, - } as any); + await generateDocumentIds( + applicationContext, + { + attachmentToPetitionUploadProgress: { + file: mockFile, + uploadProgress: jest.fn(), + }, + petitionMetadata, + petitionUploadProgress: { + file: mockFile, + uploadProgress: jest.fn(), + }, + } as any, + mockPetitionerUser, + ); expect( applicationContext.getUseCases().uploadDocumentAndMakeSafeInteractor.mock @@ -122,13 +129,17 @@ describe('generateDocumentIds', () => { .uploadDocumentAndMakeSafeInteractor.mockRejectedValue('something wrong'); await expect( - generateDocumentIds(applicationContext, { - petitionMetadata, - petitionUploadProgress: { - file: mockFile, - uploadProgress: jest.fn(), - }, - } as any), + generateDocumentIds( + applicationContext, + { + petitionMetadata, + petitionUploadProgress: { + file: mockFile, + uploadProgress: jest.fn(), + }, + } as any, + mockPetitionerUser, + ), ).rejects.toThrow('Error generating document Ids'); }); }); diff --git a/shared/src/business/useCases/generateDocumentIds.ts b/shared/src/business/useCases/generateDocumentIds.ts index 2cdaf73817e..03b3687fc68 100644 --- a/shared/src/business/useCases/generateDocumentIds.ts +++ b/shared/src/business/useCases/generateDocumentIds.ts @@ -4,6 +4,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const generateDocumentIds = async ( applicationContext: any, @@ -22,12 +23,11 @@ export const generateDocumentIds = async ( requestForPlaceOfTrialUploadProgress?: FileUploadProgressType; stinUploadProgress: FileUploadProgressType; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - const hasPermissions = - isAuthorized(user, ROLE_PERMISSIONS.PETITION) || - isAuthorized(user, ROLE_PERMISSIONS.START_PAPER_CASE); + isAuthorized(authorizedUser, ROLE_PERMISSIONS.PETITION) || + isAuthorized(authorizedUser, ROLE_PERMISSIONS.START_PAPER_CASE); if (!hasPermissions) { throw new UnauthorizedError('Unauthorized'); diff --git a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.test.ts b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.test.ts index 3f879598ed1..bead1a37564 100644 --- a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.test.ts +++ b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.test.ts @@ -1,9 +1,9 @@ import { MOCK_CASE, MOCK_CONSOLIDATED_CASE_SUMMARY } from '../../test/mockCase'; -import { MOCK_USERS } from '../../test/mockUsers'; import { RawConsolidatedCaseSummary } from '@shared/business/dto/cases/ConsolidatedCaseSummary'; import { applicationContext } from '../test/createTestApplicationContext'; import { generatePrintableFilingReceiptInteractor } from './generatePrintableFilingReceiptInteractor'; import { getContactPrimary } from '../entities/cases/Case'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('generatePrintableFilingReceiptInteractor', () => { const mockPrimaryDocketEntryId = MOCK_CASE.docketEntries[0].docketEntryId; @@ -42,9 +42,6 @@ describe('generatePrintableFilingReceiptInteractor', () => { }; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue( - MOCK_USERS['a7d90c05-f6cd-442c-a168-202db587f16f'], - ); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(mockCase); @@ -56,13 +53,17 @@ describe('generatePrintableFilingReceiptInteractor', () => { }); it('should call the Receipt of Filing document generator', async () => { - await generatePrintableFilingReceiptInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - documentsFiled: { - primaryDocumentId: mockPrimaryDocketEntryId, + await generatePrintableFilingReceiptInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + documentsFiled: { + primaryDocumentId: mockPrimaryDocketEntryId, + }, + fileAcrossConsolidatedGroup: false, }, - fileAcrossConsolidatedGroup: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getDocumentGenerators().receiptOfFiling, @@ -76,22 +77,26 @@ describe('generatePrintableFilingReceiptInteractor', () => { }); it('should populate filedBy on the receipt of filing', async () => { - await generatePrintableFilingReceiptInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - documentsFiled: { - hasSecondarySupportingDocuments: true, - hasSupportingDocuments: true, - primaryDocumentId: mockPrimaryDocketEntryId, - secondaryDocument: { docketEntryId: 4 }, - secondaryDocumentFile: { fakeDocument: true }, - secondarySupportingDocuments: [ - { docketEntryId: '3' }, - { docketEntryId: '7' }, - ], - supportingDocuments: [{ docketEntryId: '1' }, { docketEntryId: '2' }], + await generatePrintableFilingReceiptInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + documentsFiled: { + hasSecondarySupportingDocuments: true, + hasSupportingDocuments: true, + primaryDocumentId: mockPrimaryDocketEntryId, + secondaryDocument: { docketEntryId: 4 }, + secondaryDocumentFile: { fakeDocument: true }, + secondarySupportingDocuments: [ + { docketEntryId: '3' }, + { docketEntryId: '7' }, + ], + supportingDocuments: [{ docketEntryId: '1' }, { docketEntryId: '2' }], + }, + fileAcrossConsolidatedGroup: false, }, - fileAcrossConsolidatedGroup: false, - }); + mockDocketClerkUser, + ); const receiptMockCall = applicationContext.getDocumentGenerators().receiptOfFiling.mock @@ -106,22 +111,26 @@ describe('generatePrintableFilingReceiptInteractor', () => { }); it('acquires document information', async () => { - await generatePrintableFilingReceiptInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - documentsFiled: { - hasSecondarySupportingDocuments: true, - hasSupportingDocuments: true, - primaryDocumentId: mockPrimaryDocketEntryId, - secondaryDocument: { docketEntryId: 4 }, - secondaryDocumentFile: { fakeDocument: true }, - secondarySupportingDocuments: [ - { docketEntryId: '3' }, - { docketEntryId: '7' }, - ], - supportingDocuments: [{ docketEntryId: '1' }, { docketEntryId: '2' }], + await generatePrintableFilingReceiptInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + documentsFiled: { + hasSecondarySupportingDocuments: true, + hasSupportingDocuments: true, + primaryDocumentId: mockPrimaryDocketEntryId, + secondaryDocument: { docketEntryId: 4 }, + secondaryDocumentFile: { fakeDocument: true }, + secondarySupportingDocuments: [ + { docketEntryId: '3' }, + { docketEntryId: '7' }, + ], + supportingDocuments: [{ docketEntryId: '1' }, { docketEntryId: '2' }], + }, + fileAcrossConsolidatedGroup: false, }, - fileAcrossConsolidatedGroup: false, - }); + mockDocketClerkUser, + ); const receiptMockCall = applicationContext.getDocumentGenerators().receiptOfFiling.mock @@ -131,42 +140,50 @@ describe('generatePrintableFilingReceiptInteractor', () => { expect(receiptMockCall.secondaryDocument).toBeDefined(); }); - it('formats certificateOfServiceDate', async () => { - await generatePrintableFilingReceiptInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - documentsFiled: { - certificateOfService: true, - certificateOfServiceDate: '2019-08-25T05:00:00.000Z', - primaryDocumentId: mockPrimaryDocketEntryId, - }, - fileAcrossConsolidatedGroup: false, - }); + it( + 'formats certificateOfServiceDate', + async () => { + await generatePrintableFilingReceiptInteractor(applicationContext, { + docketNumber: mockCase.docketNumber, + documentsFiled: { + certificateOfService: true, + certificateOfServiceDate: '2019-08-25T05:00:00.000Z', + primaryDocumentId: mockPrimaryDocketEntryId, + }, + fileAcrossConsolidatedGroup: false, + }); - const receiptMockCall = - applicationContext.getDocumentGenerators().receiptOfFiling.mock - .calls[0][0].data; - expect(receiptMockCall.document.formattedCertificateOfServiceDate).toEqual( - '08/25/19', - ); - }); + const receiptMockCall = + applicationContext.getDocumentGenerators().receiptOfFiling.mock + .calls[0][0].data; + expect( + receiptMockCall.document.formattedCertificateOfServiceDate, + ).toEqual('08/25/19'); + }, + mockDocketClerkUser, + ); it('should call the Receipt of Filing document generator with consolidatedCases array populated when fileAcrossConsolidatedGroup is true', async () => { - await generatePrintableFilingReceiptInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - documentsFiled: { - hasSecondarySupportingDocuments: true, - hasSupportingDocuments: true, - primaryDocumentId: mockPrimaryDocketEntryId, - secondaryDocument: { docketEntryId: 4 }, - secondaryDocumentFile: { fakeDocument: true }, - secondarySupportingDocuments: [ - { docketEntryId: '3' }, - { docketEntryId: '7' }, - ], - supportingDocuments: [{ docketEntryId: '1' }, { docketEntryId: '2' }], + await generatePrintableFilingReceiptInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + documentsFiled: { + hasSecondarySupportingDocuments: true, + hasSupportingDocuments: true, + primaryDocumentId: mockPrimaryDocketEntryId, + secondaryDocument: { docketEntryId: 4 }, + secondaryDocumentFile: { fakeDocument: true }, + secondarySupportingDocuments: [ + { docketEntryId: '3' }, + { docketEntryId: '7' }, + ], + supportingDocuments: [{ docketEntryId: '1' }, { docketEntryId: '2' }], + }, + fileAcrossConsolidatedGroup: true, }, - fileAcrossConsolidatedGroup: true, - }); + mockDocketClerkUser, + ); const receiptMockCall = applicationContext.getDocumentGenerators().receiptOfFiling.mock @@ -182,22 +199,26 @@ describe('generatePrintableFilingReceiptInteractor', () => { }); it('should call the Receipt of Filing document generator with consolidatedCases array unpopulated (emptyArray) when fileAcrossConsolidatedGroup is true', async () => { - await generatePrintableFilingReceiptInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - documentsFiled: { - hasSecondarySupportingDocuments: true, - hasSupportingDocuments: true, - primaryDocumentId: mockPrimaryDocketEntryId, - secondaryDocument: { docketEntryId: 4 }, - secondaryDocumentFile: { fakeDocument: true }, - secondarySupportingDocuments: [ - { docketEntryId: '3' }, - { docketEntryId: '7' }, - ], - supportingDocuments: [{ docketEntryId: '1' }, { docketEntryId: '2' }], + await generatePrintableFilingReceiptInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + documentsFiled: { + hasSecondarySupportingDocuments: true, + hasSupportingDocuments: true, + primaryDocumentId: mockPrimaryDocketEntryId, + secondaryDocument: { docketEntryId: 4 }, + secondaryDocumentFile: { fakeDocument: true }, + secondarySupportingDocuments: [ + { docketEntryId: '3' }, + { docketEntryId: '7' }, + ], + supportingDocuments: [{ docketEntryId: '1' }, { docketEntryId: '2' }], + }, + fileAcrossConsolidatedGroup: false, }, - fileAcrossConsolidatedGroup: false, - }); + mockDocketClerkUser, + ); const receiptMockCall = applicationContext.getDocumentGenerators().receiptOfFiling.mock diff --git a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts index 49cffd460be..39d37b1bc85 100644 --- a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts +++ b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts @@ -1,18 +1,21 @@ import { Case } from '../entities/cases/Case'; import { DocketEntry } from '../entities/DocketEntry'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { getCaseCaptionMeta } from '../utilities/getCaseCaptionMeta'; const getDocumentInfo = ({ applicationContext, + authorizedUser, documentData, petitioners, }: { applicationContext: IApplicationContext; + authorizedUser: UnknownAuthUser; documentData: any; petitioners?: any[]; }) => { const doc = new DocketEntry(documentData, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, petitioners, }); @@ -50,6 +53,7 @@ export const generatePrintableFilingReceiptInteractor = async ( documentsFiled: any; fileAcrossConsolidatedGroup: boolean; }, + authorizedUser: UnknownAuthUser, ) => { const caseRecord = await applicationContext .getPersistenceGateway() @@ -59,7 +63,7 @@ export const generatePrintableFilingReceiptInteractor = async ( }); let caseEntity = new Case(caseRecord, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }).validate(); if (fileAcrossConsolidatedGroup && !caseRecord.leadDocketNumber) { @@ -87,6 +91,7 @@ export const generatePrintableFilingReceiptInteractor = async ( const primaryDocument = getDocumentInfo({ applicationContext, + authorizedUser, documentData: documentsFiled, petitioners: caseRecord.petitioners, }); @@ -102,21 +107,30 @@ export const generatePrintableFilingReceiptInteractor = async ( if (documentsFiled.hasSupportingDocuments) { filingReceiptDocumentParams.supportingDocuments = documentsFiled.supportingDocuments.map(doc => - getDocumentInfo({ applicationContext, documentData: doc }), + getDocumentInfo({ + applicationContext, + authorizedUser, + documentData: doc, + }), ); } if (documentsFiled.secondaryDocumentFile) { filingReceiptDocumentParams.secondaryDocument = getDocumentInfo({ applicationContext, + authorizedUser, documentData: documentsFiled.secondaryDocument, - } as any); + }); } if (documentsFiled.hasSecondarySupportingDocuments) { filingReceiptDocumentParams.secondarySupportingDocuments = documentsFiled.secondarySupportingDocuments.map(doc => - getDocumentInfo({ applicationContext, documentData: doc }), + getDocumentInfo({ + applicationContext, + authorizedUser, + documentData: doc, + }), ); } diff --git a/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts b/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts index 8f149c97947..ce55e7e7624 100644 --- a/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts +++ b/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generatePrintableFilingReceiptInteractor } from '@shared/business/useCases/generatePrintableFilingReceiptInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const generatePrintableFilingReceiptLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .generatePrintableFilingReceiptInteractor( +export const generatePrintableFilingReceiptLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await generatePrintableFilingReceiptInteractor( applicationContext, JSON.parse(event.body), + authorizedUser, ); - }); + }, + authorizedUser, + ); diff --git a/web-client/src/presenter/actions/createCaseAction.ts b/web-client/src/presenter/actions/createCaseAction.ts index 45f20b253f1..95dd69b304c 100644 --- a/web-client/src/presenter/actions/createCaseAction.ts +++ b/web-client/src/presenter/actions/createCaseAction.ts @@ -31,16 +31,18 @@ export const createCaseAction = async ({ corporateDisclosureFileId, petitionFileId, stinFileId, - } = await applicationContext - .getUseCases() - .generateDocumentIds(applicationContext, { + } = await applicationContext.getUseCases().generateDocumentIds( + applicationContext, + { attachmentToPetitionUploadProgress: fileUploadProgressMap.attachmentToPetition, corporateDisclosureUploadProgress: fileUploadProgressMap.corporateDisclosure, petitionUploadProgress: fileUploadProgressMap.petition, stinUploadProgress: fileUploadProgressMap.stin, - }); + }, + user, + ); stinFile = stinFileId; diff --git a/web-client/src/presenter/actions/createCaseFromPaperAction.ts b/web-client/src/presenter/actions/createCaseFromPaperAction.ts index 102683dc730..dd93a4067c2 100644 --- a/web-client/src/presenter/actions/createCaseFromPaperAction.ts +++ b/web-client/src/presenter/actions/createCaseFromPaperAction.ts @@ -10,6 +10,7 @@ export const createCaseFromPaperAction = async ({ }: ActionProps<{ fileUploadProgressMap: FileUploadProgressMapType; }>) => { + const user = get(state.user); const petitionMetadata: CreatedCaseType = get(state.form); const { fileUploadProgressMap } = props; let caseDetail: RawCase; @@ -22,9 +23,9 @@ export const createCaseFromPaperAction = async ({ petitionFileId, requestForPlaceOfTrialFileId, stinFileId, - } = await applicationContext - .getUseCases() - .generateDocumentIds(applicationContext, { + } = await applicationContext.getUseCases().generateDocumentIds( + applicationContext, + { applicationForWaiverOfFilingFeeUploadProgress: fileUploadProgressMap.applicationForWaiverOfFilingFee, attachmentToPetitionUploadProgress: @@ -35,7 +36,9 @@ export const createCaseFromPaperAction = async ({ requestForPlaceOfTrialUploadProgress: fileUploadProgressMap.requestForPlaceOfTrial, stinUploadProgress: fileUploadProgressMap.stin, - }); + }, + user, + ); caseDetail = await applicationContext .getUseCases() diff --git a/web-client/src/presenter/state.ts b/web-client/src/presenter/state.ts index d087a877d4f..01943d4437c 100644 --- a/web-client/src/presenter/state.ts +++ b/web-client/src/presenter/state.ts @@ -3,6 +3,8 @@ import { FormattedPendingMotionWithWorksheet } from '@web-api/business/useCases/ import { GetCasesByStatusAndByJudgeResponse } from '@web-api/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor'; import { JudgeActivityReportState } from './judgeActivityReportState'; import { RawCaseDeadline } from '@shared/business/entities/CaseDeadline'; +import { RawIrsPractitioner } from '@shared/business/entities/IrsPractitioner'; +import { RawPractitioner } from '@shared/business/entities/Practitioner'; import { RawUser } from '@shared/business/entities/User'; import { TAssociatedCase } from '@shared/business/useCases/getCasesForUserInteractor'; import { addCourtIssuedDocketEntryHelper } from './computeds/addCourtIssuedDocketEntryHelper'; @@ -766,7 +768,7 @@ export const baseState = { name: '', }, trialSessionWorkingCopy: cloneDeep(initialTrialSessionWorkingCopyState), - user: null as any, + user: null as unknown as RawUser | RawPractitioner | RawIrsPractitioner, // TODO 10417 initialize to the correct shape after verifying no where in the application is doing a null check for state.user. userContactEditProgress: {}, users: [] as RawUser[], validationErrors: {} as Record, From df5563fa968959199c694539d7a4aa6e1e7cefec Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 11:37:04 -0700 Subject: [PATCH 075/523] 10417: Remove getCurrentUser from shared --- ...eneratePrintableFilingReceiptInteractor.ts | 2 +- .../useCases/getCaseDeadlinesInteractor.ts | 10 +- .../useCases/getCaseInteractor.test.ts | 5 - .../getDownloadPolicyUrlInteractor.test.ts | 568 +++++++++++------- 4 files changed, 359 insertions(+), 226 deletions(-) diff --git a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts index 39d37b1bc85..ac3d5239108 100644 --- a/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts +++ b/shared/src/business/useCases/generatePrintableFilingReceiptInteractor.ts @@ -85,7 +85,7 @@ export const generatePrintableFilingReceiptInteractor = async ( .sort((a, b) => a.sortableDocketNumber - b.sortableDocketNumber) .map(consolidatedCaseRecord => consolidatedCaseRecord.docketNumber); caseEntity = new Case(leadCase, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }).validate(); } diff --git a/shared/src/business/useCases/getCaseDeadlinesInteractor.ts b/shared/src/business/useCases/getCaseDeadlinesInteractor.ts index 4ff9b266748..1b89604aa7d 100644 --- a/shared/src/business/useCases/getCaseDeadlinesInteractor.ts +++ b/shared/src/business/useCases/getCaseDeadlinesInteractor.ts @@ -1,3 +1,7 @@ +import { + AuthUser, + UnknownAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../entities/cases/Case'; import { CaseDeadline } from '../entities/CaseDeadline'; import { @@ -5,7 +9,6 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { pick } from 'lodash'; export const getCaseDeadlinesInteractor = async ( @@ -49,6 +52,7 @@ export const getCaseDeadlinesInteractor = async ( const caseMap = await getCasesByDocketNumbers({ applicationContext, + authorizedUser, docketNumbers: validatedCaseDeadlines.map(item => item.docketNumber), }); @@ -70,10 +74,12 @@ export const getCaseDeadlinesInteractor = async ( const getCasesByDocketNumbers = async ({ applicationContext, + authorizedUser, docketNumbers, }: { applicationContext: IApplicationContext; docketNumbers: string[]; + authorizedUser: AuthUser; }) => { const caseData = await applicationContext .getPersistenceGateway() @@ -86,7 +92,7 @@ const getCasesByDocketNumbers = async ({ .map( caseRecord => new Case(caseRecord, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }), ) .filter(caseEntity => { diff --git a/shared/src/business/useCases/getCaseInteractor.test.ts b/shared/src/business/useCases/getCaseInteractor.test.ts index 2ec61d4a0b7..1acd60db35e 100644 --- a/shared/src/business/useCases/getCaseInteractor.test.ts +++ b/shared/src/business/useCases/getCaseInteractor.test.ts @@ -20,7 +20,6 @@ import { } from '@shared/test/mockAuthUsers'; describe('getCaseInteractor', () => { - const petitionsclerkId = '23c4d382-1136-492f-b1f4-45e893c34771'; const irsPractitionerId = '6cf19fba-18c6-467a-9ea6-7a14e42add2f'; const practitionerId = '295c3640-7ff9-40bb-b2f1-8117bba084ea'; const practitioner2Id = '42614976-4228-49aa-a4c3-597dae1c7220'; @@ -87,10 +86,6 @@ describe('getCaseInteractor', () => { }); it('throws an error when the entity returned from persistence is invalid', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: petitionsclerkId, - }); const mockInvalidCase = { ...testCase, caseCaption: undefined }; applicationContext .getPersistenceGateway() diff --git a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.test.ts b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.test.ts index aaeeea0adc8..15d3bb4781f 100644 --- a/shared/src/business/useCases/getDownloadPolicyUrlInteractor.test.ts +++ b/shared/src/business/useCases/getDownloadPolicyUrlInteractor.test.ts @@ -5,7 +5,6 @@ import { DOCUMENT_PROCESSING_STATUS_OPTIONS, INITIAL_DOCUMENT_TYPES, NOTICE_OF_CHANGE_CONTACT_INFORMATION_MAP, - ROLES, STIPULATED_DECISION_EVENT_CODE, TRANSCRIPT_EVENT_CODE, } from '../entities/EntityConstants'; @@ -23,14 +22,19 @@ import { } from '../utilities/DateHandler'; import { casePetitioner, - docketClerkUser, irsPractitionerUser, - irsSuperuserUser, - petitionerUser, - petitionsClerkUser, privatePractitionerUser, } from '../../test/mockUsers'; import { cloneDeep } from 'lodash'; +import { + mockAdminUser, + mockDocketClerkUser, + mockIrsPractitionerUser, + mockIrsSuperuser, + mockPetitionerUser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getDownloadPolicyUrlInteractor', () => { let mockCase; @@ -57,39 +61,42 @@ describe('getDownloadPolicyUrlInteractor', () => { }); it('should throw unauthorized error when the users role is invalid', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.admin, - userId: 'b5724655-1791-4a99-b0f6-f9bbe99c1db5', - }); - await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockAdminUser, + ), ).rejects.toThrow('Unauthorized'); }); describe('when the user is a petitioner not associated with case or the consolidated group', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - }); - it('should throw an unauthorized error', async () => { await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should throw an unauthorized error when the document being viewed is the case confirmation pdf', async () => { await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: `case-${MOCK_CASE.docketNumber}-confirmation.pdf`, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: `case-${MOCK_CASE.docketNumber}-confirmation.pdf`, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -106,10 +113,14 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized to view document at this time'); }); @@ -123,10 +134,14 @@ describe('getDownloadPolicyUrlInteractor', () => { servedAt: applicationContext.getUtilities().createISODateString(), }; - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ); expect(url).toEqual('localhost'); }); @@ -141,32 +156,36 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized to view document at this time.'); }); it('should throw an Unauthorized error for a petitioner attempting to access an case confirmation pdf for a different case', async () => { await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, //docket number is 101-18 - key: 'case-101-20-confirmation.pdf', - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, //docket number is 101-18 + key: 'case-101-20-confirmation.pdf', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); }); describe('when the user is a petitioner associated with case', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - }); - beforeEach(() => { mockCase.petitioners = [ { - contactId: petitionerUser.userId, + contactId: mockPetitionerUser.userId, }, ]; }); @@ -182,10 +201,14 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized to view document at this time'); }); @@ -201,10 +224,14 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized to view document at this time'); }); @@ -220,18 +247,26 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized to view document at this time'); }); it('should return the policy url when the doucument requested is an available document', async () => { - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ); expect(url).toEqual('localhost'); }); @@ -247,10 +282,14 @@ describe('getDownloadPolicyUrlInteractor', () => { sealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, }; - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ); expect(url).toEqual('localhost'); }); @@ -270,19 +309,27 @@ describe('getDownloadPolicyUrlInteractor', () => { sealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, }; - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ); expect(url).toEqual('localhost'); }); it('should throw a not found error when the document requested is a document that is not on the docket record', async () => { await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: '26258791-7a20-4a53-8e25-cc509b502cf3', - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: '26258791-7a20-4a53-8e25-cc509b502cf3', + }, + mockPetitionerUser, + ), ).rejects.toThrow( 'Docket entry 26258791-7a20-4a53-8e25-cc509b502cf3 was not found.', ); @@ -295,10 +342,14 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow( `Docket entry ${baseDocketEntry.docketEntryId} does not have an attached file.`, ); @@ -310,10 +361,14 @@ describe('getDownloadPolicyUrlInteractor', () => { .getCaseByDocketNumber.mockReturnValue({ docketEntries: [] }); await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: '123-20', - key: '26258791-7a20-4a53-8e25-cc509b502cf3', - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: '123-20', + key: '26258791-7a20-4a53-8e25-cc509b502cf3', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Case 123-20 was not found.'); }); @@ -326,10 +381,14 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized to view document at this time'); }); @@ -342,29 +401,41 @@ describe('getDownloadPolicyUrlInteractor', () => { servedAt: applicationContext.getUtilities().createISODateString(), }; - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ); expect(url).toEqual('localhost'); }); it('should return the policy url when the document requested is a case confirmation pdf', async () => { - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: 'case-101-18-confirmation.pdf', - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: 'case-101-18-confirmation.pdf', + }, + mockPetitionerUser, + ); expect(url).toEqual('localhost'); }); it('should throw an error when the document requested is a STIN', async () => { await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: stinDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: stinDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized to view document at this time.'); }); @@ -394,10 +465,14 @@ describe('getDownloadPolicyUrlInteractor', () => { userId: '7805d1ab-18d0-43ec-bafb-654e83405416', }); - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: briefDocketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: briefDocketEntryId, + }, + mockPetitionerUser, + ); expect(url).toEqual('localhost'); }); @@ -435,19 +510,20 @@ describe('getDownloadPolicyUrlInteractor', () => { }); await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: briefDocketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: briefDocketEntryId, + }, + mockPetitionerUser, + ), ).rejects.toThrow(); }); }); describe('when the user is a private practitioner not associated with case', () => { beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue( - privatePractitionerUser, - ); applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(false); @@ -461,10 +537,14 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Unauthorized to view document at this time'); }); @@ -480,23 +560,26 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPrivatePractitionerUser, + ), ).resolves.toBeDefined(); }); }); describe('when the user is a private practitioner associated with case', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue( - privatePractitionerUser, - ); - }); - beforeEach(() => { - mockCase.privatePractitioners = [privatePractitionerUser]; + mockCase.privatePractitioners = [ + { + ...privatePractitionerUser, + userId: mockPrivatePractitionerUser.userId, + }, + ]; }); it('should receive the policy url when the document being viewed is a document that has been sealed to the public', async () => { @@ -510,10 +593,14 @@ describe('getDownloadPolicyUrlInteractor', () => { servedAt: applicationContext.getUtilities().createISODateString(), }; - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPrivatePractitionerUser, + ); expect(url).toEqual('localhost'); }); @@ -530,10 +617,14 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Unauthorized to view document at this time'); }); @@ -546,27 +637,31 @@ describe('getDownloadPolicyUrlInteractor', () => { servedAt: applicationContext.getUtilities().createISODateString(), }); - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPrivatePractitionerUser, + ); expect(url).toEqual('localhost'); }); }); describe('when the user is a petitions clerk', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - }); - it('should return the policy url when the case has not been served and the requested document is a STIN', async () => { mockCase.docketEntries[0].servedAt = undefined; stinDocketEntry.servedAt = undefined; - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: stinDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: stinDocketEntry.docketEntryId, + }, + mockPetitionsClerkUser, + ); expect(url).toEqual('localhost'); }); @@ -575,25 +670,29 @@ describe('getDownloadPolicyUrlInteractor', () => { mockCase.docketEntries[0].servedAt = '2019-08-25T05:00:00.000Z'; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: stinDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: stinDocketEntry.docketEntryId, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(UNAUTHORIZED_DOCUMENT_MESSAGE); }); }); describe('when the user is a docket clerk', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - }); - it('should throw an error when the requested document is a STIN', async () => { await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: stinDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: stinDocketEntry.docketEntryId, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(UNAUTHORIZED_DOCUMENT_MESSAGE); }); @@ -605,38 +704,46 @@ describe('getDownloadPolicyUrlInteractor', () => { }, ]; - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: mockCorrespondenceId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: mockCorrespondenceId, + }, + mockDocketClerkUser, + ); expect(url).toEqual('localhost'); }); }); describe('when the user is a irs superuser', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(irsSuperuserUser); - }); - it('should throw an error when the petition document on the case is not served', async () => { mockCase.docketEntries[0].servedAt = undefined; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockIrsSuperuser, + ), ).rejects.toThrow(UNAUTHORIZED_DOCUMENT_MESSAGE); }); it('should return the policy url when requested document is a petition on a served case', async () => { mockCase.docketEntries[0].servedAt = '2019-08-25T05:00:00.000Z'; - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: petitionDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: petitionDocketEntry.docketEntryId, + }, + mockIrsSuperuser, + ); expect(url).toEqual('localhost'); }); @@ -653,10 +760,14 @@ describe('getDownloadPolicyUrlInteractor', () => { servedAt: '2019-03-01T21:40:46.415Z', }); - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: '60814ae9-cd39-454a-9dc7-f5595a39988f', - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: '60814ae9-cd39-454a-9dc7-f5595a39988f', + }, + mockIrsSuperuser, + ); expect(url).toEqual('localhost'); }); @@ -674,10 +785,14 @@ describe('getDownloadPolicyUrlInteractor', () => { servedAt: applicationContext.getUtilities().createISODateString(), }); - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: '60814ae9-cd39-454a-9dc7-f5595a39988f', - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: '60814ae9-cd39-454a-9dc7-f5595a39988f', + }, + mockIrsSuperuser, + ); expect(url).toEqual('localhost'); }); @@ -692,10 +807,14 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: '60814ae9-cd39-454a-9dc7-f5595a39988f', - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: '60814ae9-cd39-454a-9dc7-f5595a39988f', + }, + mockIrsSuperuser, + ), ).rejects.toThrow( 'Docket entry 60814ae9-cd39-454a-9dc7-f5595a39988f does not have an attached file.', ); @@ -703,10 +822,14 @@ describe('getDownloadPolicyUrlInteractor', () => { it('throws a not found error if the user role is irsSuperuser and the petition document on the case is served but the document requested is not on the case', async () => { await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: '984fe4c3-7685-4d1e-9ad6-9914785e6dd6', - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: '984fe4c3-7685-4d1e-9ad6-9914785e6dd6', + }, + mockIrsSuperuser, + ), ).rejects.toThrow( 'Docket entry 984fe4c3-7685-4d1e-9ad6-9914785e6dd6 was not found.', ); @@ -720,12 +843,10 @@ describe('getDownloadPolicyUrlInteractor', () => { units: 'hours', }); - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(irsPractitionerUser); - }); - beforeEach(() => { - mockCase.irsPractitioners = [irsPractitionerUser]; + mockCase.irsPractitioners = [ + { ...irsPractitionerUser, userId: mockIrsPractitionerUser.userId }, + ]; }); it('should not throw an error if the user is associated with the case and the document meets age requirements', async () => { @@ -738,10 +859,14 @@ describe('getDownloadPolicyUrlInteractor', () => { isFileAttached: true, }; - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockIrsPractitionerUser, + ); expect(url).toEqual('localhost'); }); @@ -757,10 +882,14 @@ describe('getDownloadPolicyUrlInteractor', () => { }; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockIrsPractitionerUser, + ), ).rejects.toThrow(UNAUTHORIZED_DOCUMENT_MESSAGE); }); }); @@ -769,39 +898,42 @@ describe('getDownloadPolicyUrlInteractor', () => { const leadMockCase: RawCase = { ...MOCK_CASE, leadDocketNumber: MOCK_CASE.docketNumber, - petitioners: [casePetitioner], + petitioners: [ + { ...casePetitioner, contactId: mockPetitionerUser.userId }, + ], }; leadMockCase.consolidatedCases = [ new ConsolidatedCaseSummary(leadMockCase), ]; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(leadMockCase); }); it('should return the policy url when the document requested is an available document', async () => { - const url = await getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: baseDocketEntry.docketEntryId, - }); + const url = await getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: baseDocketEntry.docketEntryId, + }, + mockPetitionerUser, + ); expect(url).toEqual('localhost'); }); it('should throw an error when the document requested is an available document and the user is not associated with the consolidated group', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - ...petitionerUser, - userId: 'someone-else', - }); - await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: `case-${MOCK_CASE.docketNumber}-confirmation.pdf`, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: `case-${MOCK_CASE.docketNumber}-confirmation.pdf`, + }, + { ...mockPetitionerUser, userId: 'someone-else' }, + ), ).rejects.toThrow(new UnauthorizedError('Unauthorized')); }); }); From 5114740b4aa056f78c70aa7e8c10071ad5a0c855 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 12:04:37 -0700 Subject: [PATCH 076/523] 10417: Remove getCurrentUser from shared --- .../getNotificationsInteractor.test.ts | 235 +++++++++++------- shared/src/test/mockAuthUsers.ts | 1 + 2 files changed, 152 insertions(+), 84 deletions(-) diff --git a/shared/src/business/useCases/getNotificationsInteractor.test.ts b/shared/src/business/useCases/getNotificationsInteractor.test.ts index 8d650273366..a1e3ea0c41f 100644 --- a/shared/src/business/useCases/getNotificationsInteractor.test.ts +++ b/shared/src/business/useCases/getNotificationsInteractor.test.ts @@ -1,4 +1,6 @@ import { + ADC_SECTION, + CHAMBERS_SECTION, CHIEF_JUDGE, DOCKET_SECTION, PETITIONS_SECTION, @@ -7,6 +9,11 @@ import { import { applicationContext } from '../test/createTestApplicationContext'; import { caseServicesSupervisorUser } from '../../test/mockUsers'; import { getNotificationsInteractor } from './getNotificationsInteractor'; +import { + mockAdcUser, + mockDocketClerkUser, + mockJudgeUser, +} from '@shared/test/mockAuthUsers'; const workItems = [ { @@ -98,50 +105,19 @@ describe('getNotificationsInteractor', () => { ...workItems, { ...workItems[0], isRead: false }, ]); - - applicationContext - .getPersistenceGateway() - .getUserById.mockImplementation(({ userId }) => { - if (userId === 'e8577e31-d6d5-4c4a-adc6-520075f3dde5') { - return { - role: ROLES.docketClerk, - section: DOCKET_SECTION, - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', - }; - } else if (userId === 'ff377e31-d6d5-4c4a-adc6-520075f3dde5') { - return { - role: ROLES.petitioner, - userId: 'ff377e31-d6d5-4c4a-adc6-520075f3dde5', - }; - } else if (userId === 'ee577e31-d6d5-4c4a-adc6-520075f3dde5') { - return { - name: 'Some Judge', - role: ROLES.judge, - section: 'someChambers', - userId: 'ee577e31-d6d5-4c4a-adc6-520075f3dde5', - }; - } else if (userId === '79f21a87-810c-4440-9189-bb6bfea413fd') { - return { - name: 'ADC', - role: ROLES.adc, - section: 'adc', - userId: '79f21a87-810c-4440-9189-bb6bfea413fd', - }; - } - }); - - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', - }); }); it('returns an unread count for my messages', async () => { + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); applicationContext .getPersistenceGateway() .getDocumentQCInboxForUser.mockReturnValue([ { - assigneeId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + assigneeId: mockDocketClerkUser.userId, caseIsInProgress: false, docketEntry: { isFileAttached: true }, isRead: true, @@ -152,7 +128,9 @@ describe('getNotificationsInteractor', () => { const result = await getNotificationsInteractor( applicationContext, {} as any, + mockDocketClerkUser, ); + expect(result).toEqual({ qcIndividualInProgressCount: 0, qcIndividualInboxCount: 1, @@ -166,38 +144,64 @@ describe('getNotificationsInteractor', () => { }); it('returns the total user inbox count', async () => { + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); + const result = await await getNotificationsInteractor( applicationContext, {} as any, + mockDocketClerkUser, ); expect(result.userInboxCount).toEqual(1); }); it('returns the total section messages count', async () => { + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); + const result = await await getNotificationsInteractor( applicationContext, {} as any, + mockDocketClerkUser, ); expect(result.userSectionCount).toEqual(2); }); it('returns an accurate unread count for legacy items marked complete', async () => { + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); + const result = await getNotificationsInteractor( applicationContext, {} as any, + mockDocketClerkUser, ); expect(result.qcUnreadCount).toEqual(1); }); it('returns the qcIndividualInProgressCount for qc individual items with caseIsInProgress true, isFileAttached true and a judgeUserId supplied', async () => { + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); applicationContext .getPersistenceGateway() .getDocumentQCInboxForUser.mockReturnValue([ { - assigneeId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + assigneeId: mockDocketClerkUser.userId, associatedJudge: 'Judge Barker', caseIsInProgress: true, docketEntry: { @@ -208,7 +212,7 @@ describe('getNotificationsInteractor', () => { section: DOCKET_SECTION, }, { - assigneeId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + assigneeId: mockDocketClerkUser.userId, associatedJudge: 'Some Judge', caseIsInProgress: true, docketEntry: { @@ -219,7 +223,7 @@ describe('getNotificationsInteractor', () => { section: DOCKET_SECTION, }, { - assigneeId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + assigneeId: mockDocketClerkUser.userId, associatedJudge: 'Some Judge', caseIsInProgress: false, docketEntry: { @@ -231,20 +235,29 @@ describe('getNotificationsInteractor', () => { }, ]); - const result = await getNotificationsInteractor(applicationContext, { - caseServicesSupervisorData: undefined, - judgeUserId: 'ee577e31-d6d5-4c4a-adc6-520075f3dde5', - }); + const result = await getNotificationsInteractor( + applicationContext, + { + caseServicesSupervisorData: undefined, + judgeUserId: mockJudgeUser.userId, + }, + mockDocketClerkUser, + ); expect(result.qcIndividualInProgressCount).toEqual(1); }); it('returns the qcIndividualInboxCount for qc individual items with caseIsInProgress false, isFileAttached true and a judgeUserId supplied', async () => { + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); applicationContext .getPersistenceGateway() .getDocumentQCInboxForUser.mockReturnValue([ { - assigneeId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + assigneeId: mockDocketClerkUser.userId, associatedJudge: 'Judge Barker', caseIsInProgress: false, docketEntry: { @@ -255,7 +268,7 @@ describe('getNotificationsInteractor', () => { section: DOCKET_SECTION, }, { - assigneeId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + assigneeId: mockDocketClerkUser.userId, associatedJudge: 'Some Judge', caseIsInProgress: false, docketEntry: { @@ -266,7 +279,7 @@ describe('getNotificationsInteractor', () => { section: DOCKET_SECTION, }, { - assigneeId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + assigneeId: mockDocketClerkUser.userId, associatedJudge: 'Some Judge', caseIsInProgress: true, docketEntry: { @@ -278,15 +291,24 @@ describe('getNotificationsInteractor', () => { }, ]); - const result = await getNotificationsInteractor(applicationContext, { - caseServicesSupervisorData: undefined, - judgeUserId: 'ee577e31-d6d5-4c4a-adc6-520075f3dde5', - }); + const result = await getNotificationsInteractor( + applicationContext, + { + caseServicesSupervisorData: undefined, + judgeUserId: mockJudgeUser.userId, + }, + mockDocketClerkUser, + ); expect(result.qcIndividualInboxCount).toEqual(1); }); it('returns the qcSectionInProgressCount for qc section items with caseIsInProgress true, isFileAttached true and a judgeUserId supplied', async () => { + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); applicationContext .getPersistenceGateway() .getDocumentQCInboxForSection.mockReturnValue([ @@ -321,7 +343,7 @@ describe('getNotificationsInteractor', () => { section: DOCKET_SECTION, }, { - assigneeId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + assigneeId: mockDocketClerkUser.userId, associatedJudge: 'Some Judge', caseIsInProgress: true, docketEntry: { @@ -343,15 +365,24 @@ describe('getNotificationsInteractor', () => { }, ]); - const result = await getNotificationsInteractor(applicationContext, { - caseServicesSupervisorData: undefined, - judgeUserId: 'ee577e31-d6d5-4c4a-adc6-520075f3dde5', - }); + const result = await getNotificationsInteractor( + applicationContext, + { + caseServicesSupervisorData: undefined, + judgeUserId: mockJudgeUser.userId, + }, + mockDocketClerkUser, + ); expect(result.qcSectionInProgressCount).toEqual(2); }); it('returns the qcSectionInboxCount for qc section items with caseIsInProgress true, isFileAttached true and a judgeUserId supplied', async () => { + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); applicationContext .getPersistenceGateway() .getDocumentQCInboxForSection.mockReturnValue([ @@ -377,15 +408,24 @@ describe('getNotificationsInteractor', () => { }, ]); - const result = await getNotificationsInteractor(applicationContext, { - caseServicesSupervisorData: undefined, - judgeUserId: 'ee577e31-d6d5-4c4a-adc6-520075f3dde5', - }); + const result = await getNotificationsInteractor( + applicationContext, + { + caseServicesSupervisorData: undefined, + judgeUserId: mockJudgeUser.userId, + }, + mockDocketClerkUser, + ); expect(result.qcSectionInboxCount).toEqual(1); }); it('returns an accurate unread count for my messages', async () => { + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); applicationContext .getPersistenceGateway() .getUserInboxMessages.mockReturnValue([ @@ -399,10 +439,14 @@ describe('getNotificationsInteractor', () => { }, ]); - const result = await getNotificationsInteractor(applicationContext, { - caseServicesSupervisorData: undefined, - judgeUserId: 'docketclerk', - }); + const result = await getNotificationsInteractor( + applicationContext, + { + caseServicesSupervisorData: undefined, + judgeUserId: 'docketclerk', + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ userInboxCount: 2, @@ -410,11 +454,22 @@ describe('getNotificationsInteractor', () => { }); it('should fetch the qc section items for the provided judgeUserId', async () => { - await getNotificationsInteractor(applicationContext, { - caseServicesSupervisorData: undefined, - judgeUserId: 'ee577e31-d6d5-4c4a-adc6-520075f3dde5', + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + name: 'Some Judge', + role: ROLES.judge, + section: CHAMBERS_SECTION, + userId: mockJudgeUser.userId, }); + await getNotificationsInteractor( + applicationContext, + { + caseServicesSupervisorData: undefined, + judgeUserId: mockJudgeUser.userId, + }, + mockDocketClerkUser, + ); + expect( applicationContext.getPersistenceGateway().getDocumentQCInboxForSection .mock.calls[0][0], @@ -424,7 +479,17 @@ describe('getNotificationsInteractor', () => { }); it('should fetch the qc section items without a judgeName when a judgeUserId is not provided', async () => { - await getNotificationsInteractor(applicationContext, {} as any); + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ + role: ROLES.docketClerk, + section: DOCKET_SECTION, + userId: mockDocketClerkUser.userId, + }); + + await getNotificationsInteractor( + applicationContext, + {} as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDocumentQCInboxForSection @@ -435,12 +500,17 @@ describe('getNotificationsInteractor', () => { }); it('should fetch the qc section items with judgeName of CHIEF_JUDGE when a judgeUserId is not provided and the user role is adc', async () => { - applicationContext.getCurrentUser.mockReturnValue({ + applicationContext.getPersistenceGateway().getUserById.mockResolvedValue({ role: ROLES.adc, - userId: '79f21a87-810c-4440-9189-bb6bfea413fd', + section: ADC_SECTION, + userId: mockAdcUser.userId, }); - await getNotificationsInteractor(applicationContext, {} as any); + await getNotificationsInteractor( + applicationContext, + {} as any, + mockAdcUser, + ); expect( applicationContext.getPersistenceGateway().getDocumentQCInboxForSection @@ -451,11 +521,6 @@ describe('getNotificationsInteractor', () => { }); it('should fetch messages for the filtered document QC inbox for the selected section when caseServicesSupervisorData is not empty', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.adc, - userId: '79f21a87-810c-4440-9189-bb6bfea413fd', - }); - const filteredWorkItem = { associatedJudge: 'Judge Barker', caseIsInProgress: false, @@ -466,23 +531,25 @@ describe('getNotificationsInteractor', () => { isRead: true, section: PETITIONS_SECTION, }; - const mockCaseServicesSupervisorData = { section: PETITIONS_SECTION, userId: caseServicesSupervisorUser.userId, }; - applicationContext .getPersistenceGateway() .getDocumentQCInboxForSection.mockReturnValue([filteredWorkItem]); - const result = await getNotificationsInteractor(applicationContext, { - caseServicesSupervisorData: { - section: PETITIONS_SECTION, - userId: caseServicesSupervisorUser.userId, + const result = await getNotificationsInteractor( + applicationContext, + { + caseServicesSupervisorData: { + section: PETITIONS_SECTION, + userId: caseServicesSupervisorUser.userId, + }, + judgeUserId: undefined, }, - judgeUserId: undefined, - }); + mockAdcUser, + ); expect( applicationContext.getPersistenceGateway().getUserInboxMessages.mock diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index 2231c3dc30d..742bd3f0be0 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -7,6 +7,7 @@ export const mockPetitionerUser: AuthUser = { role: ROLES.petitioner, userId: 'e4988d2d-deb0-4b65-a97f-5abfadb0970a', }; + export const mockDocketClerkUser: AuthUser = { email: 'mockDocketClerk@example.com', name: 'Dimmy Docket', From c5894588bb4af38a8ee9b8a8ec9c8ce493a6d6b9 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 12:06:59 -0700 Subject: [PATCH 077/523] 10417: Remove getCurrentUser from shared --- .../getPaperServicePdfUrlInteractor.test.ts | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/shared/src/business/useCases/getPaperServicePdfUrlInteractor.test.ts b/shared/src/business/useCases/getPaperServicePdfUrlInteractor.test.ts index 19cc4fdf2d7..1b9bd34bd19 100644 --- a/shared/src/business/useCases/getPaperServicePdfUrlInteractor.test.ts +++ b/shared/src/business/useCases/getPaperServicePdfUrlInteractor.test.ts @@ -1,29 +1,37 @@ import { applicationContext } from '../test/createTestApplicationContext'; import { getPaperServicePdfUrlInteractor } from './getPaperServicePdfUrlInteractor'; -import { petitionerUser, petitionsClerkUser } from '@shared/test/mockUsers'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getPaperServicePdfUrlInteractor', () => { it('should throw an unauthorized error when the user does not have permission to re-print trial session paper service documents', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce(petitionerUser); // Only trial clerks and petitions clerks can re-print paper service documents - await expect( - getPaperServicePdfUrlInteractor(applicationContext, { - fileId: 'd30ca1a5-6e9c-411d-a292-3e89abf13141', - }), + getPaperServicePdfUrlInteractor( + applicationContext, + { + fileId: 'd30ca1a5-6e9c-411d-a292-3e89abf13141', + }, + mockPetitionerUser, // Only trial clerks and petitions clerks can re-print paper service documents + ), ).rejects.toThrow('Unauthorized'); }); it('should return a url to the document specified when the user has permission to re-print trial session paper service documents', async () => { const mockFileId = 'd30ca1a5-6e9c-411d-a292-3e89abf13141'; const mockDocumentUrl = 'example.com'; - applicationContext.getCurrentUser.mockReturnValueOnce(petitionsClerkUser); applicationContext .getPersistenceGateway() .getDownloadPolicyUrl.mockResolvedValue({ url: mockDocumentUrl }); - const { url } = await getPaperServicePdfUrlInteractor(applicationContext, { - fileId: mockFileId, - }); + const { url } = await getPaperServicePdfUrlInteractor( + applicationContext, + { + fileId: mockFileId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDownloadPolicyUrl, From 2e64667f6546cb1f3b1e63e92fe2809e16d8ffff Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 12:08:52 -0700 Subject: [PATCH 078/523] 10417: Remove getCurrentUser from shared --- .../getReconciliationReportInteractor.test.ts | 111 ++++++++++++------ 1 file changed, 72 insertions(+), 39 deletions(-) diff --git a/shared/src/business/useCases/getReconciliationReportInteractor.test.ts b/shared/src/business/useCases/getReconciliationReportInteractor.test.ts index 5c8c8ef0345..0c072debbc8 100644 --- a/shared/src/business/useCases/getReconciliationReportInteractor.test.ts +++ b/shared/src/business/useCases/getReconciliationReportInteractor.test.ts @@ -4,9 +4,12 @@ import { createStartOfDayISO, formatNow, } from '../utilities/DateHandler'; -import { ROLES } from '../entities/EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; import { getReconciliationReportInteractor } from './getReconciliationReportInteractor'; +import { + mockDocketClerkUser, + mockIrsSuperuser, +} from '@shared/test/mockAuthUsers'; describe('getReconciliationReportInteractor', () => { const mockCaseCaption = 'Kaitlin Chaney, Petitioner'; @@ -22,46 +25,56 @@ describe('getReconciliationReportInteractor', () => { sk: 'case|135-20', }, ]); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsSuperuser, - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', - }); }); it('should throw unauthorized error if user does not have permission', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: ROLES.docketClerk, - userId: '33577e31-d6d5-4c4a-adc6-520075f3dde5', - }); await expect( - getReconciliationReportInteractor(applicationContext, { - reconciliationDate: undefined, - }), + getReconciliationReportInteractor( + applicationContext, + { + reconciliationDate: undefined, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should throw an error if date is not formatted correctly', async () => { await expect( - getReconciliationReportInteractor(applicationContext, { - reconciliationDate: undefined, - }), + getReconciliationReportInteractor( + applicationContext, + { + reconciliationDate: undefined, + }, + mockIrsSuperuser, + ), ).rejects.toThrow('Must be valid reconciliation date'); }); + it('should throw an error if date is in the future', async () => { await expect( - getReconciliationReportInteractor(applicationContext, { - reconciliationDate: '9999-01-01', - }), + getReconciliationReportInteractor( + applicationContext, + { + reconciliationDate: '9999-01-01', + }, + mockIrsSuperuser, + ), ).rejects.toThrow('not later than today'); }); + it('should call the persistence method with current date if "today" is provided as a parameter', async () => { applicationContext .getPersistenceGateway() .getReconciliationReport.mockReturnValue([]); - await getReconciliationReportInteractor(applicationContext, { - reconciliationDate: 'today', - }); + await getReconciliationReportInteractor( + applicationContext, + { + reconciliationDate: 'today', + }, + mockIrsSuperuser, + ); const reconciliationDateNow = formatNow(FORMATS.YYYYMMDD); const [year, month, day] = reconciliationDateNow.split('-'); @@ -83,9 +96,13 @@ describe('getReconciliationReportInteractor', () => { .getReconciliationReport.mockReturnValue([]); const reconciliationDate = '2021-01-01'; - const result = await getReconciliationReportInteractor(applicationContext, { - reconciliationDate, - }); + const result = await getReconciliationReportInteractor( + applicationContext, + { + reconciliationDate, + }, + mockIrsSuperuser, + ); expect(result).toMatchObject({ docketEntries: expect.any(Array), @@ -114,9 +131,13 @@ describe('getReconciliationReportInteractor', () => { .getReconciliationReport.mockReturnValue(docketEntries); const reconciliationDate = '2021-01-01'; - const result = await getReconciliationReportInteractor(applicationContext, { - reconciliationDate, - }); + const result = await getReconciliationReportInteractor( + applicationContext, + { + reconciliationDate, + }, + mockIrsSuperuser, + ); expect(result).toMatchObject({ docketEntries, @@ -154,9 +175,13 @@ describe('getReconciliationReportInteractor', () => { .getReconciliationReport.mockReturnValue(docketEntries); const reconciliationDate = '2021-01-01'; - await getReconciliationReportInteractor(applicationContext, { - reconciliationDate, - }); + await getReconciliationReportInteractor( + applicationContext, + { + reconciliationDate, + }, + mockIrsSuperuser, + ); expect( applicationContext.getPersistenceGateway().getCasesByDocketNumbers.mock @@ -169,10 +194,14 @@ describe('getReconciliationReportInteractor', () => { const startDate = '2020-01-01'; const timeStart = '05:00'; await expect( - getReconciliationReportInteractor(applicationContext, { - reconciliationDate: startDate, - start: timeStart, - }), + getReconciliationReportInteractor( + applicationContext, + { + reconciliationDate: startDate, + start: timeStart, + }, + mockIrsSuperuser, + ), ).resolves.not.toThrow(); }); @@ -197,11 +226,15 @@ describe('getReconciliationReportInteractor', () => { .getPersistenceGateway() .getReconciliationReport.mockReturnValue(docketEntries); - const result = await getReconciliationReportInteractor(applicationContext, { - end: timeEnd, - reconciliationDate: startDate, - start: timeStart, - }); + const result = await getReconciliationReportInteractor( + applicationContext, + { + end: timeEnd, + reconciliationDate: startDate, + start: timeStart, + }, + mockIrsSuperuser, + ); expect(result.reconciliationDate).toBe(startDate); }); }); From 018bd4cdfde35ab190a53c71ba07fd5784d88398 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 12:10:55 -0700 Subject: [PATCH 079/523] 10417: Remove getCurrentUser from shared --- .../getUploadPolicyInteractor.test.ts | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/shared/src/business/useCases/getUploadPolicyInteractor.test.ts b/shared/src/business/useCases/getUploadPolicyInteractor.test.ts index e641d6518f3..07df571993c 100644 --- a/shared/src/business/useCases/getUploadPolicyInteractor.test.ts +++ b/shared/src/business/useCases/getUploadPolicyInteractor.test.ts @@ -1,16 +1,20 @@ -import { ROLES } from '../entities/EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; import { getUploadPolicyInteractor } from './getUploadPolicyInteractor'; +import { + mockAdminUser, + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getUploadPolicyInteractor', () => { it('throw unauthorized error on invalid role', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.admin, - userId: 'petitioner', - }); let error; try { - await getUploadPolicyInteractor(applicationContext, {} as any); + await getUploadPolicyInteractor( + applicationContext, + {} as any, + mockAdminUser, + ); } catch (err) { error = err; } @@ -18,11 +22,6 @@ describe('getUploadPolicyInteractor', () => { }); it('returns the expected policy when the file does not already exist', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - isExternalUser: () => true, - role: ROLES.petitioner, - userId: 'petitioner', - }); applicationContext .getPersistenceGateway() .getUploadPolicy.mockReturnValue('policy'); @@ -30,32 +29,30 @@ describe('getUploadPolicyInteractor', () => { .getPersistenceGateway() .isFileExists.mockReturnValue(false); - const url = await getUploadPolicyInteractor(applicationContext, {} as any); + const url = await getUploadPolicyInteractor( + applicationContext, + {} as any, + mockPetitionerUser, + ); expect(url).toEqual('policy'); }); it('does not check if the file exists if the user is internal', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - isExternalUser: () => false, - role: ROLES.docketClerk, - userId: 'docket', - }); applicationContext .getPersistenceGateway() .getUploadPolicy.mockReturnValue('policy'); - await getUploadPolicyInteractor(applicationContext, {} as any); + await getUploadPolicyInteractor( + applicationContext, + {} as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().isFileExists, ).not.toHaveBeenCalled(); }); it('throws an unauthorized exception when file already exists', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - isExternalUser: () => true, - role: ROLES.petitioner, - userId: 'petitioner', - }); applicationContext .getPersistenceGateway() .getUploadPolicy.mockReturnValue('policy'); @@ -65,7 +62,11 @@ describe('getUploadPolicyInteractor', () => { let error; try { - await getUploadPolicyInteractor(applicationContext, {} as any); + await getUploadPolicyInteractor( + applicationContext, + {} as any, + mockPetitionerUser, + ); } catch (err) { error = err; } From 3b6b2d1bec62a8e8070f39de2f49ec37b22ad5f0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 12:20:24 -0700 Subject: [PATCH 080/523] 10417: Remove getCurrentUser from shared --- .../useCases/getUserInteractor.test.ts | 99 +++++++------------ 1 file changed, 38 insertions(+), 61 deletions(-) diff --git a/shared/src/business/useCases/getUserInteractor.test.ts b/shared/src/business/useCases/getUserInteractor.test.ts index d1e368996f9..1040c52b37b 100644 --- a/shared/src/business/useCases/getUserInteractor.test.ts +++ b/shared/src/business/useCases/getUserInteractor.test.ts @@ -1,32 +1,31 @@ -import { IrsPractitioner } from '../entities/IrsPractitioner'; +import { IrsPractitioner } from '@shared/business/entities/IrsPractitioner'; import { PETITIONS_SECTION, ROLES } from '../entities/EntityConstants'; import { Practitioner } from '@shared/business/entities/Practitioner'; import { PrivatePractitioner } from '@shared/business/entities/PrivatePractitioner'; -import { User } from '../entities/User'; import { applicationContext } from '../test/createTestApplicationContext'; import { getUserInteractor } from './getUserInteractor'; +import { + mockIrsPractitionerUser, + mockJudgeUser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getUserInteractor', () => { it('should call the persistence method to get the user', async () => { - const mockPetitionsClerk = { - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }; - applicationContext.getCurrentUser.mockReturnValue( - new User(mockPetitionsClerk), - ); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ - ...mockPetitionsClerk, + ...mockPetitionsClerkUser, section: PETITIONS_SECTION, }); - const user = await getUserInteractor(applicationContext); + const user = await getUserInteractor( + applicationContext, + mockPetitionsClerkUser, + ); expect(user).toEqual({ - ...mockPetitionsClerk, + ...mockPetitionsClerkUser, barNumber: undefined, - email: undefined, entityName: 'User', section: PETITIONS_SECTION, token: undefined, @@ -34,20 +33,14 @@ describe('getUserInteractor', () => { }); it('should throw an error if the user is not found', async () => { - const mockPetitionsClerk = { - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }; - applicationContext.getCurrentUser.mockReturnValue( - new User(mockPetitionsClerk), - ); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(null); - await expect(getUserInteractor(applicationContext)).rejects.toThrow( - `User id "${mockPetitionsClerk.userId}" not found in persistence.`, + await expect( + getUserInteractor(applicationContext, mockPetitionsClerkUser), + ).rejects.toThrow( + `User id "${mockPetitionsClerkUser.userId}" not found in persistence.`, ); }); @@ -58,15 +51,14 @@ describe('getUserInteractor', () => { judgeTitle: 'Judge', name: 'Test Judge', role: ROLES.judge, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', + userId: mockJudgeUser.userId, }; - applicationContext.getCurrentUser.mockReturnValue(new User(mockJudge)); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ ...mockJudge, section: 'judge', }); - const user = await getUserInteractor(applicationContext); + const user = await getUserInteractor(applicationContext, mockJudgeUser); expect(user).toEqual({ ...mockJudge, @@ -79,27 +71,20 @@ describe('getUserInteractor', () => { }); it('should return a PrivatePractitioner entity when the entity returned from persistence is a PrivatePractitioner', async () => { - const mockPrivatePractitioner = { - entityName: PrivatePractitioner.ENTITY_NAME, - name: 'Test Private Practitioner', - role: ROLES.privatePractitioner, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }; - - applicationContext.getCurrentUser.mockReturnValue( - new User(mockPrivatePractitioner), - ); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ - ...mockPrivatePractitioner, + ...mockPrivatePractitionerUser, barNumber: 'PT1234', + entityName: PrivatePractitioner.ENTITY_NAME, }); - const user = await getUserInteractor(applicationContext); + const user = await getUserInteractor( + applicationContext, + mockPrivatePractitionerUser, + ); expect(user).toMatchObject({ - ...mockPrivatePractitioner, + ...mockPrivatePractitionerUser, barNumber: 'PT1234', - email: undefined, isUpdatingInformation: undefined, representing: [], token: undefined, @@ -107,27 +92,20 @@ describe('getUserInteractor', () => { }); it('should return an IrsPractitioner entity when the entity returned from persistence is a IrsPractitioner', async () => { - const mockIrsPractitioner = { - entityName: IrsPractitioner.ENTITY_NAME, - name: 'Test Irs Practitioner', - role: ROLES.irsPractitioner, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }; - - applicationContext.getCurrentUser.mockReturnValue( - new User(mockIrsPractitioner), - ); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ - ...mockIrsPractitioner, + ...mockIrsPractitionerUser, barNumber: 'PT5678', + entityName: IrsPractitioner.ENTITY_NAME, }); - const user = await getUserInteractor(applicationContext); + const user = await getUserInteractor( + applicationContext, + mockIrsPractitionerUser, + ); expect(user).toMatchObject({ - ...mockIrsPractitioner, + ...mockIrsPractitionerUser, barNumber: 'PT5678', - email: undefined, isUpdatingInformation: undefined, token: undefined, }); @@ -146,18 +124,17 @@ describe('getUserInteractor', () => { practiceType: 'IRS', practitionerType: 'Attorney', role: ROLES.irsPractitioner, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', + userId: mockIrsPractitionerUser.userId, }; - - applicationContext.getCurrentUser.mockReturnValue( - new User(mockPractitioner), - ); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ ...mockPractitioner, barNumber: 'PT9012', }); - const user = await getUserInteractor(applicationContext); + const user = await getUserInteractor( + applicationContext, + mockIrsPractitionerUser, + ); expect(user).toMatchObject({ ...mockPractitioner, From 68affbdd9b09b16a0167dd4ab267dae106173175 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 12:50:23 -0700 Subject: [PATCH 081/523] 10417: Remove getCurrentUser from shared --- .../removeCasePendingItemInteractor.test.ts | 96 ++++++++++--------- .../removeCasePendingItemInteractor.ts | 10 +- .../cases/removeCasePendingItemLambda.ts | 27 ++++-- 3 files changed, 78 insertions(+), 55 deletions(-) diff --git a/shared/src/business/useCases/removeCasePendingItemInteractor.test.ts b/shared/src/business/useCases/removeCasePendingItemInteractor.test.ts index eafd746739a..aa8b3f08a6e 100644 --- a/shared/src/business/useCases/removeCasePendingItemInteractor.test.ts +++ b/shared/src/business/useCases/removeCasePendingItemInteractor.test.ts @@ -1,17 +1,15 @@ -import { - AUTOMATIC_BLOCKED_REASONS, - PARTY_TYPES, - ROLES, -} from '../entities/EntityConstants'; +import { AUTOMATIC_BLOCKED_REASONS } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; import { MOCK_LOCK } from '../../test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '../entities/User'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { removeCasePendingItemInteractor } from './removeCasePendingItemInteractor'; describe('removeCasePendingItemInteractor', () => { - let user; let mockLock; beforeAll(() => { @@ -22,13 +20,7 @@ describe('removeCasePendingItemInteractor', () => { beforeEach(() => { mockLock = undefined; - user = new User({ - name: 'Petitions Clerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); @@ -38,25 +30,27 @@ describe('removeCasePendingItemInteractor', () => { }); it('should throw an unauthorized error if user is unauthorized for updating a case', async () => { - user = new User({ - name: PARTY_TYPES.petitioner, - role: ROLES.petitioner, - userId: '2c464719-646c-463e-9826-16443500ed88', - }); - await expect( - removeCasePendingItemInteractor(applicationContext, { - docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE - docketNumber: MOCK_CASE.docketNumber, - }), + removeCasePendingItemInteractor( + applicationContext, + { + docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for update case'); }); it('should call updateCase with the pending document set to pending=false', async () => { - await removeCasePendingItemInteractor(applicationContext, { - docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE - docketNumber: MOCK_CASE.docketNumber, - }); + await removeCasePendingItemInteractor( + applicationContext, + { + docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -69,10 +63,14 @@ describe('removeCasePendingItemInteractor', () => { .getPersistenceGateway() .getCaseDeadlinesByDocketNumber.mockReturnValue([]); - await removeCasePendingItemInteractor(applicationContext, { - docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE - docketNumber: MOCK_CASE.docketNumber, - }); + await removeCasePendingItemInteractor( + applicationContext, + { + docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -91,10 +89,14 @@ describe('removeCasePendingItemInteractor', () => { { deadline: 'something' }, ]); - await removeCasePendingItemInteractor(applicationContext, { - docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE - docketNumber: MOCK_CASE.docketNumber, - }); + await removeCasePendingItemInteractor( + applicationContext, + { + docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -113,10 +115,14 @@ describe('removeCasePendingItemInteractor', () => { mockLock = MOCK_LOCK; await expect( - removeCasePendingItemInteractor(applicationContext, { - docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE - docketNumber: MOCK_CASE.docketNumber, - }), + removeCasePendingItemInteractor( + applicationContext, + { + docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -125,10 +131,14 @@ describe('removeCasePendingItemInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await removeCasePendingItemInteractor(applicationContext, { - docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE - docketNumber: MOCK_CASE.docketNumber, - }); + await removeCasePendingItemInteractor( + applicationContext, + { + docketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', // docketEntries[3] from MOCK_CASE + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/removeCasePendingItemInteractor.ts b/shared/src/business/useCases/removeCasePendingItemInteractor.ts index c5cd6d67004..85005d1dc27 100644 --- a/shared/src/business/useCases/removeCasePendingItemInteractor.ts +++ b/shared/src/business/useCases/removeCasePendingItemInteractor.ts @@ -4,6 +4,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -17,10 +18,9 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const removeCasePendingItem = async ( applicationContext, { docketEntryId, docketNumber }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.UPDATE_CASE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPDATE_CASE)) { throw new UnauthorizedError('Unauthorized for update case'); } @@ -34,7 +34,9 @@ export const removeCasePendingItem = async ( } }); - let updatedCaseEntity = new Case(caseToUpdate, { authorizedUser: user }); + let updatedCaseEntity = new Case(caseToUpdate, { + authorizedUser, + }); updatedCaseEntity = await applicationContext .getUseCaseHelpers() diff --git a/web-api/src/lambdas/cases/removeCasePendingItemLambda.ts b/web-api/src/lambdas/cases/removeCasePendingItemLambda.ts index 38e232438af..a433ed9e173 100644 --- a/web-api/src/lambdas/cases/removeCasePendingItemLambda.ts +++ b/web-api/src/lambdas/cases/removeCasePendingItemLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { removeCasePendingItemInteractor } from '@shared/business/useCases/removeCasePendingItemInteractor'; /** * used for removing pending items from a case @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const removeCasePendingItemLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .removeCasePendingItemInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const removeCasePendingItemLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await removeCasePendingItemInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 6a52b6d0af4b4d5407fd3e43b5fe66824bb7bcbf Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 12:54:40 -0700 Subject: [PATCH 082/523] 10417: Remove getCurrentUser from shared --- ...removePdfFromDocketEntryInteractor.test.ts | 118 +++++++++++------- .../removePdfFromDocketEntryInteractor.ts | 4 +- .../removePdfFromDocketEntryLambda.ts | 20 ++- 3 files changed, 88 insertions(+), 54 deletions(-) diff --git a/shared/src/business/useCases/removePdfFromDocketEntryInteractor.test.ts b/shared/src/business/useCases/removePdfFromDocketEntryInteractor.test.ts index 650a3ff77d0..c58f0dc8293 100644 --- a/shared/src/business/useCases/removePdfFromDocketEntryInteractor.test.ts +++ b/shared/src/business/useCases/removePdfFromDocketEntryInteractor.test.ts @@ -10,6 +10,10 @@ import { MOCK_LOCK } from '../../test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { removePdfFromDocketEntryInteractor } from './removePdfFromDocketEntryInteractor'; describe('removePdfFromDocketEntryInteractor', () => { @@ -61,19 +65,15 @@ describe('removePdfFromDocketEntryInteractor', () => { userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', }; - const docketClerkUser = { - name: 'docket clerk', - role: ROLES.docketClerk, - userId: '54cddcd9-d012-4874-b74f-73732c95d42b', - }; let mockLock; beforeAll(() => { applicationContext.getPersistenceGateway().deleteDocumentFile = jest.fn(); - applicationContext - .getPersistenceGateway() - .getUserById.mockReturnValue(docketClerkUser); + applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ + ...mockDocketClerkUser, + name: 'docket clerk', + }); applicationContext .getPersistenceGateway() @@ -88,29 +88,31 @@ describe('removePdfFromDocketEntryInteractor', () => { }); beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); mockLock = undefined; }); it('should throw an error if the user is unauthorized to update a case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: 'nope', - userId: 'nope', - }); - await expect( - removePdfFromDocketEntryInteractor(applicationContext, { - docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: MOCK_CASE.docketNumber, - }), + removePdfFromDocketEntryInteractor( + applicationContext, + { + docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for update case'); }); it('should fetch the case by the provided docketNumber', async () => { - await removePdfFromDocketEntryInteractor(applicationContext, { - docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: MOCK_CASE.docketNumber, - }); + await removePdfFromDocketEntryInteractor( + applicationContext, + { + docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -118,10 +120,14 @@ describe('removePdfFromDocketEntryInteractor', () => { }); it('should delete the pdf from s3 and update the case if the docketEntry has a file attached', async () => { - await removePdfFromDocketEntryInteractor(applicationContext, { - docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', // entry with isFileAttached: true - docketNumber: MOCK_CASE.docketNumber, - }); + await removePdfFromDocketEntryInteractor( + applicationContext, + { + docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', // entry with isFileAttached: true + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteDocumentFile, @@ -133,10 +139,14 @@ describe('removePdfFromDocketEntryInteractor', () => { }); it('should set the docketEntry isFileAttached flag to false', async () => { - await removePdfFromDocketEntryInteractor(applicationContext, { - docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: MOCK_CASE.docketNumber, - }); + await removePdfFromDocketEntryInteractor( + applicationContext, + { + docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); const docketEntry = applicationContext .getPersistenceGateway() @@ -148,10 +158,14 @@ describe('removePdfFromDocketEntryInteractor', () => { }); it('does not modify the docketEntry or case if the isFileAttachedFlag is false', async () => { - await removePdfFromDocketEntryInteractor(applicationContext, { - docketEntryId: '1905d1ab-18d0-43ec-bafb-654e83405491', // entry with isFileAttached: false - docketNumber: MOCK_CASE.docketNumber, - }); + await removePdfFromDocketEntryInteractor( + applicationContext, + { + docketEntryId: '1905d1ab-18d0-43ec-bafb-654e83405491', // entry with isFileAttached: false + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteDocumentFile, @@ -163,10 +177,14 @@ describe('removePdfFromDocketEntryInteractor', () => { }); it('does not modify the docketEntry or case if the docketEntry can not be found on the case', async () => { - await removePdfFromDocketEntryInteractor(applicationContext, { - docketEntryId: 'nope', - docketNumber: MOCK_CASE.docketNumber, - }); + await removePdfFromDocketEntryInteractor( + applicationContext, + { + docketEntryId: 'nope', + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteDocumentFile, @@ -180,10 +198,14 @@ describe('removePdfFromDocketEntryInteractor', () => { mockLock = MOCK_LOCK; await expect( - removePdfFromDocketEntryInteractor(applicationContext, { - docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: MOCK_CASE.docketNumber, - }), + removePdfFromDocketEntryInteractor( + applicationContext, + { + docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -192,10 +214,14 @@ describe('removePdfFromDocketEntryInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await removePdfFromDocketEntryInteractor(applicationContext, { - docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: MOCK_CASE.docketNumber, - }); + await removePdfFromDocketEntryInteractor( + applicationContext, + { + docketEntryId: '7805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts b/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts index c04bd0601bc..e8347574e42 100644 --- a/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts +++ b/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts @@ -4,6 +4,7 @@ import { isAuthorized, } from '../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -17,9 +18,8 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const removePdfFromDocketEntry = async ( applicationContext, { docketEntryId, docketNumber }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPDATE_CASE)) { throw new UnauthorizedError('Unauthorized for update case'); } diff --git a/web-api/src/lambdas/documents/removePdfFromDocketEntryLambda.ts b/web-api/src/lambdas/documents/removePdfFromDocketEntryLambda.ts index cb651bdc3c3..ce27ba4538c 100644 --- a/web-api/src/lambdas/documents/removePdfFromDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/removePdfFromDocketEntryLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { removePdfFromDocketEntryInteractor } from '@shared/business/useCases/removePdfFromDocketEntryInteractor'; /** * used for removing a pdf from a docket entry @@ -6,12 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const removePdfFromDocketEntryLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .removePdfFromDocketEntryInteractor( +export const removePdfFromDocketEntryLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await removePdfFromDocketEntryInteractor( applicationContext, event.pathParameters, + authorizedUser, ); - }); + }, + authorizedUser, + ); From 87d3ac3627d305f4f2c06caa0014403d4436992d Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 13:43:12 -0700 Subject: [PATCH 083/523] 10417: Remove getCurrentUser from shared --- docs/remove-get-current-user.md | 1 + .../opinionAdvancedSearchInteractor.test.ts | 63 ++++++++++++------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index 92e4530ed09..790b2ae1f81 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -5,6 +5,7 @@ # TODO - Go back to all // TODO 10417 - Look at validateRawCollection() +- Look at all references of genericHandler to make sure authorizedUser is being passed in. # Web-Client Steps to transition getCurrentUser() in web-client diff --git a/shared/src/business/useCases/opinionAdvancedSearchInteractor.test.ts b/shared/src/business/useCases/opinionAdvancedSearchInteractor.test.ts index ec7d5021b0b..c5f7d0d9878 100644 --- a/shared/src/business/useCases/opinionAdvancedSearchInteractor.test.ts +++ b/shared/src/business/useCases/opinionAdvancedSearchInteractor.test.ts @@ -4,13 +4,14 @@ import { OPINION_EVENT_CODES_WITH_BENCH_OPINION, } from '../../business/entities/EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { opinionAdvancedSearchInteractor } from './opinionAdvancedSearchInteractor'; -import { petitionerUser, petitionsClerkUser } from '@shared/test/mockUsers'; describe('opinionAdvancedSearchInteractor', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - applicationContext .getPersistenceGateway() .advancedDocumentSearch.mockResolvedValue({ @@ -38,19 +39,25 @@ describe('opinionAdvancedSearchInteractor', () => { }); it('should return an unauthorized error when the currentUser is a petitioner', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - await expect( - opinionAdvancedSearchInteractor(applicationContext, {} as any), + opinionAdvancedSearchInteractor( + applicationContext, + {} as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should return results when the current user has permission to perform advanced opinion searches (petitionsclerk)', async () => { - const result = await opinionAdvancedSearchInteractor(applicationContext, { - dateRange: DATE_RANGE_SEARCH_OPTIONS.CUSTOM_DATES, - keyword: 'candy', - startDate: '01/01/2001', - } as any); + const result = await opinionAdvancedSearchInteractor( + applicationContext, + { + dateRange: DATE_RANGE_SEARCH_OPTIONS.CUSTOM_DATES, + keyword: 'candy', + startDate: '01/01/2001', + } as any, + mockPetitionsClerkUser, + ); expect(result).toMatchObject([ { @@ -88,10 +95,14 @@ describe('opinionAdvancedSearchInteractor', () => { .getPersistenceGateway() .advancedDocumentSearch.mockResolvedValue({ results: maxPlusOneResults }); - const results = await opinionAdvancedSearchInteractor(applicationContext, { - keyword: 'keyword', - petitionerName: 'test person', - } as any); + const results = await opinionAdvancedSearchInteractor( + applicationContext, + { + keyword: 'keyword', + petitionerName: 'test person', + } as any, + mockPetitionsClerkUser, + ); expect(results.length).toBe(MAX_SEARCH_RESULTS); }); @@ -99,12 +110,16 @@ describe('opinionAdvancedSearchInteractor', () => { it('should search for documents that are of type opinions', async () => { const keyword = 'keyword'; - await opinionAdvancedSearchInteractor(applicationContext, { - dateRange: DATE_RANGE_SEARCH_OPTIONS.CUSTOM_DATES, - keyword, - opinionTypes: OPINION_EVENT_CODES_WITH_BENCH_OPINION, - startDate: '01/01/2001', - } as any); + await opinionAdvancedSearchInteractor( + applicationContext, + { + dateRange: DATE_RANGE_SEARCH_OPTIONS.CUSTOM_DATES, + keyword, + opinionTypes: OPINION_EVENT_CODES_WITH_BENCH_OPINION, + startDate: '01/01/2001', + } as any, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().advancedDocumentSearch.mock @@ -115,7 +130,11 @@ describe('opinionAdvancedSearchInteractor', () => { }); it('should search for opinions with isOpinionSearch set to true', async () => { - await opinionAdvancedSearchInteractor(applicationContext, {} as any); + await opinionAdvancedSearchInteractor( + applicationContext, + {} as any, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().advancedDocumentSearch.mock From c714fbbd2b49837842f3abb7a26a822a9cc1c5a1 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 13:54:22 -0700 Subject: [PATCH 084/523] 10417: Remove getCurrentUser from shared --- ...titionerAndUpdateCaptionInteractor.test.ts | 142 +++++++++++------- ...ovePetitionerAndUpdateCaptionInteractor.ts | 15 +- .../saveCaseDetailInternalEditInteractor.ts | 4 +- ...removeCounselFromRemovedPetitioner.test.ts | 21 +-- .../removeCounselFromRemovedPetitioner.ts | 11 +- .../removePetitionerAndUpdateCaptionLambda.ts | 29 ++-- 6 files changed, 135 insertions(+), 87 deletions(-) diff --git a/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.test.ts b/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.test.ts index d9a91789fe0..9d56534db5a 100644 --- a/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.test.ts +++ b/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.test.ts @@ -13,13 +13,19 @@ import { } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; import { getPetitionerById } from '../entities/cases/Case'; +import { + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { removePetitionerAndUpdateCaptionInteractor } from './removePetitionerAndUpdateCaptionInteractor'; describe('removePetitionerAndUpdateCaptionInteractor', () => { let mockCase; let petitionerToRemove; - const SECONDARY_CONTACT_ID = '56387318-0092-49a3-8cc1-921b0432bd16'; let mockLock; + + const SECONDARY_CONTACT_ID = '56387318-0092-49a3-8cc1-921b0432bd16'; + beforeAll(() => { applicationContext .getPersistenceGateway() @@ -46,10 +52,6 @@ describe('removePetitionerAndUpdateCaptionInteractor', () => { petitioners: [MOCK_CASE.petitioners[0], petitionerToRemove], status: CASE_STATUS_TYPES.generalDocket, }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); applicationContext .getPersistenceGateway() @@ -61,16 +63,16 @@ describe('removePetitionerAndUpdateCaptionInteractor', () => { }); it('should throw an unauthorized error when the current user does not have permission to edit petitioners', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsClerk', - }); await expect( - removePetitionerAndUpdateCaptionInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, - contactId: '7805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: MOCK_CASE.docketNumber, - }), + removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + caseCaption: MOCK_CASE.caseCaption, + contactId: '7805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -81,11 +83,15 @@ describe('removePetitionerAndUpdateCaptionInteractor', () => { }; await expect( - removePetitionerAndUpdateCaptionInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, - contactId: SECONDARY_CONTACT_ID, - docketNumber: MOCK_CASE.docketNumber, - }), + removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + caseCaption: MOCK_CASE.caseCaption, + contactId: SECONDARY_CONTACT_ID, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow( `Case with docketNumber ${mockCase.docketNumber} has not been served`, ); @@ -99,22 +105,30 @@ describe('removePetitionerAndUpdateCaptionInteractor', () => { }; await expect( - removePetitionerAndUpdateCaptionInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, - contactId: MOCK_CASE.petitioners[0].contactId, - docketNumber: MOCK_CASE.docketNumber, - }), + removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + caseCaption: MOCK_CASE.caseCaption, + contactId: MOCK_CASE.petitioners[0].contactId, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow( `Cannot remove petitioner ${MOCK_CASE.petitioners[0].contactId} from case with docketNumber ${MOCK_CASE.docketNumber}`, ); }); it('should remove the specified petitioner form the case petitioners array', async () => { - await removePetitionerAndUpdateCaptionInteractor(applicationContext, { - caseCaption: MOCK_CASE.caseCaption, - contactId: petitionerToRemove.contactId, - docketNumber: MOCK_CASE.docketNumber, - }); + await removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + caseCaption: MOCK_CASE.caseCaption, + contactId: petitionerToRemove.contactId, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); const { caseToUpdate } = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -142,11 +156,15 @@ describe('removePetitionerAndUpdateCaptionInteractor', () => { privatePractitioners: [mockPrivatePractitioner], }; - await removePetitionerAndUpdateCaptionInteractor(applicationContext, { - caseCaption: mockCase.caseCaption, - contactId: petitionerToRemove.contactId, - docketNumber: mockCase.docketNumber, - }); + await removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + caseCaption: mockCase.caseCaption, + contactId: petitionerToRemove.contactId, + docketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); const { caseToUpdate } = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -167,11 +185,15 @@ describe('removePetitionerAndUpdateCaptionInteractor', () => { it('should update the case caption', async () => { const mockUpdatedCaption = 'An updated caption'; - await removePetitionerAndUpdateCaptionInteractor(applicationContext, { - caseCaption: mockUpdatedCaption, - contactId: MOCK_CASE.petitioners[0].contactId, - docketNumber: mockCase.docketNumber, - }); + await removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + caseCaption: mockUpdatedCaption, + contactId: MOCK_CASE.petitioners[0].contactId, + docketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -209,11 +231,15 @@ describe('removePetitionerAndUpdateCaptionInteractor', () => { }, ]; - await removePetitionerAndUpdateCaptionInteractor(applicationContext, { - caseCaption: 'hello world', - contactId: MOCK_CASE.petitioners[0].contactId, - docketNumber: mockCase.docketNumber, - }); + await removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + caseCaption: 'hello world', + contactId: MOCK_CASE.petitioners[0].contactId, + docketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -224,11 +250,15 @@ describe('removePetitionerAndUpdateCaptionInteractor', () => { mockLock = MOCK_LOCK; await expect( - removePetitionerAndUpdateCaptionInteractor(applicationContext, { - caseCaption: 'some caption', - contactId: MOCK_CASE.petitioners[0].contactId, - docketNumber: mockCase.docketNumber, - }), + removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + caseCaption: 'some caption', + contactId: MOCK_CASE.petitioners[0].contactId, + docketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -237,11 +267,15 @@ describe('removePetitionerAndUpdateCaptionInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await removePetitionerAndUpdateCaptionInteractor(applicationContext, { - caseCaption: 'some caption', - contactId: MOCK_CASE.petitioners[0].contactId, - docketNumber: mockCase.docketNumber, - }); + await removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + caseCaption: 'some caption', + contactId: MOCK_CASE.petitioners[0].contactId, + docketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts b/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts index 91e5614389a..e4bf148565a 100644 --- a/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts +++ b/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts @@ -4,7 +4,9 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -17,17 +19,17 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the case data */ export const removePetitionerAndUpdateCaption = async ( - applicationContext: IApplicationContext, + applicationContext: ServerApplicationContext, { caseCaption, contactId, docketNumber, }: { caseCaption: string; contactId: string; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { const petitionerContactId = contactId; - const user = applicationContext.getCurrentUser(); - if (!isAuthorized(user, ROLE_PERMISSIONS.REMOVE_PETITIONER)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.REMOVE_PETITIONER)) { throw new UnauthorizedError( 'Unauthorized for removing petitioner from case', ); @@ -37,7 +39,7 @@ export const removePetitionerAndUpdateCaption = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - let caseEntity = new Case(caseToUpdate, { authorizedUser: user }); + let caseEntity = new Case(caseToUpdate, { authorizedUser }); if (caseToUpdate.status === CASE_STATUS_TYPES.new) { throw new Error( @@ -55,6 +57,7 @@ export const removePetitionerAndUpdateCaption = async ( .getUseCaseHelpers() .removeCounselFromRemovedPetitioner({ applicationContext, + authorizedUser, caseEntity, petitionerContactId, }); @@ -76,9 +79,7 @@ export const removePetitionerAndUpdateCaption = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const removePetitionerAndUpdateCaptionInteractor = withLocking( diff --git a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts index b02b5b20ab8..379d11b74f3 100644 --- a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts +++ b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts @@ -4,6 +4,7 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError, UnprocessableEntityError, @@ -21,7 +22,7 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the updated case data */ export const saveCaseDetailInternalEdit = async ( - applicationContext, + applicationContext: ServerApplicationContext, { caseToUpdate, docketNumber }, ) => { const authorizedUser = applicationContext.getCurrentUser(); @@ -119,6 +120,7 @@ export const saveCaseDetailInternalEdit = async ( .getUseCaseHelpers() .removeCounselFromRemovedPetitioner({ applicationContext, + authorizedUser, caseEntity: caseEntityWithFormEdits, petitionerContactId: originalSecondaryContactId, }); diff --git a/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts index 6e844654f56..36dec6917b7 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts @@ -1,14 +1,10 @@ import { CONTACT_TYPES, PARTY_TYPES, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; -import { - MOCK_PRACTITIONER, - petitionsClerkUser, -} from '../../../../../shared/src/test/mockUsers'; +import { MOCK_PRACTITIONER } from '../../../../../shared/src/test/mockUsers'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { mockPetitionerUser, @@ -22,19 +18,14 @@ describe('removeCounselFromRemovedPetitioner', () => { const mockSecondPractitionerUserId = '5dde0389-6e09-4e2f-a7f4-34e4f2a534a8'; const mockThirdPractitionerUserId = '0bd63272-781f-4cbd-8b7d-7cb649ca255d'; - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - }); - it('throws an unauthorized error if user does not have correct permissions', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - }); - await expect( removeCounselFromRemovedPetitioner({ applicationContext, - caseEntity: new Case(MOCK_CASE, { authorizedUser: mockPetitionerUser }), + authorizedUser: mockPetitionerUser, + caseEntity: new Case(MOCK_CASE, { + authorizedUser: mockPetitionerUser, + }), petitionerContactId: mockContactPrimaryId, }), ).rejects.toThrow('Unauthorized'); @@ -65,6 +56,7 @@ describe('removeCounselFromRemovedPetitioner', () => { const updatedCase = await removeCounselFromRemovedPetitioner({ applicationContext, + authorizedUser: mockPetitionsClerkUser, caseEntity, petitionerContactId: mockContactSecondaryId, }); @@ -108,6 +100,7 @@ describe('removeCounselFromRemovedPetitioner', () => { const updatedCase = await removeCounselFromRemovedPetitioner({ applicationContext, + authorizedUser: mockPetitionsClerkUser, caseEntity, petitionerContactId: mockContactSecondaryId, }); diff --git a/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.ts b/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.ts index d7f6a4205e7..80dfc007add 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.ts @@ -1,8 +1,11 @@ +import { Case } from '@shared/business/entities/cases/Case'; import { ROLE_PERMISSIONS, isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * removeCounselFromRemovedPetitioner * @@ -14,11 +17,15 @@ import { UnauthorizedError } from '@web-api/errors/errors'; */ export const removeCounselFromRemovedPetitioner = async ({ applicationContext, + authorizedUser, caseEntity, petitionerContactId, +}: { + applicationContext: ServerApplicationContext; + caseEntity: Case; + petitionerContactId: string; + authorizedUser: UnknownAuthUser; }) => { - const authorizedUser = applicationContext.getCurrentUser(); - if ( !isAuthorized(authorizedUser, ROLE_PERMISSIONS.QC_PETITION) && !isAuthorized(authorizedUser, ROLE_PERMISSIONS.REMOVE_PETITIONER) diff --git a/web-api/src/lambdas/cases/removePetitionerAndUpdateCaptionLambda.ts b/web-api/src/lambdas/cases/removePetitionerAndUpdateCaptionLambda.ts index 5e9d729661a..990c15bf182 100644 --- a/web-api/src/lambdas/cases/removePetitionerAndUpdateCaptionLambda.ts +++ b/web-api/src/lambdas/cases/removePetitionerAndUpdateCaptionLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { removePetitionerAndUpdateCaptionInteractor } from '@shared/business/useCases/removePetitionerAndUpdateCaptionInteractor'; /** * lambda which is used for removing a petitioner from a case @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const removePetitionerAndUpdateCaptionLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .removePetitionerAndUpdateCaptionInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const removePetitionerAndUpdateCaptionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 6c0200937421d0c6215b4d2a0b772aac8bfd67de Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 13:56:15 -0700 Subject: [PATCH 085/523] 10417: Remove getCurrentUser from shared --- .../orderAdvancedSearchInteractor.test.ts | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/shared/src/business/useCases/orderAdvancedSearchInteractor.test.ts b/shared/src/business/useCases/orderAdvancedSearchInteractor.test.ts index b2feb14599b..5a651620e21 100644 --- a/shared/src/business/useCases/orderAdvancedSearchInteractor.test.ts +++ b/shared/src/business/useCases/orderAdvancedSearchInteractor.test.ts @@ -5,13 +5,14 @@ import { ROLES, } from '../entities/EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { orderAdvancedSearchInteractor } from './orderAdvancedSearchInteractor'; -import { petitionerUser, petitionsClerkUser } from '@shared/test/mockUsers'; describe('orderAdvancedSearchInteractor', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - applicationContext .getPersistenceGateway() .advancedDocumentSearch.mockResolvedValue({ @@ -43,19 +44,25 @@ describe('orderAdvancedSearchInteractor', () => { }); it('returns an unauthorized error on petitioner user role', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - await expect( - orderAdvancedSearchInteractor(applicationContext, {} as any), + orderAdvancedSearchInteractor( + applicationContext, + {} as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('logs raw search information and results size', async () => { - const result = await orderAdvancedSearchInteractor(applicationContext, { - dateRange: DATE_RANGE_SEARCH_OPTIONS.CUSTOM_DATES, - keyword: 'candy', - startDate: '01/01/2001', - } as any); + const result = await orderAdvancedSearchInteractor( + applicationContext, + { + dateRange: DATE_RANGE_SEARCH_OPTIONS.CUSTOM_DATES, + keyword: 'candy', + startDate: '01/01/2001', + } as any, + mockPetitionsClerkUser, + ); expect(applicationContext.logger.info.mock.calls[0][1]).toMatchObject({ from: 0, @@ -79,10 +86,14 @@ describe('orderAdvancedSearchInteractor', () => { .getPersistenceGateway() .advancedDocumentSearch.mockResolvedValue({ results: maxPlusOneResults }); - const results = await orderAdvancedSearchInteractor(applicationContext, { - keyword: 'keyword', - petitionerName: 'test person', - } as any); + const results = await orderAdvancedSearchInteractor( + applicationContext, + { + keyword: 'keyword', + petitionerName: 'test person', + } as any, + mockPetitionsClerkUser, + ); expect(results.length).toBe(MAX_SEARCH_RESULTS); }); @@ -90,11 +101,15 @@ describe('orderAdvancedSearchInteractor', () => { it('searches for documents that are of type orders', async () => { const keyword = 'keyword'; - await orderAdvancedSearchInteractor(applicationContext, { - dateRange: DATE_RANGE_SEARCH_OPTIONS.CUSTOM_DATES, - keyword, - startDate: '01/01/2001', - } as any); + await orderAdvancedSearchInteractor( + applicationContext, + { + dateRange: DATE_RANGE_SEARCH_OPTIONS.CUSTOM_DATES, + keyword, + startDate: '01/01/2001', + } as any, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().advancedDocumentSearch.mock From 0c12111c6364e10045329729a1acecd902c485df Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 13:58:14 -0700 Subject: [PATCH 086/523] 10417: Remove getCurrentUser from shared --- .../useCases/prioritizeCaseInteractor.test.ts | 119 +++++++++++------- 1 file changed, 77 insertions(+), 42 deletions(-) diff --git a/shared/src/business/useCases/prioritizeCaseInteractor.test.ts b/shared/src/business/useCases/prioritizeCaseInteractor.test.ts index 89fa74e6c71..1e68e7e4453 100644 --- a/shared/src/business/useCases/prioritizeCaseInteractor.test.ts +++ b/shared/src/business/useCases/prioritizeCaseInteractor.test.ts @@ -1,8 +1,12 @@ -import { CASE_STATUS_TYPES, ROLES } from '../entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; import { MOCK_LOCK } from '../../test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { prioritizeCaseInteractor } from './prioritizeCaseInteractor'; describe('prioritizeCaseInteractor', () => { @@ -16,10 +20,6 @@ describe('prioritizeCaseInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); }); it('should update the case with the highPriority flag set as true and attach a reason', async () => { @@ -32,10 +32,14 @@ describe('prioritizeCaseInteractor', () => { }), ); - const result = await prioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }); + const result = await prioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ); expect(result).toMatchObject({ highPriority: true, @@ -61,10 +65,14 @@ describe('prioritizeCaseInteractor', () => { }), ); - await prioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }); + await prioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -73,12 +81,14 @@ describe('prioritizeCaseInteractor', () => { }); it('should throw an unauthorized error if the user has no access to prioritize cases', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - prioritizeCaseInteractor(applicationContext, { - docketNumber: '123-20', - } as any), + prioritizeCaseInteractor( + applicationContext, + { + docketNumber: '123-20', + } as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -93,10 +103,14 @@ describe('prioritizeCaseInteractor', () => { ); await expect( - prioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }), + prioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Cannot set a calendared case as high priority'); }); @@ -113,10 +127,14 @@ describe('prioritizeCaseInteractor', () => { ); await expect( - prioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }), + prioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Cannot set a blocked case as high priority'); }); @@ -130,10 +148,15 @@ describe('prioritizeCaseInteractor', () => { }), ); - await prioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }); + await prioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ); + expect( applicationContext.getPersistenceGateway() .createCaseTrialSortMappingRecords, @@ -153,10 +176,14 @@ describe('prioritizeCaseInteractor', () => { }), ); - await prioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }); + await prioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -168,10 +195,14 @@ describe('prioritizeCaseInteractor', () => { mockLock = MOCK_LOCK; await expect( - prioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }), + prioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -180,10 +211,14 @@ describe('prioritizeCaseInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await prioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - reason: 'just because', - }); + await prioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + reason: 'just because', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, From 2aef221076b5035a1b3cb14f8d6498a8b167c993 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:02:45 -0700 Subject: [PATCH 087/523] 10417: Remove getCurrentUser from shared --- ...oveSignatureFromDocumentInteractor.test.ts | 26 +++++++++++++------ .../removeSignatureFromDocumentInteractor.ts | 7 +++-- .../removeSignatureFromDocumentLambda.ts | 20 +++++++++----- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.test.ts b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.test.ts index 9f8d7bd6ebe..8578f445b65 100644 --- a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.test.ts +++ b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.test.ts @@ -1,6 +1,7 @@ import { MOCK_CASE } from '../../test/mockCase'; import { ROLES } from '../entities/EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { removeSignatureFromDocumentInteractor } from './removeSignatureFromDocumentInteractor'; describe('removeSignatureFromDocumentInteractor', () => { @@ -36,10 +37,14 @@ describe('removeSignatureFromDocumentInteractor', () => { }); it('should retrieve the original, unsigned document from S3', async () => { - await removeSignatureFromDocumentInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: mockCase.docketNumber, - }); + await removeSignatureFromDocumentInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDocument.mock.calls[0][0], @@ -50,10 +55,14 @@ describe('removeSignatureFromDocumentInteractor', () => { }); it('should overwrite the current, signed document in S3 with the original, unsigned document', async () => { - await removeSignatureFromDocumentInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: mockCase.docketNumber, - }); + await removeSignatureFromDocumentInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda.mock @@ -70,6 +79,7 @@ describe('removeSignatureFromDocumentInteractor', () => { docketEntryId: mockDocketEntryId, docketNumber: mockCase.docketNumber, }, + mockDocketClerkUser, ); const unsignedDocument = updatedCase.docketEntries.find( diff --git a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts index 388b1e6c4a3..704544cd897 100644 --- a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts +++ b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts @@ -1,4 +1,6 @@ import { Case } from '../entities/cases/Case'; +import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * Removes a signature from a document @@ -10,8 +12,9 @@ import { Case } from '../entities/cases/Case'; * @returns {object} the updated case */ export const removeSignatureFromDocumentInteractor = async ( - applicationContext, + applicationContext: ServerApplicationContext, { docketEntryId, docketNumber }, + authorizedUser: UnknownAuthUser, ) => { const caseRecord = await applicationContext .getPersistenceGateway() @@ -20,7 +23,7 @@ export const removeSignatureFromDocumentInteractor = async ( docketNumber, }); const caseEntity = new Case(caseRecord, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const docketEntryToUnsign = caseEntity.getDocketEntryById({ docketEntryId, diff --git a/web-api/src/lambdas/documents/removeSignatureFromDocumentLambda.ts b/web-api/src/lambdas/documents/removeSignatureFromDocumentLambda.ts index e1f6dae628c..1b3e988c022 100644 --- a/web-api/src/lambdas/documents/removeSignatureFromDocumentLambda.ts +++ b/web-api/src/lambdas/documents/removeSignatureFromDocumentLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { removeSignatureFromDocumentInteractor } from '@shared/business/useCases/removeSignatureFromDocumentInteractor'; /** * used for removing signature from a signed document @@ -6,12 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const removeSignatureFromDocumentLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .removeSignatureFromDocumentInteractor( +export const removeSignatureFromDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await removeSignatureFromDocumentInteractor( applicationContext, event.pathParameters, + authorizedUser, ); - }); + }, + authorizedUser, + ); From b62a64fb4f4763c394bdb3a588dd73e2d9369aa4 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:07:20 -0700 Subject: [PATCH 088/523] 10417: Remove getCurrentUser from shared --- ...veCaseDetailInternalEditInteractor.test.ts | 175 +++++++++++------- .../saveCaseDetailInternalEditInteractor.ts | 4 +- .../cases/saveCaseDetailInternalEditLambda.ts | 31 +++- 3 files changed, 131 insertions(+), 79 deletions(-) diff --git a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.test.ts b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.test.ts index f4805290929..2fc95e6772e 100644 --- a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.test.ts +++ b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.test.ts @@ -10,6 +10,10 @@ import { MOCK_PRACTITIONER, petitionsClerkUser } from '../../test/mockUsers'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; import { getContactPrimary, getContactSecondary } from '../entities/cases/Case'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; import { saveCaseDetailInternalEditInteractor } from './saveCaseDetailInternalEditInteractor'; @@ -54,10 +58,10 @@ describe('updateCase', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - applicationContext - .getPersistenceGateway() - .getUserById.mockReturnValue(petitionsClerkUser); + applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ + ...petitionsClerkUser, + userId: mockPetitionsClerkUser.userId, + }); applicationContext .getPersistenceGateway() @@ -66,32 +70,39 @@ describe('updateCase', () => { it('should throw an error if caseToUpdate is not passed in', async () => { await expect( - saveCaseDetailInternalEditInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - } as any), + saveCaseDetailInternalEditInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + } as any, + mockPetitionsClerkUser, + ), ).rejects.toThrow('cannot process'); }); it('should throw an error if the user is unauthorized to update a case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: 'nope', - userId: 'nope', - }); - await expect( - saveCaseDetailInternalEditInteractor(applicationContext, { - caseToUpdate: mockCase, - docketNumber: mockCase.docketNumber, - }), + saveCaseDetailInternalEditInteractor( + applicationContext, + { + caseToUpdate: mockCase, + docketNumber: mockCase.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for update case'); }); it('should throw an error if the caseToUpdate passed in is an invalid case', async () => { await expect( - saveCaseDetailInternalEditInteractor(applicationContext, { - caseToUpdate: omit({ ...mockCase }, 'caseCaption'), - docketNumber: mockCase.docketNumber, - }), + saveCaseDetailInternalEditInteractor( + applicationContext, + { + caseToUpdate: omit({ ...mockCase }, 'caseCaption'), + docketNumber: mockCase.docketNumber, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('The Case entity was invalid'); }); @@ -112,6 +123,7 @@ describe('updateCase', () => { }, docketNumber: mockCase.docketNumber, }, + mockPetitionsClerkUser, ); expect(result.petitioners[1].address1).toEqual(mockAddress); @@ -120,14 +132,18 @@ describe('updateCase', () => { it("should move the initialize case work item into the current user's in-progress box if the case is not paper", async () => { const caseToUpdate = Object.assign(mockCase); - await saveCaseDetailInternalEditInteractor(applicationContext, { - caseToUpdate: { - ...caseToUpdate, - caseCaption: 'Iola Snow & Linda Singleton, Petitioners', - contactPrimary: getContactPrimary(mockCase), + await saveCaseDetailInternalEditInteractor( + applicationContext, + { + caseToUpdate: { + ...caseToUpdate, + caseCaption: 'Iola Snow & Linda Singleton, Petitioners', + contactPrimary: getContactPrimary(mockCase), + }, + docketNumber: caseToUpdate.docketNumber, }, - docketNumber: caseToUpdate.docketNumber, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem, @@ -136,7 +152,7 @@ describe('updateCase', () => { applicationContext.getPersistenceGateway().saveWorkItem.mock.calls[0][0] .workItem, ).toMatchObject({ - assigneeId: petitionsClerkUser.userId, + assigneeId: mockPetitionsClerkUser.userId, assigneeName: petitionsClerkUser.name, caseIsInProgress: true, }); @@ -147,14 +163,18 @@ describe('updateCase', () => { caseToUpdate.isPaper = true; caseToUpdate.mailingDate = 'yesterday'; - await saveCaseDetailInternalEditInteractor(applicationContext, { - caseToUpdate: { - ...caseToUpdate, - caseCaption: 'Iola Snow & Linda Singleton, Petitioners', - contactPrimary: getContactPrimary(mockCase), + await saveCaseDetailInternalEditInteractor( + applicationContext, + { + caseToUpdate: { + ...caseToUpdate, + caseCaption: 'Iola Snow & Linda Singleton, Petitioners', + contactPrimary: getContactPrimary(mockCase), + }, + docketNumber: caseToUpdate.docketNumber, }, - docketNumber: caseToUpdate.docketNumber, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem, @@ -165,14 +185,18 @@ describe('updateCase', () => { const caseToUpdate = Object.assign(mockCase); await expect( - saveCaseDetailInternalEditInteractor(applicationContext, { - caseToUpdate: { - ...caseToUpdate, - contactPrimary: null, - contactSecondary: {}, + saveCaseDetailInternalEditInteractor( + applicationContext, + { + caseToUpdate: { + ...caseToUpdate, + contactPrimary: null, + contactSecondary: {}, + }, + docketNumber: caseToUpdate.docketNumber, }, - docketNumber: caseToUpdate.docketNumber, - }), + mockPetitionsClerkUser, + ), ).rejects.toThrow('The Case entity was invalid'); }); @@ -195,16 +219,20 @@ describe('updateCase', () => { isPaper: true, }); - await saveCaseDetailInternalEditInteractor(applicationContext, { - caseToUpdate: { - ...mockCase, - contactPrimary: getContactPrimary(mockCase), - docketEntries: [...mockCase.docketEntries, mockRQT], - isPaper: true, - mailingDate: 'yesterday', + await saveCaseDetailInternalEditInteractor( + applicationContext, + { + caseToUpdate: { + ...mockCase, + contactPrimary: getContactPrimary(mockCase), + docketEntries: [...mockCase.docketEntries, mockRQT], + isPaper: true, + mailingDate: 'yesterday', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().updateInitialFilingDocuments, @@ -231,6 +259,7 @@ describe('updateCase', () => { }, docketNumber: caseToUpdate.docketNumber, }, + mockPetitionsClerkUser, ); expect(result.orderDesignatingPlaceOfTrial).toBeTruthy(); @@ -255,6 +284,7 @@ describe('updateCase', () => { }, docketNumber: mockCase.docketNumber, }, + mockPetitionsClerkUser, ); expect(result.petitioners[0].contactId).toEqual( @@ -277,6 +307,7 @@ describe('updateCase', () => { }, docketNumber: mockCase.docketNumber, }, + mockPetitionsClerkUser, ); expect(result.petitioners.length).toEqual(1); @@ -317,6 +348,7 @@ describe('updateCase', () => { }, docketNumber: mockCase.docketNumber, }, + mockPetitionsClerkUser, ); expect(result.privatePractitioners).toBeDefined(); @@ -348,6 +380,7 @@ describe('updateCase', () => { }, docketNumber: mockCase.docketNumber, }, + mockPetitionsClerkUser, ); expect(result.receivedAt).toEqual(currentCaseDetail.receivedAt); @@ -356,16 +389,20 @@ describe('updateCase', () => { mockLock = MOCK_LOCK; await expect( - saveCaseDetailInternalEditInteractor(applicationContext, { - caseToUpdate: { - ...mockCase, - contactPrimary: { - ...getContactPrimary(mockCase), + saveCaseDetailInternalEditInteractor( + applicationContext, + { + caseToUpdate: { + ...mockCase, + contactPrimary: { + ...getContactPrimary(mockCase), + }, + petitioners: undefined, }, - petitioners: undefined, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }), + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -374,16 +411,20 @@ describe('updateCase', () => { }); it('should acquire and remove the lock on the case', async () => { - await saveCaseDetailInternalEditInteractor(applicationContext, { - caseToUpdate: { - ...mockCase, - contactPrimary: { - ...getContactPrimary(mockCase), + await saveCaseDetailInternalEditInteractor( + applicationContext, + { + caseToUpdate: { + ...mockCase, + contactPrimary: { + ...getContactPrimary(mockCase), + }, + petitioners: undefined, }, - petitioners: undefined, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts index 379d11b74f3..087b3ce8a21 100644 --- a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts +++ b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts @@ -9,6 +9,7 @@ import { UnauthorizedError, UnprocessableEntityError, } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../entities/WorkItem'; import { isEmpty } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -24,9 +25,8 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const saveCaseDetailInternalEdit = async ( applicationContext: ServerApplicationContext, { caseToUpdate, docketNumber }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPDATE_CASE)) { throw new UnauthorizedError('Unauthorized for update case'); } diff --git a/web-api/src/lambdas/cases/saveCaseDetailInternalEditLambda.ts b/web-api/src/lambdas/cases/saveCaseDetailInternalEditLambda.ts index bfb72dacb00..75b8f0b3995 100644 --- a/web-api/src/lambdas/cases/saveCaseDetailInternalEditLambda.ts +++ b/web-api/src/lambdas/cases/saveCaseDetailInternalEditLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { saveCaseDetailInternalEditInteractor } from '@shared/business/useCases/saveCaseDetailInternalEditInteractor'; /** * used for updating a case @@ -6,13 +8,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const saveCaseDetailInternalEditLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .saveCaseDetailInternalEditInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - caseToUpdate: JSON.parse(event.body), - }); - }); +export const saveCaseDetailInternalEditLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await saveCaseDetailInternalEditInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + caseToUpdate: JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From a3d080b2f07984d8ed9ac60cd61aec719208867f Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:10:17 -0700 Subject: [PATCH 089/523] 10417: Remove getCurrentUser from shared --- .../saveSignedDocumentInteractor.test.ts | 54 ++++++++++++------- .../useCases/saveSignedDocumentInteractor.ts | 17 +++--- .../documents/saveSignedDocumentLambda.ts | 39 +++++++++----- 3 files changed, 69 insertions(+), 41 deletions(-) diff --git a/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts b/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts index 021ed76722c..b00828dbaaf 100644 --- a/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts +++ b/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts @@ -6,6 +6,7 @@ import { import { MOCK_CASE } from '../../test/mockCase'; import { MOCK_DOCUMENTS } from '../../test/mockDocketEntry'; import { applicationContext } from '../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { saveSignedDocumentInteractor } from './saveSignedDocumentInteractor'; describe('saveSignedDocumentInteractor', () => { @@ -55,12 +56,16 @@ describe('saveSignedDocumentInteractor', () => { }); it('should save the original, unsigned document to S3 with a new id', async () => { - await saveSignedDocumentInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - nameForSigning: mockSigningName, - originalDocketEntryId: mockOriginalDocketEntryId, - signedDocketEntryId: mockSignedDocketEntryId, - } as any); + await saveSignedDocumentInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + nameForSigning: mockSigningName, + originalDocketEntryId: mockOriginalDocketEntryId, + signedDocketEntryId: mockSignedDocketEntryId, + } as any, + mockDocketClerkUser, + ); expect(applicationContext.getUniqueId).toHaveBeenCalled(); expect( @@ -72,12 +77,16 @@ describe('saveSignedDocumentInteractor', () => { }); it('should replace the original, unsigned document with the signed document', async () => { - await saveSignedDocumentInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - nameForSigning: mockSigningName, - originalDocketEntryId: mockOriginalDocketEntryId, - signedDocketEntryId: mockSignedDocketEntryId, - } as any); + await saveSignedDocumentInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + nameForSigning: mockSigningName, + originalDocketEntryId: mockOriginalDocketEntryId, + signedDocketEntryId: mockSignedDocketEntryId, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda.mock @@ -96,6 +105,7 @@ describe('saveSignedDocumentInteractor', () => { originalDocketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', signedDocketEntryId: mockSignedDocketEntryId, } as any, + mockDocketClerkUser, ); expect(caseEntity.docketEntries.length).toEqual(MOCK_DOCUMENTS.length + 1); @@ -130,6 +140,7 @@ describe('saveSignedDocumentInteractor', () => { originalDocketEntryId: mockOriginalDocketEntryId, signedDocketEntryId: mockSignedDocketEntryId, } as any, + mockDocketClerkUser, ); const signedDocument = caseEntity.docketEntries.find( @@ -149,6 +160,7 @@ describe('saveSignedDocumentInteractor', () => { originalDocketEntryId: mockOriginalDocketEntryId, signedDocketEntryId: mockSignedDocketEntryId, } as any, + mockDocketClerkUser, ); const signedDocument = caseEntity.docketEntries.find( @@ -160,13 +172,17 @@ describe('saveSignedDocumentInteractor', () => { }); it('should add the signed document to the latest message in the message thread if parentMessageId is included and the original document is a Proposed Stipulated Decision', async () => { - await saveSignedDocumentInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - nameForSigning: mockSigningName, - originalDocketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', - parentMessageId: mockParentMessageId, - signedDocketEntryId: mockSignedDocketEntryId, - }); + await saveSignedDocumentInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + nameForSigning: mockSigningName, + originalDocketEntryId: 'def81f4d-1e47-423a-8caf-6d2fdc3d3859', + parentMessageId: mockParentMessageId, + signedDocketEntryId: mockSignedDocketEntryId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateMessage, diff --git a/shared/src/business/useCases/saveSignedDocumentInteractor.ts b/shared/src/business/useCases/saveSignedDocumentInteractor.ts index 140eb2655c1..4b4cc7c2b41 100644 --- a/shared/src/business/useCases/saveSignedDocumentInteractor.ts +++ b/shared/src/business/useCases/saveSignedDocumentInteractor.ts @@ -5,6 +5,7 @@ import { } from '../entities/EntityConstants'; import { DocketEntry } from '../entities/DocketEntry'; import { Message } from '../entities/Message'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { orderBy } from 'lodash'; const saveOriginalDocumentWithNewId = async ({ @@ -70,15 +71,15 @@ export const saveSignedDocumentInteractor = async ( parentMessageId, signedDocketEntryId, }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); const caseRecord = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber, }); - const caseEntity = new Case(caseRecord, { authorizedUser: user }); + const caseEntity = new Case(caseRecord, { authorizedUser }); const originalDocketEntryEntity = caseEntity.docketEntries.find( docketEntry => docketEntry.docketEntryId === originalDocketEntryId, ); @@ -103,12 +104,12 @@ export const saveSignedDocumentInteractor = async ( isPaper: false, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { authorizedUser: user }, + { authorizedUser }, ); - signedDocketEntryEntity.setFiledBy(user); + signedDocketEntryEntity.setFiledBy(authorizedUser); - signedDocketEntryEntity.setSigned(user.userId, nameForSigning); + signedDocketEntryEntity.setSigned(authorizedUser?.userId, nameForSigning); caseEntity.addDocketEntry(signedDocketEntryEntity); @@ -155,12 +156,12 @@ export const saveSignedDocumentInteractor = async ( isFileAttached: true, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { authorizedUser: user }, + { authorizedUser }, ); - signedDocketEntryEntity.setFiledBy(user); + signedDocketEntryEntity.setFiledBy(authorizedUser); - signedDocketEntryEntity.setSigned(user.userId, nameForSigning); + signedDocketEntryEntity.setSigned(authorizedUser?.userId, nameForSigning); caseEntity.updateDocketEntry(signedDocketEntryEntity); } diff --git a/web-api/src/lambdas/documents/saveSignedDocumentLambda.ts b/web-api/src/lambdas/documents/saveSignedDocumentLambda.ts index 98a52775619..8d1176d35ba 100644 --- a/web-api/src/lambdas/documents/saveSignedDocumentLambda.ts +++ b/web-api/src/lambdas/documents/saveSignedDocumentLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { saveSignedDocumentInteractor } from '@shared/business/useCases/saveSignedDocumentInteractor'; /** * used for signing PDF documents @@ -6,18 +8,27 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const saveSignedDocumentLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { - body, - pathParameters: { docketEntryId: originalDocketEntryId, docketNumber }, - } = event; +export const saveSignedDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { + body, + pathParameters: { docketEntryId: originalDocketEntryId, docketNumber }, + } = event; - return await applicationContext - .getUseCases() - .saveSignedDocumentInteractor(applicationContext, { - ...JSON.parse(body), - docketNumber, - originalDocketEntryId, - }); - }); + return await saveSignedDocumentInteractor( + applicationContext, + { + ...JSON.parse(body), + docketNumber, + originalDocketEntryId, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 246912e23857efb8e1076aa4a27133b56831f5e7 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:13:43 -0700 Subject: [PATCH 090/523] 10417: Remove getCurrentUser from shared --- .../sealCaseContactAddressInteractor.test.ts | 124 ++++++++++-------- .../sealCaseContactAddressInteractor.ts | 7 +- .../cases/sealCaseContactAddressLambda.ts | 27 ++-- 3 files changed, 91 insertions(+), 67 deletions(-) diff --git a/shared/src/business/useCases/sealCaseContactAddressInteractor.test.ts b/shared/src/business/useCases/sealCaseContactAddressInteractor.test.ts index c00f55758f2..138186f94c5 100644 --- a/shared/src/business/useCases/sealCaseContactAddressInteractor.test.ts +++ b/shared/src/business/useCases/sealCaseContactAddressInteractor.test.ts @@ -3,10 +3,13 @@ import { MOCK_CASE_WITH_SECONDARY_OTHERS, } from '../../test/mockCase'; import { MOCK_LOCK } from '../../test/mockLock'; -import { ROLES } from '../entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; import { getOtherFilers } from '../entities/cases/Case'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { sealCaseContactAddressInteractor } from './sealCaseContactAddressInteractor'; describe('sealCaseContactAddressInteractor', () => { @@ -22,31 +25,31 @@ describe('sealCaseContactAddressInteractor', () => { applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); }); it('should throw an error if the user is unauthorized to seal a case contact address', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'docketClerk', - }); await expect( - sealCaseContactAddressInteractor(applicationContext, { - contactId: '10aa100f-0330-442b-8423-b01690c76e3f', - docketNumber: MOCK_CASE.docketNumber, - }), + sealCaseContactAddressInteractor( + applicationContext, + { + contactId: '10aa100f-0330-442b-8423-b01690c76e3f', + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for sealing case contact addresses'); }); it('should throw an error if the contactId is not found on the case', async () => { await expect( - sealCaseContactAddressInteractor(applicationContext, { - contactId: '23-skidoo', - docketNumber: MOCK_CASE.docketNumber, - }), + sealCaseContactAddressInteractor( + applicationContext, + { + contactId: '23-skidoo', + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Cannot seal contact'); }); @@ -61,24 +64,27 @@ describe('sealCaseContactAddressInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(caseWithoutOthers); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); - await expect( - sealCaseContactAddressInteractor(applicationContext, { - contactId: '23-skidoo', - docketNumber: MOCK_CASE.docketNumber, - }), + sealCaseContactAddressInteractor( + applicationContext, + { + contactId: '23-skidoo', + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Cannot seal contact'); }); it('should call updateCase with `isSealedAddress` on contactPrimary and return the updated case', async () => { - const result = await sealCaseContactAddressInteractor(applicationContext, { - contactId: '7805d1ab-18d0-43ec-bafb-654e83405416', // contactPrimary - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await sealCaseContactAddressInteractor( + applicationContext, + { + contactId: '7805d1ab-18d0-43ec-bafb-654e83405416', // contactPrimary + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -91,15 +97,14 @@ describe('sealCaseContactAddressInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE_WITH_SECONDARY_OTHERS); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); - - const result = await sealCaseContactAddressInteractor(applicationContext, { - contactId: '2226050f-a423-47bb-943b-a5661fe08a6b', // contactSecondary - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await sealCaseContactAddressInteractor( + applicationContext, + { + contactId: '2226050f-a423-47bb-943b-a5661fe08a6b', // contactSecondary + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -112,15 +117,14 @@ describe('sealCaseContactAddressInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE_WITH_SECONDARY_OTHERS); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); - - const result = await sealCaseContactAddressInteractor(applicationContext, { - contactId: '4446050f-a423-47bb-943b-a5661fe08a6b', // otherFilers[1] - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await sealCaseContactAddressInteractor( + applicationContext, + { + contactId: '4446050f-a423-47bb-943b-a5661fe08a6b', // otherFilers[1] + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -132,10 +136,14 @@ describe('sealCaseContactAddressInteractor', () => { mockLock = MOCK_LOCK; await expect( - sealCaseContactAddressInteractor(applicationContext, { - contactId: '7805d1ab-18d0-43ec-bafb-654e83405416', // contactPrimary - docketNumber: MOCK_CASE.docketNumber, - }), + sealCaseContactAddressInteractor( + applicationContext, + { + contactId: '7805d1ab-18d0-43ec-bafb-654e83405416', // contactPrimary + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -144,10 +152,14 @@ describe('sealCaseContactAddressInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await sealCaseContactAddressInteractor(applicationContext, { - contactId: '7805d1ab-18d0-43ec-bafb-654e83405416', // contactPrimary - docketNumber: MOCK_CASE.docketNumber, - }); + await sealCaseContactAddressInteractor( + applicationContext, + { + contactId: '7805d1ab-18d0-43ec-bafb-654e83405416', // contactPrimary + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/sealCaseContactAddressInteractor.ts b/shared/src/business/useCases/sealCaseContactAddressInteractor.ts index 2ccbec9b6fa..aaab5548f2e 100644 --- a/shared/src/business/useCases/sealCaseContactAddressInteractor.ts +++ b/shared/src/business/useCases/sealCaseContactAddressInteractor.ts @@ -3,10 +3,12 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError, UnprocessableEntityError, } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -18,11 +20,10 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the updated case data */ export const sealCaseContactAddress = async ( - applicationContext, + applicationContext: ServerApplicationContext, { contactId, docketNumber }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPDATE_CASE)) { throw new UnauthorizedError( 'Unauthorized for sealing case contact addresses', diff --git a/web-api/src/lambdas/cases/sealCaseContactAddressLambda.ts b/web-api/src/lambdas/cases/sealCaseContactAddressLambda.ts index 3144fcdb0a4..95613d04a0e 100644 --- a/web-api/src/lambdas/cases/sealCaseContactAddressLambda.ts +++ b/web-api/src/lambdas/cases/sealCaseContactAddressLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { sealCaseContactAddressInteractor } from '@shared/business/useCases/sealCaseContactAddressInteractor'; /** * used for sealing an address on a case @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const sealCaseContactAddressLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .sealCaseContactAddressInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const sealCaseContactAddressLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await sealCaseContactAddressInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From f2b04c43f909a3914ae71939c2e6534d6093f426 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:17:19 -0700 Subject: [PATCH 091/523] 10417: Remove getCurrentUser from shared --- .../useCases/sealCaseInteractor.test.ts | 64 ++++++++++++------- .../business/useCases/sealCaseInteractor.ts | 15 ++--- web-api/src/lambdas/cases/sealCaseLambda.ts | 24 ++++--- 3 files changed, 63 insertions(+), 40 deletions(-) diff --git a/shared/src/business/useCases/sealCaseInteractor.test.ts b/shared/src/business/useCases/sealCaseInteractor.test.ts index 9e88ab6eec2..0c358e926a3 100644 --- a/shared/src/business/useCases/sealCaseInteractor.test.ts +++ b/shared/src/business/useCases/sealCaseInteractor.test.ts @@ -1,12 +1,16 @@ import { MOCK_CASE } from '../../test/mockCase'; import { MOCK_LOCK } from '../../test/mockLock'; -import { ROLES } from '../entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { sealCaseInteractor } from './sealCaseInteractor'; describe('sealCaseInteractor', () => { let mockLock; + beforeAll(() => { applicationContext .getPersistenceGateway() @@ -18,35 +22,39 @@ describe('sealCaseInteractor', () => { applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); }); it('should throw an error if the user is unauthorized to seal a case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.privatePractitioner, - userId: 'docketClerk', - }); await expect( - sealCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }), + sealCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Unauthorized for sealing cases'); }); it('should call updateCase with the sealedDate set on the case and return the updated case', async () => { - const result = await sealCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await sealCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect(result.sealedDate).toBeTruthy(); }); it('should send a notification that a case has been sealed', async () => { - await sealCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + await sealCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getDispatchers().sendNotificationOfSealing, ).toHaveBeenCalled(); @@ -56,9 +64,13 @@ describe('sealCaseInteractor', () => { mockLock = MOCK_LOCK; await expect( - sealCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }), + sealCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -67,9 +79,13 @@ describe('sealCaseInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await sealCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + await sealCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/sealCaseInteractor.ts b/shared/src/business/useCases/sealCaseInteractor.ts index 511fa8404c7..28cb1a0529c 100644 --- a/shared/src/business/useCases/sealCaseInteractor.ts +++ b/shared/src/business/useCases/sealCaseInteractor.ts @@ -3,7 +3,9 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -14,12 +16,11 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {Promise} the updated case data */ export const sealCase = async ( - applicationContext: IApplicationContext, + applicationContext: ServerApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.SEAL_CASE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.SEAL_CASE)) { throw new UnauthorizedError('Unauthorized for sealing cases'); } @@ -27,7 +28,7 @@ export const sealCase = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { authorizedUser: user }); + const newCase = new Case(oldCase, { authorizedUser }); newCase.setAsSealed(); @@ -42,9 +43,7 @@ export const sealCase = async ( .getDispatchers() .sendNotificationOfSealing(applicationContext, { docketNumber }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const sealCaseInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/sealCaseLambda.ts b/web-api/src/lambdas/cases/sealCaseLambda.ts index 87ad9d7b757..666315cadb4 100644 --- a/web-api/src/lambdas/cases/sealCaseLambda.ts +++ b/web-api/src/lambdas/cases/sealCaseLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { sealCaseInteractor } from '@shared/business/useCases/sealCaseInteractor'; /** * used for marking a case as sealed @@ -6,11 +8,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const sealCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .sealCaseInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const sealCaseLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await sealCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 40e10058931f019ae545e50cf0a81037a06d0d7d Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:20:17 -0700 Subject: [PATCH 092/523] 10417: Remove getCurrentUser from shared --- .../unblockCaseFromTrialInteractor.test.ts | 62 ++++++++++++------- .../unblockCaseFromTrialInteractor.ts | 7 ++- .../cases/unblockCaseFromTrialLambda.ts | 27 +++++--- 3 files changed, 63 insertions(+), 33 deletions(-) diff --git a/shared/src/business/useCases/unblockCaseFromTrialInteractor.test.ts b/shared/src/business/useCases/unblockCaseFromTrialInteractor.test.ts index 71f8c7d5fe6..338b71e5fbb 100644 --- a/shared/src/business/useCases/unblockCaseFromTrialInteractor.test.ts +++ b/shared/src/business/useCases/unblockCaseFromTrialInteractor.test.ts @@ -1,8 +1,12 @@ -import { CASE_STATUS_TYPES, ROLES } from '../entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; import { MOCK_LOCK } from '../../test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { unblockCaseFromTrialInteractor } from './unblockCaseFromTrialInteractor'; describe('unblockCaseFromTrialInteractor', () => { @@ -15,10 +19,6 @@ describe('unblockCaseFromTrialInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue( @@ -29,9 +29,13 @@ describe('unblockCaseFromTrialInteractor', () => { ); }); it('should set the blocked flag to false and remove the blockedReason', async () => { - const result = await unblockCaseFromTrialInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await unblockCaseFromTrialInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect(result).toMatchObject({ blocked: false, @@ -48,12 +52,14 @@ describe('unblockCaseFromTrialInteractor', () => { }); it('should throw an unauthorized error if the user has no access to unblock the case', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - unblockCaseFromTrialInteractor(applicationContext, { - docketNumber: '123-45', - }), + unblockCaseFromTrialInteractor( + applicationContext, + { + docketNumber: '123-45', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -68,9 +74,13 @@ describe('unblockCaseFromTrialInteractor', () => { }), ); - await unblockCaseFromTrialInteractor(applicationContext, { - docketNumber: '123-45', - }); + await unblockCaseFromTrialInteractor( + applicationContext, + { + docketNumber: '123-45', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -82,9 +92,13 @@ describe('unblockCaseFromTrialInteractor', () => { mockLock = MOCK_LOCK; await expect( - unblockCaseFromTrialInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }), + unblockCaseFromTrialInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -93,9 +107,13 @@ describe('unblockCaseFromTrialInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await unblockCaseFromTrialInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + await unblockCaseFromTrialInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts b/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts index 9f862561670..41269bb20b8 100644 --- a/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts +++ b/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts @@ -3,7 +3,9 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -14,11 +16,10 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the case data */ export const unblockCaseFromTrial = async ( - applicationContext: IApplicationContext, + applicationContext: ServerApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.BLOCK_CASE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/cases/unblockCaseFromTrialLambda.ts b/web-api/src/lambdas/cases/unblockCaseFromTrialLambda.ts index 953d03b8133..dec2a18f10a 100644 --- a/web-api/src/lambdas/cases/unblockCaseFromTrialLambda.ts +++ b/web-api/src/lambdas/cases/unblockCaseFromTrialLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { unblockCaseFromTrialInteractor } from '@shared/business/useCases/unblockCaseFromTrialInteractor'; /** * used for unblocking a case @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const unblockCaseFromTrialLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .unblockCaseFromTrialInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const unblockCaseFromTrialLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await unblockCaseFromTrialInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 72debea37b8925d3a788f1a575cf846bc6461e5e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:23:37 -0700 Subject: [PATCH 093/523] 10417: Remove getCurrentUser from shared --- .../unprioritizeCaseInteractor.test.ts | 74 ++++++++++++------- .../useCases/unprioritizeCaseInteractor.ts | 7 +- .../lambdas/cases/unprioritizeCaseLambda.ts | 27 +++++-- 3 files changed, 70 insertions(+), 38 deletions(-) diff --git a/shared/src/business/useCases/unprioritizeCaseInteractor.test.ts b/shared/src/business/useCases/unprioritizeCaseInteractor.test.ts index 38d86ae78b2..a3888f0370f 100644 --- a/shared/src/business/useCases/unprioritizeCaseInteractor.test.ts +++ b/shared/src/business/useCases/unprioritizeCaseInteractor.test.ts @@ -1,18 +1,20 @@ -import { CASE_STATUS_TYPES, ROLES } from '../entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; import { MOCK_LOCK } from '../../test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { unprioritizeCaseInteractor } from './unprioritizeCaseInteractor'; describe('unprioritizeCaseInteractor', () => { - let mockUser; let mockLock; beforeAll(() => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => mockLock); - applicationContext.getCurrentUser.mockImplementation(() => mockUser); applicationContext .getUseCaseHelpers() @@ -23,19 +25,17 @@ describe('unprioritizeCaseInteractor', () => { beforeEach(() => { mockLock = undefined; - mockUser = { - role: ROLES.petitionsClerk, - userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', - }; }); it('should throw an unauthorized error if the user has no access to unprioritize the case', async () => { - mockUser = {}; - await expect( - unprioritizeCaseInteractor(applicationContext, { - docketNumber: '123-20', - }), + unprioritizeCaseInteractor( + applicationContext, + { + docketNumber: '123-20', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -44,9 +44,13 @@ describe('unprioritizeCaseInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(Promise.resolve(MOCK_CASE)); - await unprioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + await unprioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().updateCaseAutomaticBlock, @@ -65,9 +69,13 @@ describe('unprioritizeCaseInteractor', () => { }), ); - const result = await unprioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await unprioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect(result).toMatchObject({ highPriority: false, @@ -99,9 +107,13 @@ describe('unprioritizeCaseInteractor', () => { }), ); - const result = await unprioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await unprioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect(result).toMatchObject({ highPriority: false, @@ -125,9 +137,13 @@ describe('unprioritizeCaseInteractor', () => { mockLock = MOCK_LOCK; await expect( - unprioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }), + unprioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -138,9 +154,13 @@ describe('unprioritizeCaseInteractor', () => { it('should acquire and remove the lock on the case', async () => { mockLock = undefined; - await unprioritizeCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + await unprioritizeCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/unprioritizeCaseInteractor.ts b/shared/src/business/useCases/unprioritizeCaseInteractor.ts index 8eb9ce61501..2d419311b61 100644 --- a/shared/src/business/useCases/unprioritizeCaseInteractor.ts +++ b/shared/src/business/useCases/unprioritizeCaseInteractor.ts @@ -3,7 +3,9 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -14,11 +16,10 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the case data */ export const unprioritizeCase = async ( - applicationContext: IApplicationContext, + applicationContext: ServerApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.PRIORITIZE_CASE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/cases/unprioritizeCaseLambda.ts b/web-api/src/lambdas/cases/unprioritizeCaseLambda.ts index 5b8a27ee965..bd9b9bdb258 100644 --- a/web-api/src/lambdas/cases/unprioritizeCaseLambda.ts +++ b/web-api/src/lambdas/cases/unprioritizeCaseLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { unprioritizeCaseInteractor } from '@shared/business/useCases/unprioritizeCaseInteractor'; /** * used for removing the high priority from a case @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const unprioritizeCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .unprioritizeCaseInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const unprioritizeCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await unprioritizeCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 416ed35f4a8058b0094da099eb0acb1b97622cc5 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:25:55 -0700 Subject: [PATCH 094/523] 10417: Remove getCurrentUser from shared --- .../useCases/unsealCaseInteractor.test.ts | 55 ++++++++++++------- .../business/useCases/unsealCaseInteractor.ts | 15 +++-- web-api/src/lambdas/cases/unsealCaseLambda.ts | 24 +++++--- 3 files changed, 57 insertions(+), 37 deletions(-) diff --git a/shared/src/business/useCases/unsealCaseInteractor.test.ts b/shared/src/business/useCases/unsealCaseInteractor.test.ts index b540ed77390..1a1d94a4b1d 100644 --- a/shared/src/business/useCases/unsealCaseInteractor.test.ts +++ b/shared/src/business/useCases/unsealCaseInteractor.test.ts @@ -1,12 +1,16 @@ import { MOCK_CASE } from '../../test/mockCase'; import { MOCK_LOCK } from '../../test/mockLock'; -import { ROLES } from '../entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { unsealCaseInteractor } from './unsealCaseInteractor'; describe('unsealCaseInteractor', () => { let mockLock; + beforeAll(() => { applicationContext .getPersistenceGateway() @@ -18,28 +22,29 @@ describe('unsealCaseInteractor', () => { applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); }); it('should throw an error if the user is unauthorized to unseal a case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - }); - await expect( - unsealCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }), + unsealCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Unauthorized for unsealing cases'); }); it('should call updateCase with isSealed set to false and return the updated case', async () => { - const result = await unsealCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await unsealCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); + expect(result.isSealed).toBe(false); expect(result.sealedDate).toBe(undefined); }); @@ -48,9 +53,13 @@ describe('unsealCaseInteractor', () => { mockLock = MOCK_LOCK; await expect( - unsealCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }), + unsealCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -59,9 +68,13 @@ describe('unsealCaseInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await unsealCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + await unsealCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/unsealCaseInteractor.ts b/shared/src/business/useCases/unsealCaseInteractor.ts index ae0230de4d0..79da9d6319f 100644 --- a/shared/src/business/useCases/unsealCaseInteractor.ts +++ b/shared/src/business/useCases/unsealCaseInteractor.ts @@ -3,7 +3,9 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -14,12 +16,11 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {Promise} the updated case data */ export const unsealCase = async ( - applicationContext: IApplicationContext, + applicationContext: ServerApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.UNSEAL_CASE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.UNSEAL_CASE)) { throw new UnauthorizedError('Unauthorized for unsealing cases'); } @@ -27,7 +28,7 @@ export const unsealCase = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { authorizedUser: user }); + const newCase = new Case(oldCase, { authorizedUser }); newCase.setAsUnsealed(); @@ -38,9 +39,7 @@ export const unsealCase = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const unsealCaseInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/unsealCaseLambda.ts b/web-api/src/lambdas/cases/unsealCaseLambda.ts index b699e6a5b7d..56afd224a47 100644 --- a/web-api/src/lambdas/cases/unsealCaseLambda.ts +++ b/web-api/src/lambdas/cases/unsealCaseLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { unsealCaseInteractor } from '@shared/business/useCases/unsealCaseInteractor'; /** * used for marking a case as unsealed @@ -6,11 +8,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const unsealCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .unsealCaseInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const unsealCaseLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await unsealCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 0ffd8d0eb57147e6c938aa7b1db558825fe97e42 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:28:56 -0700 Subject: [PATCH 095/523] 10417: Remove getCurrentUser from shared --- .../updateCaseContextInteractor.test.ts | 194 ++++++++++-------- .../useCases/updateCaseContextInteractor.ts | 17 +- .../lambdas/cases/updateCaseContextLambda.ts | 29 ++- 3 files changed, 143 insertions(+), 97 deletions(-) diff --git a/shared/src/business/useCases/updateCaseContextInteractor.test.ts b/shared/src/business/useCases/updateCaseContextInteractor.test.ts index c510adc81b3..0f6529d0fdd 100644 --- a/shared/src/business/useCases/updateCaseContextInteractor.test.ts +++ b/shared/src/business/useCases/updateCaseContextInteractor.test.ts @@ -1,21 +1,14 @@ -import { - CASE_STATUS_TYPES, - CHIEF_JUDGE, - ROLES, -} from '../entities/EntityConstants'; +import { CASE_STATUS_TYPES, CHIEF_JUDGE } from '../entities/EntityConstants'; import { MOCK_CASE, MOCK_CASE_WITH_TRIAL_SESSION } from '../../test/mockCase'; import { MOCK_TRIAL_REMOTE } from '../../test/mockTrial'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { updateCaseContextInteractor } from './updateCaseContextInteractor'; describe('updateCaseContextInteractor', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', - }); - }); - beforeEach(() => { applicationContext .getPersistenceGateway() @@ -23,42 +16,48 @@ describe('updateCaseContextInteractor', () => { }); it('should throw an error if the user is unauthorized to update a case', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - updateCaseContextInteractor(applicationContext, { - caseStatus: CASE_STATUS_TYPES.cav, - docketNumber: MOCK_CASE.docketNumber, - }), + updateCaseContextInteractor( + applicationContext, + { + caseStatus: CASE_STATUS_TYPES.cav, + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for update case'); }); it('should call updateCase with the updated case status and return the updated case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(Promise.resolve(MOCK_CASE)); - const result = await updateCaseContextInteractor(applicationContext, { - caseStatus: CASE_STATUS_TYPES.cav, - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await updateCaseContextInteractor( + applicationContext, + { + caseStatus: CASE_STATUS_TYPES.cav, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect(result.status).toEqual(CASE_STATUS_TYPES.cav); }); it('should not remove the case from trial if the old and new case status match', async () => { const rachaelId = 'dabbad00-18d0-43ec-bafb-654e83405416'; - const result = await updateCaseContextInteractor(applicationContext, { - caseStatus: CASE_STATUS_TYPES.new, - docketNumber: MOCK_CASE.docketNumber, - judgeData: { - associatedJudge: 'Judge Rachael', - associatedJudgeId: rachaelId, + const result = await updateCaseContextInteractor( + applicationContext, + { + caseStatus: CASE_STATUS_TYPES.new, + docketNumber: MOCK_CASE.docketNumber, + judgeData: { + associatedJudge: 'Judge Rachael', + associatedJudgeId: rachaelId, + }, }, - }); + mockDocketClerkUser, + ); expect(result.status).toEqual(CASE_STATUS_TYPES.new); expect( @@ -79,14 +78,18 @@ describe('updateCaseContextInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_REMOTE); - const result = await updateCaseContextInteractor(applicationContext, { - caseStatus: CASE_STATUS_TYPES.cav, - docketNumber: MOCK_CASE_WITH_TRIAL_SESSION.docketNumber, - judgeData: { - associatedJudge: 'Judge Rachael', - associatedJudgeId: rachaelId, + const result = await updateCaseContextInteractor( + applicationContext, + { + caseStatus: CASE_STATUS_TYPES.cav, + docketNumber: MOCK_CASE_WITH_TRIAL_SESSION.docketNumber, + judgeData: { + associatedJudge: 'Judge Rachael', + associatedJudgeId: rachaelId, + }, }, - }); + mockDocketClerkUser, + ); expect(result.status).toEqual(CASE_STATUS_TYPES.cav); expect(result.associatedJudge).toEqual('Judge Rachael'); @@ -95,10 +98,14 @@ describe('updateCaseContextInteractor', () => { }); it('should call updateCase and remove the case from trial if the old case status was calendared and the new case status is General Docket - Not At Issue', async () => { - const result = await updateCaseContextInteractor(applicationContext, { - caseStatus: CASE_STATUS_TYPES.generalDocket, - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await updateCaseContextInteractor( + applicationContext, + { + caseStatus: CASE_STATUS_TYPES.generalDocket, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect(result.status).toEqual(CASE_STATUS_TYPES.generalDocket); expect(result.associatedJudge).toEqual(CHIEF_JUDGE); @@ -114,10 +121,14 @@ describe('updateCaseContextInteractor', () => { status: CASE_STATUS_TYPES.generalDocketReadyForTrial, }); - const result = await updateCaseContextInteractor(applicationContext, { - caseStatus: CASE_STATUS_TYPES.generalDocket, - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await updateCaseContextInteractor( + applicationContext, + { + caseStatus: CASE_STATUS_TYPES.generalDocket, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect(result.status).toEqual(CASE_STATUS_TYPES.generalDocket); expect( @@ -127,10 +138,14 @@ describe('updateCaseContextInteractor', () => { }); it('should call updateCase and createCaseTrialSortMappingRecords if the case status is being updated to Ready for Trial and is not assigned to a trial session', async () => { - const result = await updateCaseContextInteractor(applicationContext, { - caseStatus: CASE_STATUS_TYPES.generalDocketReadyForTrial, - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await updateCaseContextInteractor( + applicationContext, + { + caseStatus: CASE_STATUS_TYPES.generalDocketReadyForTrial, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect(result.status).toEqual(CASE_STATUS_TYPES.generalDocketReadyForTrial); expect( @@ -156,10 +171,14 @@ describe('updateCaseContextInteractor', () => { return caseToUpdate; }); - const result = await updateCaseContextInteractor(applicationContext, { - caseStatus: CASE_STATUS_TYPES.generalDocketReadyForTrial, - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await updateCaseContextInteractor( + applicationContext, + { + caseStatus: CASE_STATUS_TYPES.generalDocketReadyForTrial, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect(result.status).toEqual(CASE_STATUS_TYPES.generalDocketReadyForTrial); expect( @@ -172,10 +191,6 @@ describe('updateCaseContextInteractor', () => { }); it('should only update the associated judge without changing the status if only the associated judge is passed in', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: '7ad8dcbc-5978-4a29-8c41-02422b66f410', - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue({ @@ -185,27 +200,36 @@ describe('updateCaseContextInteractor', () => { status: CASE_STATUS_TYPES.submitted, }); - const result = await updateCaseContextInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - judgeData: { - associatedJudge: 'Judge Carluzzo', - associatedJudgeId: 'carluzzo-id', + const result = await updateCaseContextInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + judgeData: { + associatedJudge: 'Judge Carluzzo', + associatedJudgeId: 'carluzzo-id', + }, }, - }); + mockDocketClerkUser, + ); + expect(result.status).toEqual(CASE_STATUS_TYPES.submitted); expect(result.associatedJudge).toEqual('Judge Carluzzo'); expect(result.associatedJudgeId).toEqual('carluzzo-id'); }); it('should only update the associated judge without changing the status if the associated judge and the same case status are passed in', async () => { - const result = await updateCaseContextInteractor(applicationContext, { - caseStatus: CASE_STATUS_TYPES.submitted, - docketNumber: MOCK_CASE.docketNumber, - judgeData: { - associatedJudge: 'Judge Carluzzo', - associatedJudgeId: 'carluzzo-id', + const result = await updateCaseContextInteractor( + applicationContext, + { + caseStatus: CASE_STATUS_TYPES.submitted, + docketNumber: MOCK_CASE.docketNumber, + judgeData: { + associatedJudge: 'Judge Carluzzo', + associatedJudgeId: 'carluzzo-id', + }, }, - }); + mockDocketClerkUser, + ); expect(result.status).toEqual(CASE_STATUS_TYPES.submitted); expect(result.associatedJudge).toEqual('Judge Carluzzo'); @@ -213,10 +237,14 @@ describe('updateCaseContextInteractor', () => { }); it('should call updateCase with the updated case caption and return the updated case', async () => { - const result = await updateCaseContextInteractor(applicationContext, { - caseCaption: 'The new case caption', - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await updateCaseContextInteractor( + applicationContext, + { + caseCaption: 'The new case caption', + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect(result.caseCaption).toEqual('The new case caption'); }); @@ -231,10 +259,14 @@ describe('updateCaseContextInteractor', () => { }), ); - await updateCaseContextInteractor(applicationContext, { - caseCaption: 'The new case caption', - docketNumber: MOCK_CASE.docketNumber, - }); + await updateCaseContextInteractor( + applicationContext, + { + caseCaption: 'The new case caption', + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() diff --git a/shared/src/business/useCases/updateCaseContextInteractor.ts b/shared/src/business/useCases/updateCaseContextInteractor.ts index 6e15faba1f9..b9d6c4ab940 100644 --- a/shared/src/business/useCases/updateCaseContextInteractor.ts +++ b/shared/src/business/useCases/updateCaseContextInteractor.ts @@ -5,12 +5,14 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const updateCaseContext = async ( - applicationContext: IApplicationContext, + applicationContext: ServerApplicationContext, { caseCaption, caseStatus, @@ -25,10 +27,9 @@ export const updateCaseContext = async ( caseStatus?: string; docketNumber: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.UPDATE_CASE_CONTEXT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPDATE_CASE_CONTEXT)) { throw new UnauthorizedError('Unauthorized for update case'); } @@ -36,7 +37,7 @@ export const updateCaseContext = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { authorizedUser: user }); + const newCase = new Case(oldCase, { authorizedUser }); if (caseCaption) { newCase.setCaseCaption(caseCaption); @@ -53,7 +54,7 @@ export const updateCaseContext = async ( if (caseStatus && caseStatus !== oldCase.status) { const date = applicationContext.getUtilities().createISODateString(); newCase.setCaseStatus({ - changedBy: user.name, + changedBy: authorizedUser.name, date, updatedCaseStatus: caseStatus, }); @@ -116,7 +117,9 @@ export const updateCaseContext = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { authorizedUser: user }).toRawObject(); + return new Case(updatedCase, { + authorizedUser, + }).toRawObject(); }; export const updateCaseContextInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/updateCaseContextLambda.ts b/web-api/src/lambdas/cases/updateCaseContextLambda.ts index e7cebae660e..a1c5a1592d0 100644 --- a/web-api/src/lambdas/cases/updateCaseContextLambda.ts +++ b/web-api/src/lambdas/cases/updateCaseContextLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateCaseContextInteractor } from '@shared/business/useCases/updateCaseContextInteractor'; /** * used for updating a case status @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateCaseContextLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCaseContextInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const updateCaseContextLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await updateCaseContextInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 0ff316b96bdebfaba892c6581ada3ea59c979b35 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:32:57 -0700 Subject: [PATCH 096/523] 10417: Remove getCurrentUser from shared --- .../updateCaseDetailsInteractor.test.ts | 349 +++++++++++------- .../useCases/updateCaseDetailsInteractor.ts | 25 +- .../lambdas/cases/updateCaseDetailsLambda.ts | 29 +- 3 files changed, 246 insertions(+), 157 deletions(-) diff --git a/shared/src/business/useCases/updateCaseDetailsInteractor.test.ts b/shared/src/business/useCases/updateCaseDetailsInteractor.test.ts index b999e0418a7..a00a4064596 100644 --- a/shared/src/business/useCases/updateCaseDetailsInteractor.test.ts +++ b/shared/src/business/useCases/updateCaseDetailsInteractor.test.ts @@ -12,7 +12,10 @@ import { } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; -import { docketClerkUser } from '@shared/test/mockUsers'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { updateCaseDetailsInteractor } from './updateCaseDetailsInteractor'; describe('updateCaseDetailsInteractor', () => { @@ -33,71 +36,87 @@ describe('updateCaseDetailsInteractor', () => { status: CASE_STATUS_TYPES.generalDocketReadyForTrial, }); - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(mockCase); }); it('should throw an error when the user is unauthorized to update a case', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - updateCaseDetailsInteractor(applicationContext, { - caseDetails: {}, - docketNumber: mockCase.docketNumber, - }), + updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: {}, + docketNumber: mockCase.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should throw a validation error when the updates to the case make it invalid', async () => { await expect( - updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - caseType: undefined, + updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + caseType: undefined, + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }), + mockDocketClerkUser, + ), ).rejects.toThrow('The Case entity was invalid'); }); it('should set irsNoticeDate when the updated case has a verified IRS notice', async () => { - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - hasVerifiedIrsNotice: true, - irsNoticeDate: '2020-08-28T01:49:58.117Z', + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + hasVerifiedIrsNotice: true, + irsNoticeDate: '2020-08-28T01:49:58.117Z', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockDocketClerkUser, + ); expect(result.hasVerifiedIrsNotice).toBe(true); expect(result.irsNoticeDate).toBe('2020-08-28T01:49:58.117Z'); }); it('should set irsNoticeDate to undefined when the updated case does not have a verified IRS notice', async () => { - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - hasVerifiedIrsNotice: false, - irsNoticeDate: '2020-08-28T01:49:58.117Z', + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + hasVerifiedIrsNotice: false, + irsNoticeDate: '2020-08-28T01:49:58.117Z', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockDocketClerkUser, + ); expect(result.hasVerifiedIrsNotice).toBe(false); expect(result.irsNoticeDate).toBe(undefined); }); it('should call updateCase with the updated case payment information (when unpaid) and return the updated case', async () => { - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - petitionPaymentStatus: PAYMENT_STATUS.UNPAID, + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -109,15 +128,19 @@ describe('updateCaseDetailsInteractor', () => { }); it('should call updateCase with the updated case payment information (when paid) and return the updated case', async () => { - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - petitionPaymentDate: '2019-11-30T09:10:11.000Z', - petitionPaymentMethod: 'check', - petitionPaymentStatus: PAYMENT_STATUS.PAID, + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + petitionPaymentDate: '2019-11-30T09:10:11.000Z', + petitionPaymentMethod: 'check', + petitionPaymentStatus: PAYMENT_STATUS.PAID, + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -129,14 +152,18 @@ describe('updateCaseDetailsInteractor', () => { }); it('should call updateCase with the updated case payment information (when waived) and return the updated case', async () => { - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - petitionPaymentStatus: PAYMENT_STATUS.WAIVED, - petitionPaymentWaivedDate: '2019-11-30T09:10:11.000Z', + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, + petitionPaymentWaivedDate: '2019-11-30T09:10:11.000Z', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -157,14 +184,18 @@ describe('updateCaseDetailsInteractor', () => { petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }); - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - petitionPaymentStatus: PAYMENT_STATUS.WAIVED, - petitionPaymentWaivedDate: '2019-11-30T09:10:11.000Z', + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + petitionPaymentStatus: PAYMENT_STATUS.WAIVED, + petitionPaymentWaivedDate: '2019-11-30T09:10:11.000Z', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockDocketClerkUser, + ); const waivedDocument = result.docketEntries.find( entry => @@ -182,15 +213,19 @@ describe('updateCaseDetailsInteractor', () => { petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }); - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - petitionPaymentDate: '2019-11-30T09:10:11.000Z', - petitionPaymentMethod: 'check', - petitionPaymentStatus: PAYMENT_STATUS.PAID, + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + petitionPaymentDate: '2019-11-30T09:10:11.000Z', + petitionPaymentMethod: 'check', + petitionPaymentStatus: PAYMENT_STATUS.PAID, + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockDocketClerkUser, + ); const paidDocument = result.docketEntries.find( entry => @@ -208,13 +243,17 @@ describe('updateCaseDetailsInteractor', () => { petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }); - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - petitionPaymentStatus: PAYMENT_STATUS.UNPAID, + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockDocketClerkUser, + ); expect(result).toMatchObject({ docketEntries: MOCK_CASE.docketEntries, @@ -226,13 +265,17 @@ describe('updateCaseDetailsInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(generalDocketReadyForTrialCase); - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...generalDocketReadyForTrialCase, - preferredTrialCity: 'Cheyenne, Wyoming', + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...generalDocketReadyForTrialCase, + preferredTrialCity: 'Cheyenne, Wyoming', + }, + docketNumber: generalDocketReadyForTrialCase.docketNumber, }, - docketNumber: generalDocketReadyForTrialCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -253,14 +296,18 @@ describe('updateCaseDetailsInteractor', () => { highPriorityReason: 'roll out', }); - const result = await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...generalDocketReadyForTrialCase, - preferredTrialCity: 'Cheyenne, Wyoming', - status: CASE_STATUS_TYPES.rule155, + const result = await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...generalDocketReadyForTrialCase, + preferredTrialCity: 'Cheyenne, Wyoming', + status: CASE_STATUS_TYPES.rule155, + }, + docketNumber: generalDocketReadyForTrialCase.docketNumber, }, - docketNumber: generalDocketReadyForTrialCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -284,15 +331,19 @@ describe('updateCaseDetailsInteractor', () => { highPriorityReason: 'roll out', }); - await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...generalDocketReadyForTrialCase, - highPriority: true, - preferredTrialCity: 'Cheyenne, Wyoming', - status: CASE_STATUS_TYPES.rule155, + await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...generalDocketReadyForTrialCase, + highPriority: true, + preferredTrialCity: 'Cheyenne, Wyoming', + status: CASE_STATUS_TYPES.rule155, + }, + docketNumber: generalDocketReadyForTrialCase.docketNumber, }, - docketNumber: generalDocketReadyForTrialCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -308,13 +359,17 @@ describe('updateCaseDetailsInteractor', () => { caseType: CASE_TYPES_MAP.cdp, }); - await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...generalDocketReadyForTrialCase, - caseType: CASE_TYPES_MAP.deficiency, + await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...generalDocketReadyForTrialCase, + caseType: CASE_TYPES_MAP.deficiency, + }, + docketNumber: generalDocketReadyForTrialCase.docketNumber, }, - docketNumber: generalDocketReadyForTrialCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -330,13 +385,17 @@ describe('updateCaseDetailsInteractor', () => { procedureType: 'Regular', }); - await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...generalDocketReadyForTrialCase, - procedureType: 'Small', + await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...generalDocketReadyForTrialCase, + procedureType: 'Small', + }, + docketNumber: generalDocketReadyForTrialCase.docketNumber, }, - docketNumber: generalDocketReadyForTrialCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -353,13 +412,17 @@ describe('updateCaseDetailsInteractor', () => { procedureType: 'Regular', }); - await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...generalDocketReadyForTrialCase, - procedureType: 'Small', + await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...generalDocketReadyForTrialCase, + procedureType: 'Small', + }, + docketNumber: generalDocketReadyForTrialCase.docketNumber, }, - docketNumber: generalDocketReadyForTrialCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -375,12 +438,16 @@ describe('updateCaseDetailsInteractor', () => { procedureType: 'Regular', }); - await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...generalDocketReadyForTrialCase, + await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...generalDocketReadyForTrialCase, + }, + docketNumber: generalDocketReadyForTrialCase.docketNumber, }, - docketNumber: generalDocketReadyForTrialCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -396,16 +463,20 @@ describe('updateCaseDetailsInteractor', () => { highPriorityReason: 'roll out', }); - await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...generalDocketReadyForTrialCase, - mailingDate: 'SOME NEW MAILING DATE', // attempting to change a field that does not exist in editableFields - partyType: 'SOME NEW PARTY TYPE', // attempting to change a field that does not exist in editableFields - preferredTrialCity: 'Cheyenne, Wyoming', - status: CASE_STATUS_TYPES.rule155, + await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...generalDocketReadyForTrialCase, + mailingDate: 'SOME NEW MAILING DATE', // attempting to change a field that does not exist in editableFields + partyType: 'SOME NEW PARTY TYPE', // attempting to change a field that does not exist in editableFields + preferredTrialCity: 'Cheyenne, Wyoming', + status: CASE_STATUS_TYPES.rule155, + }, + docketNumber: generalDocketReadyForTrialCase.docketNumber, }, - docketNumber: generalDocketReadyForTrialCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -422,13 +493,17 @@ describe('updateCaseDetailsInteractor', () => { mockLock = MOCK_LOCK; await expect( - updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - petitionPaymentStatus: PAYMENT_STATUS.UNPAID, + updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }), + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -437,13 +512,17 @@ describe('updateCaseDetailsInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await updateCaseDetailsInteractor(applicationContext, { - caseDetails: { - ...mockCase, - petitionPaymentStatus: PAYMENT_STATUS.UNPAID, + await updateCaseDetailsInteractor( + applicationContext, + { + caseDetails: { + ...mockCase, + petitionPaymentStatus: PAYMENT_STATUS.UNPAID, + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/updateCaseDetailsInteractor.ts b/shared/src/business/useCases/updateCaseDetailsInteractor.ts index a02a8c7ed9a..73b1d9dde79 100644 --- a/shared/src/business/useCases/updateCaseDetailsInteractor.ts +++ b/shared/src/business/useCases/updateCaseDetailsInteractor.ts @@ -8,7 +8,9 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -21,12 +23,11 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the updated case data */ export const updateCaseDetails = async ( - applicationContext: IApplicationContext, + applicationContext: ServerApplicationContext, { caseDetails, docketNumber }: { caseDetails: any; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.EDIT_CASE_DETAILS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.EDIT_CASE_DETAILS)) { throw new UnauthorizedError('Unauthorized for editing case details'); } @@ -66,7 +67,7 @@ export const updateCaseDetails = async ( ? editableFields.petitionPaymentWaivedDate : null, }, - { authorizedUser: user }, + { authorizedUser }, ); if (oldCase.petitionPaymentStatus === PAYMENT_STATUS.UNPAID) { @@ -81,10 +82,10 @@ export const updateCaseDetails = async ( isOnDocketRecord: true, processingStatus: 'complete', }, - { authorizedUser: user }, + { authorizedUser }, ); - filingFeePaidEntry.setFiledBy(user); + filingFeePaidEntry.setFiledBy(authorizedUser); newCaseEntity.addDocketEntry(filingFeePaidEntry); } else if (isWaived) { @@ -98,17 +99,17 @@ export const updateCaseDetails = async ( isOnDocketRecord: true, processingStatus: 'complete', }, - { authorizedUser: user }, + { authorizedUser }, ); - filingFeeWaivedEntry.setFiledBy(user); + filingFeeWaivedEntry.setFiledBy(authorizedUser); newCaseEntity.addDocketEntry(filingFeeWaivedEntry); } } if (newCaseEntity.getShouldHaveTrialSortMappingRecords()) { - const oldCaseEntity = new Case(oldCase, { authorizedUser: user }); + const oldCaseEntity = new Case(oldCase, { authorizedUser }); const oldTrialSortTag = oldCaseEntity.getShouldHaveTrialSortMappingRecords() ? oldCaseEntity.generateTrialSortTags() : { nonHybrid: undefined }; @@ -135,9 +136,7 @@ export const updateCaseDetails = async ( caseToUpdate: newCaseEntity, }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const updateCaseDetailsInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/updateCaseDetailsLambda.ts b/web-api/src/lambdas/cases/updateCaseDetailsLambda.ts index b77a5f111e6..456590e0835 100644 --- a/web-api/src/lambdas/cases/updateCaseDetailsLambda.ts +++ b/web-api/src/lambdas/cases/updateCaseDetailsLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateCaseDetailsInteractor } from '@shared/business/useCases/updateCaseDetailsInteractor'; /** * used for updating a case's petition details information (IRS notice date, case type, case procedure, @@ -7,12 +9,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateCaseDetailsLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCaseDetailsInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const updateCaseDetailsLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await updateCaseDetailsInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From a4b09c3dfa0b7a8f51322797237fed3a04fff8be Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:37:43 -0700 Subject: [PATCH 097/523] 10417: Remove getCurrentUser from shared --- .../updateCaseTrialSortTagsInteractor.test.ts | 69 +++++++++++-------- .../updateCaseTrialSortTagsInteractor.ts | 8 +-- .../cases/updateCaseTrialSortTagsLambda.ts | 27 +++++--- 3 files changed, 64 insertions(+), 40 deletions(-) diff --git a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.ts b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.ts index 80e88d8f96a..7d926f81a7c 100644 --- a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.ts +++ b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.test.ts @@ -1,9 +1,12 @@ -import { CASE_STATUS_TYPES, ROLES } from '../entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '../entities/EntityConstants'; import { Case } from '../entities/cases/Case'; import { MOCK_CASE } from '../../test/mockCase'; -import { User } from '../entities/User'; import { applicationContext } from '../test/createTestApplicationContext'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; +import { + mockDocketClerkUser, + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; import { updateCaseTrialSortTagsInteractor } from './updateCaseTrialSortTagsInteractor'; @@ -13,23 +16,19 @@ describe('Update case trial sort tags', () => { beforeEach(() => { mockCase = MOCK_CASE; - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'bob', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), - ); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(Promise.resolve(mockCase)); }); it('does not call persistence if case status is not ready for trial', async () => { - await updateCaseTrialSortTagsInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - }); + await updateCaseTrialSortTagsInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -40,9 +39,13 @@ describe('Update case trial sort tags', () => { it('calls persistence if case status is ready for trial', async () => { mockCase.status = CASE_STATUS_TYPES.generalDocketReadyForTrial; - await updateCaseTrialSortTagsInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - }); + await updateCaseTrialSortTagsInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -51,12 +54,14 @@ describe('Update case trial sort tags', () => { }); it('throws unauthorized error if user is unauthorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - updateCaseTrialSortTagsInteractor(applicationContext, { - docketNumber: mockCase.docketNumber, - }), + updateCaseTrialSortTagsInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for update case'); }); @@ -66,9 +71,13 @@ describe('Update case trial sort tags', () => { .getCaseByDocketNumber.mockReturnValue(null); await expect( - updateCaseTrialSortTagsInteractor(applicationContext, { - docketNumber: '123-45', - }), + updateCaseTrialSortTagsInteractor( + applicationContext, + { + docketNumber: '123-45', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Case 123-45'); }); @@ -85,9 +94,13 @@ describe('Update case trial sort tags', () => { ); await expect( - updateCaseTrialSortTagsInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }), + updateCaseTrialSortTagsInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('The Case entity was invalid'); }); }); diff --git a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.ts b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.ts index a09709c990f..23b0c1d04cb 100644 --- a/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.ts +++ b/shared/src/business/useCases/updateCaseTrialSortTagsInteractor.ts @@ -4,6 +4,7 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * updates the case trial sort tags @@ -15,9 +16,8 @@ import { export const updateCaseTrialSortTagsInteractor = async ( applicationContext: IApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - const caseToUpdate = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ @@ -29,9 +29,9 @@ export const updateCaseTrialSortTagsInteractor = async ( throw new NotFoundError(`Case ${docketNumber} was not found.`); } - const caseEntity = new Case(caseToUpdate, { authorizedUser: user }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); - if (!isAuthorized(user, ROLE_PERMISSIONS.UPDATE_CASE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPDATE_CASE)) { throw new UnauthorizedError('Unauthorized for update case'); } diff --git a/web-api/src/lambdas/cases/updateCaseTrialSortTagsLambda.ts b/web-api/src/lambdas/cases/updateCaseTrialSortTagsLambda.ts index f885413f266..1fd68b2e51f 100644 --- a/web-api/src/lambdas/cases/updateCaseTrialSortTagsLambda.ts +++ b/web-api/src/lambdas/cases/updateCaseTrialSortTagsLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateCaseTrialSortTagsInteractor } from '@shared/business/useCases/updateCaseTrialSortTagsInteractor'; /** * updates case trial sort tags @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateCaseTrialSortTagsLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCaseTrialSortTagsInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const updateCaseTrialSortTagsLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await updateCaseTrialSortTagsInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From b0efc8b8c3287a31d9d498c63c53d5c1d04e22e7 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:56:35 -0700 Subject: [PATCH 098/523] 10417: Remove getCurrentUser from shared --- .../useCases/updateContactInteractor.test.ts | 260 +++++++++++------- .../useCases/updateContactInteractor.ts | 34 ++- .../src/lambdas/cases/updateContactLambda.ts | 24 +- 3 files changed, 195 insertions(+), 123 deletions(-) diff --git a/shared/src/business/useCases/updateContactInteractor.test.ts b/shared/src/business/useCases/updateContactInteractor.test.ts index 8b23b9ebeee..8991b36f082 100644 --- a/shared/src/business/useCases/updateContactInteractor.test.ts +++ b/shared/src/business/useCases/updateContactInteractor.test.ts @@ -10,15 +10,14 @@ import { } from '../../test/mockCase'; import { MOCK_LOCK } from '../../test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '../entities/User'; import { applicationContext } from '../test/createTestApplicationContext'; import { fakeData } from '../test/getFakeFile'; import { getContactPrimary } from '../entities/cases/Case'; +import { mockPetitionerUser } from '@shared/test/mockAuthUsers'; import { updateContactInteractor } from './updateContactInteractor'; describe('updates the contact on a case', () => { let mockCase; - let mockUser; let mockCaseContactPrimary; let mockLock; beforeAll(() => { @@ -35,12 +34,7 @@ describe('updates the contact on a case', () => { }; mockCaseContactPrimary = mockCase.petitioners[0]; mockCaseContactPrimary.contactType = 'petitioner'; - - mockUser = new User({ - name: 'bob', - role: ROLES.petitioner, - userId: mockCaseContactPrimary.contactId, - }); + mockCaseContactPrimary.contactId = mockPetitionerUser.userId; applicationContext .getPersistenceGateway() @@ -54,8 +48,6 @@ describe('updates the contact on a case', () => { .getDocumentGenerators() .changeOfAddress.mockReturnValue(fakeData); - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - applicationContext .getChromiumBrowser() .newPage() @@ -82,19 +74,23 @@ describe('updates the contact on a case', () => { .getUseCaseHelpers() .countPagesInDocument.mockReturnValue(mockNumberOfPages); - const caseDetail = await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: '453 Electric Ave', - city: 'Philadelphia', - email: 'petitioner', - name: 'Bill Burr', - phone: '1234567890', - postalCode: '99999', - state: 'PA', + const caseDetail = await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: '453 Electric Ave', + city: 'Philadelphia', + email: 'petitioner', + name: 'Bill Burr', + phone: '1234567890', + postalCode: '99999', + state: 'PA', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); const updatedCase = applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -153,13 +149,17 @@ describe('updates the contact on a case', () => { ], }); - await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: '453 Electric Ave', + await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: '453 Electric Ave', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem, @@ -189,13 +189,17 @@ describe('updates the contact on a case', () => { ], }); - await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: '453 Electric Ave', + await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: '453 Electric Ave', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem, @@ -225,13 +229,17 @@ describe('updates the contact on a case', () => { ], }); - await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: '453 Electric Ave', + await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: '453 Electric Ave', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem, @@ -244,24 +252,30 @@ describe('updates the contact on a case', () => { .getCaseByDocketNumber.mockResolvedValue(null); await expect( - updateContactInteractor(applicationContext, { - contactInfo: {}, - docketNumber: mockCase.docketNumber, - }), + updateContactInteractor( + applicationContext, + { + contactInfo: {}, + docketNumber: mockCase.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Case 101-18 was not found.'); }); it('throws an error if the user making the request is not associated with the case', async () => { - mockUser = { - ...mockUser, - userId: 'de300c01-f6ff-4843-a72f-ee7cd2521237', - }; - await expect( - updateContactInteractor(applicationContext, { - contactInfo: mockCaseContactPrimary, - docketNumber: mockCase.docketNumber, - }), + updateContactInteractor( + applicationContext, + { + contactInfo: mockCaseContactPrimary, + docketNumber: mockCase.docketNumber, + }, + { + ...mockPetitionerUser, + userId: '4885d93e-ab94-48b9-be87-4cda005568d4', + }, + ), ).rejects.toThrow('Unauthorized for update case contact'); }); @@ -269,10 +283,14 @@ describe('updates the contact on a case', () => { mockCase = { ...MOCK_CASE_WITH_SECONDARY_OTHERS, petitioners: [] }; await expect( - updateContactInteractor(applicationContext, { - contactInfo: mockCaseContactPrimary, - docketNumber: mockCase.docketNumber, - }), + updateContactInteractor( + applicationContext, + { + contactInfo: mockCaseContactPrimary, + docketNumber: mockCase.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Error: Petitioner was not found on case 109-19.'); }); @@ -281,10 +299,14 @@ describe('updates the contact on a case', () => { .getUtilities() .getDocumentTypeForAddressChange.mockReturnValue(undefined); - await updateContactInteractor(applicationContext, { - contactInfo: mockCaseContactPrimary, - docketNumber: mockCase.docketNumber, - }); + await updateContactInteractor( + applicationContext, + { + contactInfo: mockCaseContactPrimary, + docketNumber: mockCase.docketNumber, + }, + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -302,16 +324,20 @@ describe('updates the contact on a case', () => { .getUtilities() .getDocumentTypeForAddressChange.mockReturnValue(undefined); - const caseDetail = await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: 'nothing', - city: 'Somewhere', - email: 'hello123@example.com', - name: 'Secondary Party Name Changed', + const caseDetail = await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: 'nothing', + city: 'Somewhere', + email: 'hello123@example.com', + name: 'Secondary Party Name Changed', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); const contactPrimary = getContactPrimary(caseDetail); @@ -338,13 +364,17 @@ describe('updates the contact on a case', () => { () => mockCaseWithSealedAddress, ); - await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: 'nothing 1', + await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: 'nothing 1', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -361,13 +391,17 @@ describe('updates the contact on a case', () => { }); it('should use original case caption to create case title when creating work item', async () => { - await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: '453 Electric Ave', + await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: '453 Electric Ave', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem.mock.calls[0][0] @@ -388,13 +422,17 @@ describe('updates the contact on a case', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockImplementation(() => mockClosedCase); - await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: '453 Electric Ave', + await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: '453 Electric Ave', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda, @@ -408,12 +446,16 @@ describe('updates the contact on a case', () => { .getUtilities() .getDocumentTypeForAddressChange.mockReturnValue(null); - await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, + await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations, @@ -424,13 +466,17 @@ describe('updates the contact on a case', () => { mockLock = MOCK_LOCK; await expect( - updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: '453 Electric Ave', + updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: '453 Electric Ave', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }), + mockPetitionerUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -439,13 +485,17 @@ describe('updates the contact on a case', () => { }); it('should acquire and remove the lock on the case', async () => { - await updateContactInteractor(applicationContext, { - contactInfo: { - ...mockCaseContactPrimary, - address1: '453 Electric Ave', + await updateContactInteractor( + applicationContext, + { + contactInfo: { + ...mockCaseContactPrimary, + address1: '453 Electric Ave', + }, + docketNumber: mockCase.docketNumber, }, - docketNumber: mockCase.docketNumber, - }); + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/updateContactInteractor.ts b/shared/src/business/useCases/updateContactInteractor.ts index 1f61c233259..07b9ee87d6b 100644 --- a/shared/src/business/useCases/updateContactInteractor.ts +++ b/shared/src/business/useCases/updateContactInteractor.ts @@ -5,7 +5,16 @@ import { SERVICE_INDICATOR_TYPES, } from '../entities/EntityConstants'; import { DocketEntry } from '../entities/DocketEntry'; -import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors'; +import { + NotFoundError, + UnauthorizedError, + UnidentifiedUserError, +} from '@web-api/errors/errors'; +import { ServerApplicationContext } from '@web-api/applicationContext'; +import { + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../entities/WorkItem'; import { addCoverToPdf } from '../../../../web-api/src/business/useCases/addCoverToPdf'; import { aggregatePartiesForService } from '../utilities/aggregatePartiesForService'; @@ -24,10 +33,15 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the updated case */ export const updateContact = async ( - applicationContext, + applicationContext: ServerApplicationContext, { contactInfo, docketNumber }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); + if (!isAuthUser(authorizedUser)) { + throw new UnidentifiedUserError( + 'Unable to confirm user is an authenticated user', + ); + } const editableFields = { address1: contactInfo.address1, @@ -56,7 +70,7 @@ export const updateContact = async ( { ...caseToUpdate, }, - { authorizedUser: user }, + { authorizedUser }, ); const oldCaseContact = cloneDeep( @@ -75,12 +89,12 @@ export const updateContact = async ( } const rawUpdatedCase = caseEntity.validate().toRawObject(); - caseEntity = new Case(rawUpdatedCase, { authorizedUser: user }); + caseEntity = new Case(rawUpdatedCase, { authorizedUser }); const updatedPetitioner = caseEntity.getPetitionerById(contactInfo.contactId); const userIsAssociated = caseEntity.isAssociatedUser({ - user, + user: authorizedUser, }); if (!userIsAssociated) { @@ -136,10 +150,10 @@ export const updateContact = async ( partyPrimary: true, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { authorizedUser: user, petitioners: caseEntity.petitioners }, + { authorizedUser, petitioners: caseEntity.petitioners }, ); - changeOfAddressDocketEntry.setFiledBy(user); + changeOfAddressDocketEntry.setFiledBy(authorizedUser); const servedParties = aggregatePartiesForService(caseEntity); @@ -170,8 +184,8 @@ export const updateContact = async ( docketNumber: caseEntity.docketNumber, docketNumberWithSuffix: caseEntity.docketNumberWithSuffix, section: DOCKET_SECTION, - sentBy: user.name, - sentByUserId: user.userId, + sentBy: authorizedUser.name, + sentByUserId: authorizedUser.userId, trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, diff --git a/web-api/src/lambdas/cases/updateContactLambda.ts b/web-api/src/lambdas/cases/updateContactLambda.ts index a518f2d59c9..86fb0bddba7 100644 --- a/web-api/src/lambdas/cases/updateContactLambda.ts +++ b/web-api/src/lambdas/cases/updateContactLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateContactInteractor } from '@shared/business/useCases/updateContactInteractor'; /** * used for updating a contact on a case @@ -6,11 +8,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateContactLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateContactInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const updateContactLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await updateContactInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From ebc24ba9d7c40df21b92b8509c02260930d2c8f4 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 14:57:26 -0700 Subject: [PATCH 099/523] 10417: Remove getCurrentUser from shared --- ...updateQcCompleteForTrialInteractor.test.ts | 60 ++++++++++--------- .../updateQcCompleteForTrialInteractor.ts | 17 +++--- .../cases/updateQcCompleteForTrialLambda.ts | 29 ++++++--- 3 files changed, 61 insertions(+), 45 deletions(-) diff --git a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.test.ts b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.test.ts index 13fd7ea518b..3c796b93246 100644 --- a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.test.ts +++ b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.test.ts @@ -1,18 +1,19 @@ import { MOCK_CASE } from '../../test/mockCase'; import { MOCK_LOCK } from '../../test/mockLock'; -import { ROLES } from '../entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { updateQcCompleteForTrialInteractor } from './updateQcCompleteForTrialInteractor'; describe('updateQcCompleteForTrialInteractor', () => { - let user; let mockLock; beforeAll(() => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => mockLock); - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext .getPersistenceGateway() .updateCase.mockImplementation(({ caseToUpdate }) => @@ -28,26 +29,20 @@ describe('updateQcCompleteForTrialInteractor', () => { }); it('should throw an error if the user is unauthorized to update a trial session', async () => { - user = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( - updateQcCompleteForTrialInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - qcCompleteForTrial: true, - trialSessionId: '10aa100f-0330-442b-8423-b01690c76e3f', - }), + updateQcCompleteForTrialInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + qcCompleteForTrial: true, + trialSessionId: '10aa100f-0330-442b-8423-b01690c76e3f', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for trial session QC complete'); }); it('should call updateCase with the updated qcCompleteForTrial value and return the updated case', async () => { - user = { - role: ROLES.petitionsClerk, - userId: 'petitionsClerk', - }; - const result = await updateQcCompleteForTrialInteractor( applicationContext, { @@ -55,6 +50,7 @@ describe('updateQcCompleteForTrialInteractor', () => { qcCompleteForTrial: true, trialSessionId: '10aa100f-0330-442b-8423-b01690c76e3f', }, + mockPetitionsClerkUser, ); expect(result.qcCompleteForTrial).toEqual({ '10aa100f-0330-442b-8423-b01690c76e3f': true, @@ -65,11 +61,15 @@ describe('updateQcCompleteForTrialInteractor', () => { mockLock = MOCK_LOCK; await expect( - updateQcCompleteForTrialInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - qcCompleteForTrial: true, - trialSessionId: '10aa100f-0330-442b-8423-b01690c76e3f', - }), + updateQcCompleteForTrialInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + qcCompleteForTrial: true, + trialSessionId: '10aa100f-0330-442b-8423-b01690c76e3f', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -78,11 +78,15 @@ describe('updateQcCompleteForTrialInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await updateQcCompleteForTrialInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - qcCompleteForTrial: true, - trialSessionId: '10aa100f-0330-442b-8423-b01690c76e3f', - }); + await updateQcCompleteForTrialInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + qcCompleteForTrial: true, + trialSessionId: '10aa100f-0330-442b-8423-b01690c76e3f', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts index 59108d5693b..ced92da22e8 100644 --- a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts +++ b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts @@ -3,7 +3,9 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -18,7 +20,7 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; */ export const updateQcCompleteForTrial = async ( - applicationContext: IApplicationContext, + applicationContext: ServerApplicationContext, { docketNumber, qcCompleteForTrial, @@ -28,10 +30,11 @@ export const updateQcCompleteForTrial = async ( qcCompleteForTrial: boolean; trialSessionId: string; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSION_QC_COMPLETE)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSION_QC_COMPLETE) + ) { throw new UnauthorizedError('Unauthorized for trial session QC complete'); } @@ -39,7 +42,7 @@ export const updateQcCompleteForTrial = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { authorizedUser: user }); + const newCase = new Case(oldCase, { authorizedUser }); newCase.setQcCompleteForTrial({ qcCompleteForTrial, trialSessionId }); @@ -50,9 +53,7 @@ export const updateQcCompleteForTrial = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const updateQcCompleteForTrialInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/updateQcCompleteForTrialLambda.ts b/web-api/src/lambdas/cases/updateQcCompleteForTrialLambda.ts index 508741fd07c..ef179053d86 100644 --- a/web-api/src/lambdas/cases/updateQcCompleteForTrialLambda.ts +++ b/web-api/src/lambdas/cases/updateQcCompleteForTrialLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateQcCompleteForTrialInteractor } from '@shared/business/useCases/updateQcCompleteForTrialInteractor'; /** * used for updating whether a case is qc complete for trial @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateQcCompleteForTrialLambda = event => - genericHandler(event, async ({ applicationContext }): Promise => { - return await applicationContext - .getUseCases() - .updateQcCompleteForTrialInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const updateQcCompleteForTrialLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }): Promise => { + return await updateQcCompleteForTrialInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 50bfdb5037542a333e245f3b362775b72d81b6fb Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 4 Jul 2024 15:09:57 -0700 Subject: [PATCH 100/523] 10417: Remove getCurrentUser from shared --- .../validateCaseDetailInteractor.test.ts | 357 +++++++++--------- .../useCases/validateCaseDetailInteractor.ts | 7 +- .../actions/validateCaseDetailAction.test.ts | 2 +- .../actions/validateCaseDetailAction.ts | 10 +- .../actions/validateCaseDetailsAction.test.ts | 12 +- .../actions/validateCaseDetailsAction.ts | 20 +- .../validateNoteOnCaseDetailAction.test.ts | 2 +- .../actions/validateNoteOnCaseDetailAction.ts | 10 +- 8 files changed, 225 insertions(+), 195 deletions(-) diff --git a/shared/src/business/useCases/validateCaseDetailInteractor.test.ts b/shared/src/business/useCases/validateCaseDetailInteractor.test.ts index 73ce12d6753..a32252835d3 100644 --- a/shared/src/business/useCases/validateCaseDetailInteractor.test.ts +++ b/shared/src/business/useCases/validateCaseDetailInteractor.test.ts @@ -5,8 +5,8 @@ import { PARTY_TYPES, ROLES, } from '../entities/EntityConstants'; -import { MOCK_USERS } from '../../test/mockUsers'; import { applicationContext } from '../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { validateCaseDetailInteractor } from './validateCaseDetailInteractor'; describe('validate case detail', () => { @@ -23,16 +23,13 @@ describe('validate case detail', () => { }, ]; - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue( - MOCK_USERS['a7d90c05-f6cd-442c-a168-202db587f16f'], - ); - }); - it('returns the expected errors object on an empty case', () => { - const errors = validateCaseDetailInteractor(applicationContext, { - caseDetail: {}, - }); + const errors = validateCaseDetailInteractor( + { + caseDetail: {}, + }, + mockDocketClerkUser, + ); expect(errors).toBeTruthy(); expect(errors).toMatchObject({ @@ -41,11 +38,14 @@ describe('validate case detail', () => { }); it('does not return an error if that field is valid', () => { - const errors = validateCaseDetailInteractor(applicationContext, { - caseDetail: { - caseCaption: 'A case caption', + const errors = validateCaseDetailInteractor( + { + caseDetail: { + caseCaption: 'A case caption', + }, }, - }); + mockDocketClerkUser, + ); expect(errors).toBeTruthy(); expect(errors).toMatchObject({ @@ -54,186 +54,207 @@ describe('validate case detail', () => { }); it('returns no errors if the case validates', () => { - const errors = validateCaseDetailInteractor(applicationContext, { - caseDetail: { - caseCaption: 'Caption', - caseType: CASE_TYPES_MAP.other, - docketEntries: [ - { - createdAt: '2018-11-21T20:49:28.192Z', - docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - docketNumber: '101-18', - documentType: 'Petition', - eventCode: 'P', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - role: ROLES.petitioner, - userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', - }, - { - createdAt: '2018-11-21T20:49:28.192Z', - docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - docketNumber: '101-18', - documentType: 'Petition', - eventCode: 'P', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', - }, - ], - docketNumber: '101-18', - filingType: 'Myself', - hasVerifiedIrsNotice: true, - irsNoticeDate: applicationContext.getUtilities().createISODateString(), - partyType: PARTY_TYPES.petitioner, - petitioners, - preferredTrialCity: 'Fresno, California', - procedureType: 'Regular', - signature: true, - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + const errors = validateCaseDetailInteractor( + { + caseDetail: { + caseCaption: 'Caption', + caseType: CASE_TYPES_MAP.other, + docketEntries: [ + { + createdAt: '2018-11-21T20:49:28.192Z', + docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + docketNumber: '101-18', + documentType: 'Petition', + eventCode: 'P', + filedBy: 'Test Petitioner', + filedByRole: ROLES.petitioner, + role: ROLES.petitioner, + userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', + }, + { + createdAt: '2018-11-21T20:49:28.192Z', + docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + docketNumber: '101-18', + documentType: 'Petition', + eventCode: 'P', + filedBy: 'Test Petitioner', + filedByRole: ROLES.petitioner, + userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', + }, + ], + docketNumber: '101-18', + filingType: 'Myself', + hasVerifiedIrsNotice: true, + irsNoticeDate: applicationContext + .getUtilities() + .createISODateString(), + partyType: PARTY_TYPES.petitioner, + petitioners, + preferredTrialCity: 'Fresno, California', + procedureType: 'Regular', + signature: true, + userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + }, }, - }); + mockDocketClerkUser, + ); expect(errors).toEqual(null); }); it('returns the expected errors when passed bad date objects', () => { - const errors: any = validateCaseDetailInteractor(applicationContext, { - caseDetail: { - hasVerifiedIrsNotice: true, - irsNoticeDate: 'aa', + const errors: any = validateCaseDetailInteractor( + { + caseDetail: { + hasVerifiedIrsNotice: true, + irsNoticeDate: 'aa', + }, }, - }); + mockDocketClerkUser, + ); expect(errors).toBeTruthy(); expect(errors.irsNoticeDate).toBeTruthy(); }); it('returns no errors on valid amounts and years', () => { - const errors = validateCaseDetailInteractor(applicationContext, { - caseDetail: { - caseCaption: 'Caption', - caseType: CASE_TYPES_MAP.other, - docketEntries: [ - { - createdAt: '2018-11-21T20:49:28.192Z', - docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - docketNumber: '101-18', - documentType: 'Petition', - eventCode: 'P', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', - }, - { - createdAt: '2018-11-21T20:49:28.192Z', - docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - docketNumber: '101-18', - documentType: 'Petition', - eventCode: 'P', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', - }, - ], - docketNumber: '101-18', - filingType: CASE_TYPES_MAP.other, - hasVerifiedIrsNotice: true, - irsNoticeDate: applicationContext.getUtilities().createISODateString(), - partyType: PARTY_TYPES.petitioner, - petitioners, - preferredTrialCity: 'Fresno, California', - procedureType: 'Regular', - signature: true, - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + const errors = validateCaseDetailInteractor( + { + caseDetail: { + caseCaption: 'Caption', + caseType: CASE_TYPES_MAP.other, + docketEntries: [ + { + createdAt: '2018-11-21T20:49:28.192Z', + docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + docketNumber: '101-18', + documentType: 'Petition', + eventCode: 'P', + filedBy: 'Test Petitioner', + filedByRole: ROLES.petitioner, + userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', + }, + { + createdAt: '2018-11-21T20:49:28.192Z', + docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + docketNumber: '101-18', + documentType: 'Petition', + eventCode: 'P', + filedBy: 'Test Petitioner', + filedByRole: ROLES.petitioner, + userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', + }, + ], + docketNumber: '101-18', + filingType: CASE_TYPES_MAP.other, + hasVerifiedIrsNotice: true, + irsNoticeDate: applicationContext + .getUtilities() + .createISODateString(), + partyType: PARTY_TYPES.petitioner, + petitioners, + preferredTrialCity: 'Fresno, California', + procedureType: 'Regular', + signature: true, + userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + }, }, - }); + mockDocketClerkUser, + ); expect(errors).toEqual(null); }); it('returns no errors on null irsNoticeDate', () => { - const errors = validateCaseDetailInteractor(applicationContext, { - caseDetail: { - caseCaption: 'Caption', - caseType: CASE_TYPES_MAP.other, - docketEntries: [ - { - createdAt: '2018-11-21T20:49:28.192Z', - docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - docketNumber: '101-18', - documentType: 'Petition', - eventCode: 'P', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', - }, - { - createdAt: '2018-11-21T20:49:28.192Z', - docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - docketNumber: '101-18', - documentType: 'Petition', - eventCode: 'P', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', - }, - ], - docketNumber: '101-18', - filingType: CASE_TYPES_MAP.other, - hasVerifiedIrsNotice: false, - irsNoticeDate: null, - partyType: PARTY_TYPES.petitioner, - petitioners, - preferredTrialCity: 'Fresno, California', - procedureType: 'Regular', - signature: true, - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + const errors = validateCaseDetailInteractor( + { + caseDetail: { + caseCaption: 'Caption', + caseType: CASE_TYPES_MAP.other, + docketEntries: [ + { + createdAt: '2018-11-21T20:49:28.192Z', + docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + docketNumber: '101-18', + documentType: 'Petition', + eventCode: 'P', + filedBy: 'Test Petitioner', + filedByRole: ROLES.petitioner, + userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', + }, + { + createdAt: '2018-11-21T20:49:28.192Z', + docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + docketNumber: '101-18', + documentType: 'Petition', + eventCode: 'P', + filedBy: 'Test Petitioner', + filedByRole: ROLES.petitioner, + userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', + }, + ], + docketNumber: '101-18', + filingType: CASE_TYPES_MAP.other, + hasVerifiedIrsNotice: false, + irsNoticeDate: null, + partyType: PARTY_TYPES.petitioner, + petitioners, + preferredTrialCity: 'Fresno, California', + procedureType: 'Regular', + signature: true, + userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + }, }, - }); + mockDocketClerkUser, + ); expect(errors).toEqual(null); }); it('should validate a new Case entity when useCaseEntity is true', () => { - const errors = validateCaseDetailInteractor(applicationContext, { - caseDetail: { - caseCaption: 'Caption', - caseType: CASE_TYPES_MAP.other, - docketEntries: [ - { - createdAt: '2018-11-21T20:49:28.192Z', - docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - docketNumber: '101-18', - documentType: 'Petition', - eventCode: 'P', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', - }, - { - createdAt: '2018-11-21T20:49:28.192Z', - docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - docketNumber: '101-18', - documentType: 'Petition', - eventCode: 'P', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', - }, - ], - docketNumber: '101-18', - filingType: CASE_TYPES_MAP.other, - irsNoticeDate: applicationContext.getUtilities().createISODateString(), - partyType: PARTY_TYPES.petitioner, - petitioners, - preferredTrialCity: 'Fresno, California', - procedureType: 'Regular', - signature: true, - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + const errors = validateCaseDetailInteractor( + { + caseDetail: { + caseCaption: 'Caption', + caseType: CASE_TYPES_MAP.other, + docketEntries: [ + { + createdAt: '2018-11-21T20:49:28.192Z', + docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + docketNumber: '101-18', + documentType: 'Petition', + eventCode: 'P', + filedBy: 'Test Petitioner', + filedByRole: ROLES.petitioner, + userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', + }, + { + createdAt: '2018-11-21T20:49:28.192Z', + docketEntryId: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + docketNumber: '101-18', + documentType: 'Petition', + eventCode: 'P', + filedBy: 'Test Petitioner', + filedByRole: ROLES.petitioner, + userId: '9271f5ca-e7c9-40e8-b465-e970e22934e8', + }, + ], + docketNumber: '101-18', + filingType: CASE_TYPES_MAP.other, + irsNoticeDate: applicationContext + .getUtilities() + .createISODateString(), + partyType: PARTY_TYPES.petitioner, + petitioners, + preferredTrialCity: 'Fresno, California', + procedureType: 'Regular', + signature: true, + userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + }, + useCaseEntity: true, }, - useCaseEntity: true, - }); + mockDocketClerkUser, + ); expect(errors).toEqual(null); }); diff --git a/shared/src/business/useCases/validateCaseDetailInteractor.ts b/shared/src/business/useCases/validateCaseDetailInteractor.ts index 351d3de8cd9..8ab83f2a2f5 100644 --- a/shared/src/business/useCases/validateCaseDetailInteractor.ts +++ b/shared/src/business/useCases/validateCaseDetailInteractor.ts @@ -1,5 +1,6 @@ import { Case } from '../entities/cases/Case'; import { CaseQC } from '../entities/cases/CaseQC'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * validateCaseDetailInteractor @@ -10,18 +11,18 @@ import { CaseQC } from '../entities/cases/CaseQC'; * @returns {object} errors (null if no errors) */ export const validateCaseDetailInteractor = ( - applicationContext: IApplicationContext, { caseDetail, useCaseEntity = false, }: { caseDetail: any; useCaseEntity?: boolean }, + authorizedUser: UnknownAuthUser, ): Record | null => { if (useCaseEntity) { return new Case(caseDetail, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }).getFormattedValidationErrors(); } return new CaseQC(caseDetail, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }).getFormattedValidationErrors(); }; diff --git a/web-client/src/presenter/actions/validateCaseDetailAction.test.ts b/web-client/src/presenter/actions/validateCaseDetailAction.test.ts index f45747080d8..2e07ad00759 100644 --- a/web-client/src/presenter/actions/validateCaseDetailAction.test.ts +++ b/web-client/src/presenter/actions/validateCaseDetailAction.test.ts @@ -41,7 +41,7 @@ describe('validateCaseDetail', () => { }); expect( applicationContext.getUseCases().validateCaseDetailInteractor.mock - .calls[0][1].caseDetail, + .calls[0][0].caseDetail, ).toMatchObject({ docketNumber: '123-45', irsNoticeDate: '2009-10-13', diff --git a/web-client/src/presenter/actions/validateCaseDetailAction.ts b/web-client/src/presenter/actions/validateCaseDetailAction.ts index 245cef41aaa..0599d5a66ba 100644 --- a/web-client/src/presenter/actions/validateCaseDetailAction.ts +++ b/web-client/src/presenter/actions/validateCaseDetailAction.ts @@ -11,6 +11,7 @@ export const validateCaseDetailAction = ({ store, }: ActionProps) => { const form = get(state.form); + const user = get(state.user); let errors; if (form.isPaper) { @@ -20,11 +21,12 @@ export const validateCaseDetailAction = ({ petition: form, }); } else { - errors = applicationContext - .getUseCases() - .validateCaseDetailInteractor(applicationContext, { + errors = applicationContext.getUseCases().validateCaseDetailInteractor( + { caseDetail: form, - }); + }, + user, + ); } errors = aggregatePetitionerErrors({ errors }); diff --git a/web-client/src/presenter/actions/validateCaseDetailsAction.test.ts b/web-client/src/presenter/actions/validateCaseDetailsAction.test.ts index 41dc0045f0a..6e9a2273905 100644 --- a/web-client/src/presenter/actions/validateCaseDetailsAction.test.ts +++ b/web-client/src/presenter/actions/validateCaseDetailsAction.test.ts @@ -43,7 +43,7 @@ describe('validateCaseDetailsAction', () => { expect( applicationContext.getUseCases().validateCaseDetailInteractor.mock - .calls[0][1].caseDetail, + .calls[0][0].caseDetail, ).toMatchObject({ petitionPaymentDate: '2019-09-06T04:00:00.000Z', petitionPaymentMethod: 'check', @@ -67,7 +67,7 @@ describe('validateCaseDetailsAction', () => { expect( applicationContext.getUseCases().validateCaseDetailInteractor.mock - .calls[0][1].caseDetail, + .calls[0][0].caseDetail, ).toMatchObject({ petitionPaymentStatus: PAYMENT_STATUS.UNPAID, }); @@ -90,7 +90,7 @@ describe('validateCaseDetailsAction', () => { expect( applicationContext.getUseCases().validateCaseDetailInteractor.mock - .calls[0][1].caseDetail, + .calls[0][0].caseDetail, ).toMatchObject({ petitionPaymentStatus: PAYMENT_STATUS.WAIVED, petitionPaymentWaivedDate: '2001-01-01T05:00:00.000Z', @@ -113,7 +113,7 @@ describe('validateCaseDetailsAction', () => { expect( applicationContext.getUseCases().validateCaseDetailInteractor.mock - .calls[0][1].caseDetail, + .calls[0][0].caseDetail, ).toMatchObject({ irsNoticeDate: '2001-01-01T05:00:00.000Z', }); @@ -133,7 +133,7 @@ describe('validateCaseDetailsAction', () => { expect( applicationContext.getUseCases().validateCaseDetailInteractor.mock - .calls[0][1].caseDetail, + .calls[0][0].caseDetail, ).toMatchObject({ preferredTrialCity: null, }); @@ -153,7 +153,7 @@ describe('validateCaseDetailsAction', () => { expect( applicationContext.getUseCases().validateCaseDetailInteractor.mock - .calls[0][1].caseDetail, + .calls[0][0].caseDetail, ).toMatchObject({ preferredTrialCity: 'Fresno, California', }); diff --git a/web-client/src/presenter/actions/validateCaseDetailsAction.ts b/web-client/src/presenter/actions/validateCaseDetailsAction.ts index 36db4e3f895..65cf0ad457b 100644 --- a/web-client/src/presenter/actions/validateCaseDetailsAction.ts +++ b/web-client/src/presenter/actions/validateCaseDetailsAction.ts @@ -9,18 +9,22 @@ export const validateCaseDetailsAction = async ({ }: ActionProps) => { const caseDetail = get(state.caseDetail); const form = get(state.form); + const user = get(state.user); let errors = await applicationContext .getUseCases() - .validateCaseDetailInteractor(applicationContext, { - caseDetail: { - ...caseDetail, - ...form, - preferredTrialCity: form.preferredTrialCity - ? form.preferredTrialCity - : null, + .validateCaseDetailInteractor( + { + caseDetail: { + ...caseDetail, + ...form, + preferredTrialCity: form.preferredTrialCity + ? form.preferredTrialCity + : null, + }, }, - }); + user, + ); if (!errors) { return path.success(); diff --git a/web-client/src/presenter/actions/validateNoteOnCaseDetailAction.test.ts b/web-client/src/presenter/actions/validateNoteOnCaseDetailAction.test.ts index c1a0def0c8f..5d08f3d8b33 100644 --- a/web-client/src/presenter/actions/validateNoteOnCaseDetailAction.test.ts +++ b/web-client/src/presenter/actions/validateNoteOnCaseDetailAction.test.ts @@ -78,7 +78,7 @@ describe('validateNoteOnCaseDetailAction', () => { expect( applicationContext.getUseCases().validateCaseDetailInteractor.mock - .calls[0][1], + .calls[0][0], ).toMatchObject({ useCaseEntity: true }); }); }); diff --git a/web-client/src/presenter/actions/validateNoteOnCaseDetailAction.ts b/web-client/src/presenter/actions/validateNoteOnCaseDetailAction.ts index e485da6b127..9dfd29d661b 100644 --- a/web-client/src/presenter/actions/validateNoteOnCaseDetailAction.ts +++ b/web-client/src/presenter/actions/validateNoteOnCaseDetailAction.ts @@ -15,13 +15,15 @@ export const validateNoteOnCaseDetailAction = ({ }: ActionProps) => { const caseDetail = get(state.caseDetail); const note = get(state.modal.notes); + const user = get(state.user); - const errors = applicationContext - .getUseCases() - .validateCaseDetailInteractor(applicationContext, { + const errors = applicationContext.getUseCases().validateCaseDetailInteractor( + { caseDetail: { ...caseDetail, caseNote: note }, useCaseEntity: true, - }); + }, + user, + ); if (!errors) { return path.success(); From bb29e3c81a07050e9a6c1ef75715eb7116b3ccd8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 08:54:40 -0700 Subject: [PATCH 101/523] 10417: Remove getCurrentUser from shared --- .../useCases/validatePetitionFromPaperInteractor.test.ts | 9 +++++---- .../useCases/validatePetitionFromPaperInteractor.ts | 5 +++-- .../src/presenter/actions/validateCaseDetailAction.ts | 2 +- .../presenter/actions/validatePetitionFromPaperAction.ts | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/shared/src/business/useCases/validatePetitionFromPaperInteractor.test.ts b/shared/src/business/useCases/validatePetitionFromPaperInteractor.test.ts index 34fe0518615..c765e742cae 100644 --- a/shared/src/business/useCases/validatePetitionFromPaperInteractor.test.ts +++ b/shared/src/business/useCases/validatePetitionFromPaperInteractor.test.ts @@ -5,12 +5,13 @@ import { PARTY_TYPES, PAYMENT_STATUS, } from '../entities/EntityConstants'; -import { applicationContext } from '../test/createTestApplicationContext'; +import { createISODateString } from '@shared/business/utilities/DateHandler'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { validatePetitionFromPaperInteractor } from './validatePetitionFromPaperInteractor'; describe('validate petition from paper', () => { it('returns the expected errors object on an empty petition', () => { - const errors = validatePetitionFromPaperInteractor(applicationContext, { + const errors = validatePetitionFromPaperInteractor(mockDocketClerkUser, { petition: {}, }); @@ -28,7 +29,7 @@ describe('validate petition from paper', () => { }); it('returns null if no errors exist', () => { - const errors = validatePetitionFromPaperInteractor(applicationContext, { + const errors = validatePetitionFromPaperInteractor(mockDocketClerkUser, { petition: { archivedDocketEntries: [], caseCaption: 'testing', @@ -54,7 +55,7 @@ describe('validate petition from paper', () => { }, ], procedureType: 'Regular', - receivedAt: applicationContext.getUtilities().createISODateString(), + receivedAt: createISODateString(), }, }); diff --git a/shared/src/business/useCases/validatePetitionFromPaperInteractor.ts b/shared/src/business/useCases/validatePetitionFromPaperInteractor.ts index 22c73461d13..b58e106123b 100644 --- a/shared/src/business/useCases/validatePetitionFromPaperInteractor.ts +++ b/shared/src/business/useCases/validatePetitionFromPaperInteractor.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { PaperPetition } from '../entities/cases/PaperPetition'; /** @@ -9,11 +10,11 @@ import { PaperPetition } from '../entities/cases/PaperPetition'; * @returns {object} errors (null if no errors) */ export const validatePetitionFromPaperInteractor = ( - applicationContext: IApplicationContext, + authorizedUser: AuthUser, { petition }: { petition: any }, ) => { const errors = new PaperPetition(petition, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }).getFormattedValidationErrors(); return errors || null; }; diff --git a/web-client/src/presenter/actions/validateCaseDetailAction.ts b/web-client/src/presenter/actions/validateCaseDetailAction.ts index 0599d5a66ba..c892d57e846 100644 --- a/web-client/src/presenter/actions/validateCaseDetailAction.ts +++ b/web-client/src/presenter/actions/validateCaseDetailAction.ts @@ -17,7 +17,7 @@ export const validateCaseDetailAction = ({ if (form.isPaper) { errors = applicationContext .getUseCases() - .validatePetitionFromPaperInteractor(applicationContext, { + .validatePetitionFromPaperInteractor(user, { petition: form, }); } else { diff --git a/web-client/src/presenter/actions/validatePetitionFromPaperAction.ts b/web-client/src/presenter/actions/validatePetitionFromPaperAction.ts index 6ce49fa0e7c..bdc68140fa0 100644 --- a/web-client/src/presenter/actions/validatePetitionFromPaperAction.ts +++ b/web-client/src/presenter/actions/validatePetitionFromPaperAction.ts @@ -74,10 +74,11 @@ export const validatePetitionFromPaperAction = ({ path, }: ActionProps) => { const form = get(state.form); + const user = get(state.user); let errors = applicationContext .getUseCases() - .validatePetitionFromPaperInteractor(applicationContext, { + .validatePetitionFromPaperInteractor(user, { petition: form, }); From f7a3e984bcbd40cb7cbdf63880057735b50cd614 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 08:58:13 -0700 Subject: [PATCH 102/523] 10417: Remove getCurrentUser from shared --- .../caseConsolidation/canConsolidateInteractor.test.ts | 6 +++--- .../useCases/caseConsolidation/canConsolidateInteractor.ts | 5 +++-- .../actions/CaseConsolidation/canConsolidateAction.ts | 6 +++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.test.ts b/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.test.ts index 6efc884d759..b1f381eaf99 100644 --- a/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.test.ts +++ b/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.test.ts @@ -1,7 +1,7 @@ import { CASE_STATUS_TYPES } from '../../entities/EntityConstants'; import { MOCK_CASE } from '../../../test/mockCase'; -import { applicationContext } from '../../test/createTestApplicationContext'; import { canConsolidateInteractor } from './canConsolidateInteractor'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('canConsolidateInteractor', () => { let currentCase; @@ -25,7 +25,7 @@ describe('canConsolidateInteractor', () => { }); it('should return true when cases are consolidatable', () => { - const result = canConsolidateInteractor(applicationContext, { + const result = canConsolidateInteractor(mockDocketClerkUser, { caseToConsolidate, currentCase, }); @@ -36,7 +36,7 @@ describe('canConsolidateInteractor', () => { it('should return false when cases are not consolidatable', () => { caseToConsolidate.status = CASE_STATUS_TYPES.closed; - const result = canConsolidateInteractor(applicationContext, { + const result = canConsolidateInteractor(mockDocketClerkUser, { caseToConsolidate, currentCase, }); diff --git a/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.ts b/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.ts index 740292d4773..094d69395a0 100644 --- a/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.ts +++ b/shared/src/business/useCases/caseConsolidation/canConsolidateInteractor.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../entities/cases/Case'; /** @@ -9,14 +10,14 @@ import { Case } from '../../entities/cases/Case'; * @returns {object} whether or not the cases can be consolidated with the reason */ export const canConsolidateInteractor = ( - applicationContext: IApplicationContext, + authorizedUser: AuthUser, { caseToConsolidate, currentCase, }: { caseToConsolidate: Case; currentCase: Case }, ) => { const caseEntity = new Case(currentCase, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const results = caseEntity.getConsolidationStatus({ diff --git a/web-client/src/presenter/actions/CaseConsolidation/canConsolidateAction.ts b/web-client/src/presenter/actions/CaseConsolidation/canConsolidateAction.ts index e848879162d..56a5ce9f0ac 100644 --- a/web-client/src/presenter/actions/CaseConsolidation/canConsolidateAction.ts +++ b/web-client/src/presenter/actions/CaseConsolidation/canConsolidateAction.ts @@ -1,3 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + /** * check to see if we can consolidate cases * @@ -9,10 +11,12 @@ */ export const canConsolidateAction = ({ applicationContext, + get, path, props, }: ActionProps) => { const { caseDetail, caseToConsolidate, confirmSelection } = props; + const user = get(state.user); if (!confirmSelection) { return path.error({ @@ -22,7 +26,7 @@ export const canConsolidateAction = ({ const results = applicationContext .getUseCases() - .canConsolidateInteractor(applicationContext, { + .canConsolidateInteractor(user, { caseToConsolidate, currentCase: caseDetail, }); From 696f5c08a966148139a1227fb28e2c2dd9c1419d Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 09:43:42 -0700 Subject: [PATCH 103/523] 10417: Remove getCurrentUser from shared --- ...adCorrespondenceDocumentInteractor.test.ts | 36 +++++++++---------- .../uploadCorrespondenceDocumentInteractor.ts | 6 ++-- .../uploadCorrespondenceFileAction.ts | 11 ++++-- .../overwriteCorrespondenceFileAction.ts | 13 ++++--- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/shared/src/business/useCases/correspondence/uploadCorrespondenceDocumentInteractor.test.ts b/shared/src/business/useCases/correspondence/uploadCorrespondenceDocumentInteractor.test.ts index ce10b055a83..7afa739ae33 100644 --- a/shared/src/business/useCases/correspondence/uploadCorrespondenceDocumentInteractor.test.ts +++ b/shared/src/business/useCases/correspondence/uploadCorrespondenceDocumentInteractor.test.ts @@ -1,35 +1,33 @@ -import { ROLES } from '../../entities/EntityConstants'; import { applicationContext } from '../../test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { uploadCorrespondenceDocumentInteractor } from './uploadCorrespondenceDocumentInteractor'; describe('uploadCorrespondenceDocumentInteractor', () => { - let mockUser; const mockKey = 'cf105788-5d34-4451-aa8d-dfd9a851b675'; const mockDocumentFile = 'bananas'; - const mockUserFixture = { - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '2474e5c0-f741-4120-befa-b77378ac8bf0', - }; - - beforeEach(() => { - mockUser = mockUserFixture; - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - }); it('should throw an Unauthorized error if the user role does not have the CASE_CORRESPONDENCE permission', async () => { - mockUser = { ...mockUser, role: ROLES.petitioner }; - await expect( - uploadCorrespondenceDocumentInteractor(applicationContext, {} as any), + uploadCorrespondenceDocumentInteractor( + applicationContext, + {} as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should upload the document file to the specified correspondence document', async () => { - await uploadCorrespondenceDocumentInteractor(applicationContext, { - documentFile: mockDocumentFile, - keyToOverwrite: mockKey, - }); + await uploadCorrespondenceDocumentInteractor( + applicationContext, + { + documentFile: mockDocumentFile, + keyToOverwrite: mockKey, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().uploadDocumentFromClient.mock diff --git a/shared/src/business/useCases/correspondence/uploadCorrespondenceDocumentInteractor.ts b/shared/src/business/useCases/correspondence/uploadCorrespondenceDocumentInteractor.ts index 9033ed8ac54..9c92f227508 100644 --- a/shared/src/business/useCases/correspondence/uploadCorrespondenceDocumentInteractor.ts +++ b/shared/src/business/useCases/correspondence/uploadCorrespondenceDocumentInteractor.ts @@ -4,6 +4,7 @@ import { isAuthorized, } from '../../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const uploadCorrespondenceDocumentInteractor = async ( applicationContext: ClientApplicationContext, @@ -11,10 +12,9 @@ export const uploadCorrespondenceDocumentInteractor = async ( documentFile, keyToOverwrite, }: { documentFile: string; keyToOverwrite: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_CORRESPONDENCE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_CORRESPONDENCE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-client/src/presenter/actions/CorrespondenceDocument/uploadCorrespondenceFileAction.ts b/web-client/src/presenter/actions/CorrespondenceDocument/uploadCorrespondenceFileAction.ts index ffe5d005941..3c503a3fac9 100644 --- a/web-client/src/presenter/actions/CorrespondenceDocument/uploadCorrespondenceFileAction.ts +++ b/web-client/src/presenter/actions/CorrespondenceDocument/uploadCorrespondenceFileAction.ts @@ -14,13 +14,18 @@ export const uploadCorrespondenceFileAction = async ({ path, }: ActionProps) => { const { primaryDocumentFile } = get(state.form); + const user = get(state.user); try { const primaryDocumentFileId = await applicationContext .getUseCases() - .uploadCorrespondenceDocumentInteractor(applicationContext, { - documentFile: primaryDocumentFile, - }); + .uploadCorrespondenceDocumentInteractor( + applicationContext, + { + documentFile: primaryDocumentFile, + }, + user, + ); return path.success({ primaryDocumentFileId, diff --git a/web-client/src/presenter/actions/CourtIssuedOrder/overwriteCorrespondenceFileAction.ts b/web-client/src/presenter/actions/CourtIssuedOrder/overwriteCorrespondenceFileAction.ts index 8a832c9f275..514d36f4553 100644 --- a/web-client/src/presenter/actions/CourtIssuedOrder/overwriteCorrespondenceFileAction.ts +++ b/web-client/src/presenter/actions/CourtIssuedOrder/overwriteCorrespondenceFileAction.ts @@ -15,14 +15,19 @@ export const overwriteCorrespondenceFileAction = async ({ }: ActionProps) => { const { primaryDocumentFile } = get(state.form); const docketEntryId = get(state.docketEntryId); + const user = get(state.user); try { const primaryDocumentFileId = await applicationContext .getUseCases() - .uploadCorrespondenceDocumentInteractor(applicationContext, { - documentFile: primaryDocumentFile, - keyToOverwrite: docketEntryId, - }); + .uploadCorrespondenceDocumentInteractor( + applicationContext, + { + documentFile: primaryDocumentFile, + keyToOverwrite: docketEntryId, + }, + user, + ); return path.success({ primaryDocumentFileId, From 753c6c3bc894e294e67a975663633703c72eb844 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 10:02:14 -0700 Subject: [PATCH 104/523] 10417: Remove getCurrentUser from shared --- .../business/entities/authUser/AuthUser.ts | 24 ++--- .../uploadDocumentInteractor.test.ts | 87 ++++++++++--------- .../uploadDocumentInteractor.ts | 10 +-- .../uploadDocketEntryFileAction.ts | 15 ++-- 4 files changed, 75 insertions(+), 61 deletions(-) diff --git a/shared/src/business/entities/authUser/AuthUser.ts b/shared/src/business/entities/authUser/AuthUser.ts index c2afb07f451..a03007a774e 100644 --- a/shared/src/business/entities/authUser/AuthUser.ts +++ b/shared/src/business/entities/authUser/AuthUser.ts @@ -11,17 +11,19 @@ export type AuthUser = { export type UnknownAuthUser = AuthUser | undefined; export function isAuthUser(user): user is AuthUser { - const authUserSchema = joi.object().keys({ - email: joi.string().min(1).max(100).email({ tlds: false }).required(), - name: joi.string().min(1).required(), - role: joi - .string() - .min(1) - .valid(...Object.values(ROLES)) - .required(), - userId: joi.string().min(1).uuid().required(), - }); - + const authUserSchema = joi + .object() + .required() + .keys({ + email: joi.string().min(1).max(100).email({ tlds: false }).required(), + name: joi.string().min(1).required(), + role: joi + .string() + .min(1) + .valid(...Object.values(ROLES)) + .required(), + userId: joi.string().min(1).uuid().required(), + }); const { error } = authUserSchema.validate(user, { abortEarly: false, allowUnknown: true, diff --git a/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.ts b/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.ts index 93ba5a6fd6d..96a0922e31c 100644 --- a/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.ts +++ b/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.ts @@ -1,39 +1,38 @@ import { ROLES } from '../../entities/EntityConstants'; import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; import { uploadDocumentInteractor } from './uploadDocumentInteractor'; describe('uploadDocumentInteractor', () => { it('throws an error when an unauthorized user tries to access the use case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: 'other', - userId: 'other', - }); - await expect( - uploadDocumentInteractor(applicationContext, { - documentFile: { - primary: 'something', + uploadDocumentInteractor( + applicationContext, + { + documentFile: { + primary: 'something', + }, + key: 'abc', + onUploadProgress: () => {}, }, - key: 'abc', - onUploadProgress: () => {}, - }), + undefined, + ), ).rejects.toThrow('Unauthorized'); }); it('runs successfully with no errors with a valid user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); - await expect( - uploadDocumentInteractor(applicationContext, { - documentFile: { - primary: 'something', + uploadDocumentInteractor( + applicationContext, + { + documentFile: { + primary: 'something', + }, + key: 'abc', + onUploadProgress: () => {}, }, - key: 'abc', - onUploadProgress: () => {}, - }), + mockPetitionsClerkUser, + ), ).resolves.not.toThrow(); }); @@ -44,16 +43,20 @@ describe('uploadDocumentInteractor', () => { }); await expect( - uploadDocumentInteractor(applicationContext, { - documentFile: { - primary: 'something', - primarySupporting0: 'something3', - secondary: 'something2', - secondarySupporting0: 'something4', + uploadDocumentInteractor( + applicationContext, + { + documentFile: { + primary: 'something', + primarySupporting0: 'something3', + secondary: 'something2', + secondarySupporting0: 'something4', + }, + key: 'abc', + onUploadProgress: () => {}, }, - key: 'abc', - onUploadProgress: () => {}, - }), + mockPetitionsClerkUser, + ), ).resolves.not.toThrow(); }); @@ -64,16 +67,20 @@ describe('uploadDocumentInteractor', () => { }); await expect( - uploadDocumentInteractor(applicationContext, { - documentFile: { - primary: 'something', - primarySupporting0: 'something3', - secondary: 'something2', - secondarySupporting0: 'something4', + uploadDocumentInteractor( + applicationContext, + { + documentFile: { + primary: 'something', + primarySupporting0: 'something3', + secondary: 'something2', + secondarySupporting0: 'something4', + }, + key: 'abc', + onUploadProgress: () => {}, }, - key: 'abc', - onUploadProgress: () => {}, - }), + mockPetitionsClerkUser, + ), ).resolves.not.toThrow(); }); }); diff --git a/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.ts b/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.ts index 6468935a5e9..dde666f2c15 100644 --- a/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.ts +++ b/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.ts @@ -4,18 +4,18 @@ import { isAuthorized, } from '../../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const uploadDocumentInteractor = async ( applicationContext: ClientApplicationContext, { documentFile, key, onUploadProgress }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - if ( !( - isAuthorized(user, ROLE_PERMISSIONS.FILE_EXTERNAL_DOCUMENT) || - isAuthorized(user, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT) || - isAuthorized(user, ROLE_PERMISSIONS.DOCKET_ENTRY) + isAuthorized(authorizedUser, ROLE_PERMISSIONS.FILE_EXTERNAL_DOCUMENT) || + isAuthorized(authorizedUser, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT) || + isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY) ) ) { throw new UnauthorizedError('Unauthorized'); diff --git a/web-client/src/presenter/actions/DocketEntry/uploadDocketEntryFileAction.ts b/web-client/src/presenter/actions/DocketEntry/uploadDocketEntryFileAction.ts index 69b4874eb4c..667d0f5a88d 100644 --- a/web-client/src/presenter/actions/DocketEntry/uploadDocketEntryFileAction.ts +++ b/web-client/src/presenter/actions/DocketEntry/uploadDocketEntryFileAction.ts @@ -10,15 +10,20 @@ export const uploadDocketEntryFileAction = async ({ fileUploadProgressMap: FileUploadProgressMapType; }>) => { const docketEntryId = get(state.docketEntryId); + const user = get(state.user); const { fileUploadProgressMap } = props; try { const primaryDocumentFileId = await applicationContext .getUseCases() - .uploadDocumentInteractor(applicationContext, { - documentFile: fileUploadProgressMap.primary.file, - key: docketEntryId, - onUploadProgress: fileUploadProgressMap.primary.uploadProgress, - }); + .uploadDocumentInteractor( + applicationContext, + { + documentFile: fileUploadProgressMap.primary.file, + key: docketEntryId, + onUploadProgress: fileUploadProgressMap.primary.uploadProgress, + }, + user, + ); return path.success({ docketEntryId: primaryDocumentFileId, From 74da5f8a1572f6b8bf4eed228aac2116475c56bb Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 10:10:41 -0700 Subject: [PATCH 105/523] 10417: Remove getCurrentUser from shared --- .../uploadExternalDocumentsInteractor.test.ts | 155 +++++++++--------- .../uploadExternalDocumentsInteractor.ts | 6 +- .../uploadExternalDocumentsAction.ts | 15 +- 3 files changed, 90 insertions(+), 86 deletions(-) diff --git a/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.test.ts b/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.test.ts index 104435e9e32..b960a0eb3b6 100644 --- a/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.test.ts +++ b/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.test.ts @@ -1,5 +1,8 @@ -import { ROLES } from '../../entities/EntityConstants'; import { applicationContext } from '../../test/createTestApplicationContext'; +import { + mockIrsPractitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { uploadExternalDocumentsInteractor } from './uploadExternalDocumentsInteractor'; describe('uploadExternalDocumentsInteractor', () => { @@ -10,43 +13,41 @@ describe('uploadExternalDocumentsInteractor', () => { }); it('throws an error when an unauthorized user tries to access the use case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); - await expect( - uploadExternalDocumentsInteractor(applicationContext, { - documentFiles: { - primary: { - stuff: 'hi', + uploadExternalDocumentsInteractor( + applicationContext, + { + documentFiles: { + primary: { + stuff: 'hi', + }, + }, + documentMetadata: {}, + fileUploadProgressMap: { + primary: () => {}, }, }, - documentMetadata: {}, - fileUploadProgressMap: { - primary: () => {}, - }, - }), + mockPetitionsClerkUser, + ), ).rejects.toThrow('Unauthorized'); }); it('runs successfully with no errors with minimum data and valid user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: 'irsPractitioner', - }); - - const result = await uploadExternalDocumentsInteractor(applicationContext, { - documentFiles: { - primary: 'something', - }, - documentMetadata: { - primaryDocumentFile: {}, - }, - fileUploadProgressMap: { - primary: () => {}, + const result = await uploadExternalDocumentsInteractor( + applicationContext, + { + documentFiles: { + primary: 'something', + }, + documentMetadata: { + primaryDocumentFile: {}, + }, + fileUploadProgressMap: { + primary: () => {}, + }, }, - }); + mockIrsPractitionerUser, + ); expect(result).toMatchObject({ caseDetail: expect.anything(), docketEntryIdsAdded: expect.any(Array), @@ -54,62 +55,60 @@ describe('uploadExternalDocumentsInteractor', () => { }); it('runs successfully with no errors with all data and valid user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: 'irsPractitioner', - }); - await expect( - uploadExternalDocumentsInteractor(applicationContext, { - documentFiles: { - primary: 'something', - primarySupporting0: 'something3', - secondary: 'something2', - secondarySupporting0: 'something4', - }, - documentMetadata: { - hasSecondarySupportingDocuments: true, - hasSupportingDocuments: true, - primaryDocumentFile: {}, - secondaryDocument: {}, - secondarySupportingDocuments: [{ supportingDocument: 'something' }], - supportingDocuments: [{ supportingDocument: 'something' }], - }, - fileUploadProgressMap: { - primary: () => 'something', - primarySupporting0: () => 'something3', - secondary: () => 'something2', - secondarySupporting0: () => 'something4', + uploadExternalDocumentsInteractor( + applicationContext, + { + documentFiles: { + primary: 'something', + primarySupporting0: 'something3', + secondary: 'something2', + secondarySupporting0: 'something4', + }, + documentMetadata: { + hasSecondarySupportingDocuments: true, + hasSupportingDocuments: true, + primaryDocumentFile: {}, + secondaryDocument: {}, + secondarySupportingDocuments: [{ supportingDocument: 'something' }], + supportingDocuments: [{ supportingDocument: 'something' }], + }, + fileUploadProgressMap: { + primary: () => 'something', + primarySupporting0: () => 'something3', + secondary: () => 'something2', + secondarySupporting0: () => 'something4', + }, }, - }), + mockIrsPractitionerUser, + ), ).resolves.not.toThrow(); }); it('runs successfully with no errors with all data and valid user who is a practitioner', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: 'irsPractitioner', - }); - await expect( - uploadExternalDocumentsInteractor(applicationContext, { - documentFiles: { - primary: 'something', - primarySupporting0: 'something3', - secondary: 'something2', - secondarySupporting0: 'something4', - }, - documentMetadata: { - primaryDocumentFile: {}, - secondaryDocument: {}, - }, - fileUploadProgressMap: { - primary: 'something', - primarySupporting0: 'something3', - secondary: 'something2', - secondarySupporting0: 'something4', + uploadExternalDocumentsInteractor( + applicationContext, + { + documentFiles: { + primary: 'something', + primarySupporting0: 'something3', + secondary: 'something2', + secondarySupporting0: 'something4', + }, + documentMetadata: { + primaryDocumentFile: {}, + secondaryDocument: {}, + }, + fileUploadProgressMap: { + primary: 'something', + primarySupporting0: 'something3', + secondary: 'something2', + secondarySupporting0: 'something4', + }, }, - }), + mockIrsPractitionerUser, + ), ).resolves.not.toThrow(); }); }); diff --git a/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.ts b/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.ts index c038f999d0c..2924f966a5d 100644 --- a/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.ts +++ b/shared/src/business/useCases/externalDocument/uploadExternalDocumentsInteractor.ts @@ -5,6 +5,7 @@ import { isAuthorized, } from '../../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * Uploads external documents and calls the interactor to associate them with one or more cases @@ -27,10 +28,9 @@ export const uploadExternalDocumentsInteractor = async ( documentMetadata: any; fileUploadProgressMap: FileUploadProgressMapType; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.FILE_EXTERNAL_DOCUMENT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.FILE_EXTERNAL_DOCUMENT)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-client/src/presenter/actions/FileDocument/uploadExternalDocumentsAction.ts b/web-client/src/presenter/actions/FileDocument/uploadExternalDocumentsAction.ts index 85947b4891c..5940b46af1f 100644 --- a/web-client/src/presenter/actions/FileDocument/uploadExternalDocumentsAction.ts +++ b/web-client/src/presenter/actions/FileDocument/uploadExternalDocumentsAction.ts @@ -22,15 +22,20 @@ export const uploadExternalDocumentsAction = async ({ }>) => { const { documentMetadata, files, fileUploadProgressMap } = props; const { docketNumber } = get(state.caseDetail); + const user = get(state.user); try { const { caseDetail, docketEntryIdsAdded } = await applicationContext .getUseCases() - .uploadExternalDocumentsInteractor(applicationContext, { - documentFiles: files, - documentMetadata, - fileUploadProgressMap, - }); + .uploadExternalDocumentsInteractor( + applicationContext, + { + documentFiles: files, + documentMetadata, + fileUploadProgressMap, + }, + user, + ); for (let docketEntryId of docketEntryIdsAdded) { await addCoversheet({ From bf67c33772c6fe81134956bf415c24a47a245f75 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 10:12:53 -0700 Subject: [PATCH 106/523] 10417: Remove getCurrentUser from web-api --- .../addDocketEntryForSystemGeneratedOrder.test.ts | 9 +++++++++ .../addDocketEntryForSystemGeneratedOrder.ts | 14 +++++++++++--- .../serveCaseToIrs/generateDraftDocument.ts | 1 + .../serveCaseToIrs/serveCaseToIrsInteractor.ts | 8 ++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.test.ts b/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.test.ts index 49af6d6d77e..4098a406761 100644 --- a/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.test.ts +++ b/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.test.ts @@ -6,6 +6,7 @@ import { Case } from '../../../../shared/src/business/entities/cases/Case'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { addDocketEntryForSystemGeneratedOrder } from './addDocketEntryForSystemGeneratedOrder'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('addDocketEntryForSystemGeneratedOrder', () => { const caseEntity = new Case(MOCK_CASE, { authorizedUser: undefined }); @@ -32,6 +33,7 @@ describe('addDocketEntryForSystemGeneratedOrder', () => { await addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: mockDocketClerkUser, caseEntity, systemGeneratedDocument: noticeOfAttachmentsInNatureOfEvidence, }); @@ -55,6 +57,7 @@ describe('addDocketEntryForSystemGeneratedOrder', () => { it('should only add freeText to notices', async () => { await addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: mockDocketClerkUser, caseEntity, systemGeneratedDocument: noticeOfAttachmentsInNatureOfEvidence, }); @@ -69,6 +72,7 @@ describe('addDocketEntryForSystemGeneratedOrder', () => { it('should set the title and the name of clerk for notices', async () => { await addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: mockDocketClerkUser, caseEntity, systemGeneratedDocument: noticeOfAttachmentsInNatureOfEvidence, }); @@ -84,6 +88,7 @@ describe('addDocketEntryForSystemGeneratedOrder', () => { it('should not set a title or the name of clerk for orders', async () => { await addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: mockDocketClerkUser, caseEntity, systemGeneratedDocument: orderForFilingFee, }); @@ -99,6 +104,7 @@ describe('addDocketEntryForSystemGeneratedOrder', () => { it('should upload a generated pdf for the provided document', async () => { await addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: mockDocketClerkUser, caseEntity, systemGeneratedDocument: noticeOfAttachmentsInNatureOfEvidence, }); @@ -119,6 +125,7 @@ describe('addDocketEntryForSystemGeneratedOrder', () => { await addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: mockDocketClerkUser, caseEntity, systemGeneratedDocument: mockClonedSystemDocument, }); @@ -149,6 +156,7 @@ describe('addDocketEntryForSystemGeneratedOrder', () => { await addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: mockDocketClerkUser, caseEntity, systemGeneratedDocument: orderForAmendedPetition, }); @@ -179,6 +187,7 @@ describe('addDocketEntryForSystemGeneratedOrder', () => { await addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: mockDocketClerkUser, caseEntity, systemGeneratedDocument: orderForAmendedPetitionAndFilingFee, }); diff --git a/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.ts b/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.ts index db920022870..a2adc6b36ab 100644 --- a/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.ts +++ b/web-api/src/business/useCaseHelper/addDocketEntryForSystemGeneratedOrder.ts @@ -2,7 +2,10 @@ import { AMENDED_PETITION_FORM_NAME, SYSTEM_GENERATED_DOCUMENT_TYPES, } from '../../../../shared/src/business/entities/EntityConstants'; +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { Case } from '@shared/business/entities/cases/Case'; import { DocketEntry } from '../../../../shared/src/business/entities/DocketEntry'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { getCaseCaptionMeta } from '../../../../shared/src/business/utilities/getCaseCaptionMeta'; /** @@ -18,10 +21,15 @@ import { getCaseCaptionMeta } from '../../../../shared/src/business/utilities/ge */ export const addDocketEntryForSystemGeneratedOrder = async ({ applicationContext, + authorizedUser, caseEntity, systemGeneratedDocument, +}: { + applicationContext: ServerApplicationContext; + caseEntity: Case; + systemGeneratedDocument: any; + authorizedUser: AuthUser; }) => { - const user = applicationContext.getCurrentUser(); const isNotice = systemGeneratedDocument.eventCode === 'NOT'; const newDocketEntry = new DocketEntry( @@ -40,10 +48,10 @@ export const addDocketEntryForSystemGeneratedOrder = async ({ isDraft: true, isFileAttached: true, }, - { authorizedUser: user }, + { authorizedUser }, ); - newDocketEntry.setFiledBy(user); + newDocketEntry.setFiledBy(authorizedUser); caseEntity.addDocketEntry(newDocketEntry); const { caseCaptionExtension, caseTitle } = getCaseCaptionMeta(caseEntity); diff --git a/web-api/src/business/useCases/serveCaseToIrs/generateDraftDocument.ts b/web-api/src/business/useCases/serveCaseToIrs/generateDraftDocument.ts index 8427a8c2ea9..7fcd1861f7a 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/generateDraftDocument.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/generateDraftDocument.ts @@ -27,6 +27,7 @@ export const generateDraftDocument = async ({ .getUseCaseHelpers() .addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: applicationContext.getCurrentUser(), caseEntity, systemGeneratedDocument: { ...document, diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts index 61c59272149..7408c33dd5a 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts @@ -474,8 +474,11 @@ const contactAddressesAreDifferent = ({ applicationContext, caseEntity }) => { * @returns {Buffer} paper service pdf if the case is a paper case */ export const serveCaseToIrs = async ( - applicationContext, - { clientConnectionId, docketNumber }, + applicationContext: ServerApplicationContext, + { + clientConnectionId, + docketNumber, + }: { clientConnectionId: string; docketNumber: string }, ) => { const user = applicationContext.getCurrentUser(); try { @@ -526,6 +529,7 @@ export const serveCaseToIrs = async ( .getUseCaseHelpers() .addDocketEntryForSystemGeneratedOrder({ applicationContext, + authorizedUser: applicationContext.getCurrentUser(), caseEntity, systemGeneratedDocument: noticeOfAttachmentsInNatureOfEvidence, }), From 674a61200b2d0beb9c08caf5f5f9d62bbf71d020 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 10:20:04 -0700 Subject: [PATCH 107/523] 10417: Remove getCurrentUser from web-api --- .../useCaseHelper/generateChangeOfAddressHelper.ts | 10 ++++++++-- web-api/src/lambdas/pdfGeneration/pdf-generation.ts | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts b/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts index 8f5eb7a3b82..45a65b03bbe 100644 --- a/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts +++ b/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts @@ -1,5 +1,9 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '@shared/business/entities/cases/Case'; -import { Practitioner } from '../../../../shared/src/business/entities/Practitioner'; +import { + Practitioner, + RawPractitioner, +} from '../../../../shared/src/business/entities/Practitioner'; import { ROLES, SERVICE_INDICATOR_TYPES, @@ -20,6 +24,7 @@ import { generateAndServeDocketEntry } from '@web-api/business/useCaseHelper/ser */ export const generateChangeOfAddressHelper = async ({ applicationContext, + authorizedUser, bypassDocketEntry, contactInfo, docketNumber, @@ -32,6 +37,7 @@ export const generateChangeOfAddressHelper = async ({ websocketMessagePrefix, }: { applicationContext: ServerApplicationContext; + authorizedUser: AuthUser; docketNumber: string; bypassDocketEntry: boolean; contactInfo: TUserContact; @@ -53,7 +59,7 @@ export const generateChangeOfAddressHelper = async ({ docketNumber, }); let caseEntity = new Case(userCase, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const practitionerName = updatedName || user.name; diff --git a/web-api/src/lambdas/pdfGeneration/pdf-generation.ts b/web-api/src/lambdas/pdfGeneration/pdf-generation.ts index 49b5702d38d..d6c7dea639b 100644 --- a/web-api/src/lambdas/pdfGeneration/pdf-generation.ts +++ b/web-api/src/lambdas/pdfGeneration/pdf-generation.ts @@ -36,6 +36,7 @@ export const changeOfAddressHandler = async event => { await applicationContext.getUseCaseHelpers().generateChangeOfAddressHelper({ applicationContext, + authorizedUser: applicationContext.getCurrentUser(), bypassDocketEntry: eventBody.bypassDocketEntry, contactInfo: eventBody.contactInfo, docketNumber: eventBody.docketNumber, From 29dff9952a8f6efa1f68d55985d6b7aa2bd363c0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 10:21:53 -0700 Subject: [PATCH 108/523] 10417: Remove getCurrentUser from shared --- .../uploadDocumentInteractor.test.ts | 18 +++-------- .../uploadOrderDocumentInteractor.test.ts | 31 ++++++++++--------- .../uploadOrderDocumentInteractor.ts | 8 ++--- .../overwriteOrderFileAction.ts | 13 +++++--- .../FileDocument/uploadOrderFileAction.ts | 11 +++++-- .../createPractitionerDocumentAction.ts | 11 +++++-- .../actions/editPractitionerDocumentAction.ts | 11 ++++--- 7 files changed, 58 insertions(+), 45 deletions(-) diff --git a/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.ts b/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.ts index 96a0922e31c..4a73f9f6b51 100644 --- a/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.ts +++ b/shared/src/business/useCases/externalDocument/uploadDocumentInteractor.test.ts @@ -1,6 +1,8 @@ -import { ROLES } from '../../entities/EntityConstants'; import { applicationContext } from '../../test/createTestApplicationContext'; -import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; +import { + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { uploadDocumentInteractor } from './uploadDocumentInteractor'; describe('uploadDocumentInteractor', () => { @@ -37,11 +39,6 @@ describe('uploadDocumentInteractor', () => { }); it('runs successfully with no errors with all data and valid user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); - await expect( uploadDocumentInteractor( applicationContext, @@ -61,11 +58,6 @@ describe('uploadDocumentInteractor', () => { }); it('runs successfully with no errors with all data and valid user who is a docketclerk', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketclerk', - }); - await expect( uploadDocumentInteractor( applicationContext, @@ -79,7 +71,7 @@ describe('uploadDocumentInteractor', () => { key: 'abc', onUploadProgress: () => {}, }, - mockPetitionsClerkUser, + mockDocketClerkUser, ), ).resolves.not.toThrow(); }); diff --git a/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.test.ts b/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.test.ts index 7b32a0d247c..dedfc93b79d 100644 --- a/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.test.ts +++ b/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.test.ts @@ -1,28 +1,31 @@ -import { ROLES } from '../../entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { uploadOrderDocumentInteractor } from './uploadOrderDocumentInteractor'; describe('uploadOrderDocumentInteractor', () => { it('throws an error when an unauthorized user tries to access the use case', async () => { await expect( - uploadOrderDocumentInteractor(applicationContext, { - documentFile: '', - fileIdToOverwrite: '123', - }), + uploadOrderDocumentInteractor( + applicationContext, + { + documentFile: '', + fileIdToOverwrite: '123', + }, + undefined, + ), ).rejects.toThrow(UnauthorizedError); }); it('uploads documents on behalf of authorized users', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'admin', - }); - - await uploadOrderDocumentInteractor(applicationContext, { - documentFile: 'document file', - fileIdToOverwrite: '123', - }); + await uploadOrderDocumentInteractor( + applicationContext, + { + documentFile: 'document file', + fileIdToOverwrite: '123', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().uploadDocumentFromClient.mock diff --git a/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.ts b/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.ts index 410fe977669..718baa3908b 100644 --- a/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.ts +++ b/shared/src/business/useCases/externalDocument/uploadOrderDocumentInteractor.ts @@ -4,6 +4,7 @@ import { isAuthorized, } from '../../../authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * @@ -18,11 +19,10 @@ export const uploadOrderDocumentInteractor = async ( { documentFile, fileIdToOverwrite, - }: { fileIdToOverwrite: string; documentFile: any }, + }: { fileIdToOverwrite?: string; documentFile: any }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-client/src/presenter/actions/CourtIssuedOrder/overwriteOrderFileAction.ts b/web-client/src/presenter/actions/CourtIssuedOrder/overwriteOrderFileAction.ts index 76fb6a9f8fc..e90c065443f 100644 --- a/web-client/src/presenter/actions/CourtIssuedOrder/overwriteOrderFileAction.ts +++ b/web-client/src/presenter/actions/CourtIssuedOrder/overwriteOrderFileAction.ts @@ -15,14 +15,19 @@ export const overwriteOrderFileAction = async ({ }: ActionProps) => { const { primaryDocumentFile } = get(state.form); const documentToEdit = get(state.documentToEdit); + const user = get(state.user); try { const primaryDocumentFileId = await applicationContext .getUseCases() - .uploadOrderDocumentInteractor(applicationContext, { - documentFile: primaryDocumentFile, - fileIdToOverwrite: documentToEdit.docketEntryId, - }); + .uploadOrderDocumentInteractor( + applicationContext, + { + documentFile: primaryDocumentFile, + fileIdToOverwrite: documentToEdit.docketEntryId, + }, + user, + ); return path.success({ primaryDocumentFileId, diff --git a/web-client/src/presenter/actions/FileDocument/uploadOrderFileAction.ts b/web-client/src/presenter/actions/FileDocument/uploadOrderFileAction.ts index 63f5df0d220..ce35b7a9d33 100644 --- a/web-client/src/presenter/actions/FileDocument/uploadOrderFileAction.ts +++ b/web-client/src/presenter/actions/FileDocument/uploadOrderFileAction.ts @@ -12,13 +12,18 @@ export const uploadOrderFileAction = async ({ path, }: ActionProps) => { const { primaryDocumentFile } = get(state.form); + const user = get(state.user); try { const primaryDocumentFileId = await applicationContext .getUseCases() - .uploadOrderDocumentInteractor(applicationContext, { - documentFile: primaryDocumentFile, - }); + .uploadOrderDocumentInteractor( + applicationContext, + { + documentFile: primaryDocumentFile, + }, + user, + ); return path.success({ primaryDocumentFileId, diff --git a/web-client/src/presenter/actions/createPractitionerDocumentAction.ts b/web-client/src/presenter/actions/createPractitionerDocumentAction.ts index a717950ce48..07115ddb7d7 100644 --- a/web-client/src/presenter/actions/createPractitionerDocumentAction.ts +++ b/web-client/src/presenter/actions/createPractitionerDocumentAction.ts @@ -13,12 +13,17 @@ export const createPractitionerDocumentAction = async ({ }: ActionProps) => { const { practitionerDocumentFile, ...form } = get(state.form); const { barNumber } = get(state.practitionerDetail); + const user = get(state.user); const practitionerDocumentFileId = await applicationContext .getUseCases() - .uploadOrderDocumentInteractor(applicationContext, { - documentFile: practitionerDocumentFile, - }); + .uploadOrderDocumentInteractor( + applicationContext, + { + documentFile: practitionerDocumentFile, + }, + user, + ); await applicationContext .getUseCases() diff --git a/web-client/src/presenter/actions/editPractitionerDocumentAction.ts b/web-client/src/presenter/actions/editPractitionerDocumentAction.ts index c75d2148112..1d1413c3c3d 100644 --- a/web-client/src/presenter/actions/editPractitionerDocumentAction.ts +++ b/web-client/src/presenter/actions/editPractitionerDocumentAction.ts @@ -15,17 +15,20 @@ export const editPractitionerDocumentAction = async ({ state.form, ); const { barNumber } = get(state.practitionerDetail); + const user = get(state.user); let fileName; let uploadDate; if (practitionerDocumentFile) { - await applicationContext - .getUseCases() - .uploadOrderDocumentInteractor(applicationContext, { + await applicationContext.getUseCases().uploadOrderDocumentInteractor( + applicationContext, + { documentFile: practitionerDocumentFile, fileIdToOverwrite: practitionerDocumentFileId, - }); + }, + user, + ); fileName = practitionerDocumentFile.name; uploadDate = applicationContext.getUtilities().createISODateString(); From 7e443d65b226dfaadea4b7db6dedbd4acf1c19f9 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 10:30:17 -0700 Subject: [PATCH 109/523] 10417: Remove getCurrentUser from web-api --- .../getJudgeInSectionHelper.test.ts | 6 --- .../sealInLowerEnvironment.test.ts | 39 ++++++++++++------- .../useCaseHelper/sealInLowerEnvironment.ts | 19 ++++++--- .../cases/sealInLowerEnvironmentLambda.ts | 5 +-- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/web-api/src/business/useCaseHelper/getJudgeInSectionHelper.test.ts b/web-api/src/business/useCaseHelper/getJudgeInSectionHelper.test.ts index 07c36acce0e..b9f6c9ef011 100644 --- a/web-api/src/business/useCaseHelper/getJudgeInSectionHelper.test.ts +++ b/web-api/src/business/useCaseHelper/getJudgeInSectionHelper.test.ts @@ -2,13 +2,7 @@ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants' import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { getJudgeInSectionHelper } from './getJudgeInSectionHelper'; -let currentUser; - describe('getJudgeInSectionHelper', () => { - beforeEach(() => { - applicationContext.getCurrentUser.mockImplementation(() => currentUser); - }); - it('Fetches the judge associated with a given section', async () => { const expectedJudgeUser = { isSeniorJudge: false, diff --git a/web-api/src/business/useCaseHelper/sealInLowerEnvironment.test.ts b/web-api/src/business/useCaseHelper/sealInLowerEnvironment.test.ts index 3b21076e72c..b6199edd967 100644 --- a/web-api/src/business/useCaseHelper/sealInLowerEnvironment.test.ts +++ b/web-api/src/business/useCaseHelper/sealInLowerEnvironment.test.ts @@ -1,6 +1,6 @@ import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { sealInLowerEnvironment } from './sealInLowerEnvironment'; describe('sealInLowerEnvironment', () => { @@ -11,17 +11,19 @@ describe('sealInLowerEnvironment', () => { applicationContext.getNotificationGateway().sendNotificationOfSealing = jest.fn(); applicationContext.isCurrentColorActive = jest.fn().mockReturnValue(true); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); }); it('should seal the case with the docketNumber provided and return the updated case', async () => { - const result = await sealInLowerEnvironment(applicationContext, [ - { - docketNumber: MOCK_CASE.docketNumber, - }, - ]); + const result = await sealInLowerEnvironment( + applicationContext, + [ + { + docketNumber: MOCK_CASE.docketNumber, + }, + ], + mockDocketClerkUser, + ); + expect( applicationContext.getUseCases().sealCaseInteractor, ).toHaveBeenCalled(); @@ -29,7 +31,8 @@ describe('sealInLowerEnvironment', () => { }); it('should only log a warning if we do not have a docketNumber', async () => { - await sealInLowerEnvironment(applicationContext, [{}]); + await sealInLowerEnvironment(applicationContext, [{}], mockDocketClerkUser); + expect( applicationContext.getUseCases().sealCaseInteractor, ).not.toHaveBeenCalled(); @@ -38,11 +41,17 @@ describe('sealInLowerEnvironment', () => { it('should not execute if the current color is not active', async () => { applicationContext.isCurrentColorActive = jest.fn().mockReturnValue(false); - await sealInLowerEnvironment(applicationContext, [ - { - docketNumber: '123-21', - }, - ]); + + await sealInLowerEnvironment( + applicationContext, + [ + { + docketNumber: '123-21', + }, + ], + mockDocketClerkUser, + ); + expect( applicationContext.getUseCases().sealCaseInteractor, ).not.toHaveBeenCalled(); diff --git a/web-api/src/business/useCaseHelper/sealInLowerEnvironment.ts b/web-api/src/business/useCaseHelper/sealInLowerEnvironment.ts index d6cb633f5d3..94b827ef3c1 100644 --- a/web-api/src/business/useCaseHelper/sealInLowerEnvironment.ts +++ b/web-api/src/business/useCaseHelper/sealInLowerEnvironment.ts @@ -1,3 +1,6 @@ +import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; + /** * sealInLowerEnvironment * @@ -5,7 +8,11 @@ * @param {array} records an array of docketNumbers and/or docketEntryIds to seal * @returns {Promise} the array of responses from the interactor */ -export const sealInLowerEnvironment = async (applicationContext, records) => { +export const sealInLowerEnvironment = async ( + applicationContext: ServerApplicationContext, + records, + authorizedUser: UnknownAuthUser, +) => { const isCurrentColorActive = await applicationContext.isCurrentColorActive(applicationContext); @@ -25,11 +32,13 @@ export const sealInLowerEnvironment = async (applicationContext, records) => { // docketNumber, // }); } else if (docketNumber) { - return applicationContext - .getUseCases() - .sealCaseInteractor(applicationContext, { + return applicationContext.getUseCases().sealCaseInteractor( + applicationContext, + { docketNumber, - }); + }, + authorizedUser, + ); } applicationContext.logger.warn( diff --git a/web-api/src/lambdas/cases/sealInLowerEnvironmentLambda.ts b/web-api/src/lambdas/cases/sealInLowerEnvironmentLambda.ts index b820cd43c0c..ce2a2fd1850 100644 --- a/web-api/src/lambdas/cases/sealInLowerEnvironmentLambda.ts +++ b/web-api/src/lambdas/cases/sealInLowerEnvironmentLambda.ts @@ -1,4 +1,5 @@ import { createApplicationContext } from '../../applicationContext'; +import { sealInLowerEnvironment } from '@web-api/business/useCaseHelper/sealInLowerEnvironment'; /** * used for retroactively sealing a case in a lower environment after it is sealed in the Production environment @@ -14,7 +15,5 @@ export const sealInLowerEnvironmentLambda = async event => { ...JSON.parse(record.Sns.Message), })); - return await applicationContext - .getUseCaseHelpers() - .sealInLowerEnvironment(applicationContext, records); + return await sealInLowerEnvironment(applicationContext, records, user); }; From 39344577525dd60402e634060ca6d1ca497e1704 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 10:32:05 -0700 Subject: [PATCH 110/523] 10417: Remove getCurrentUser from shared --- ...TrialSessionAsCalendaredInteractor.test.ts | 38 +++---------------- ...anSetTrialSessionAsCalendaredInteractor.ts | 7 ++-- .../canSetTrialSessionToCalendarAction.ts | 3 +- 3 files changed, 10 insertions(+), 38 deletions(-) diff --git a/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.test.ts b/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.test.ts index 879269c36bf..07954476820 100644 --- a/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.test.ts +++ b/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.test.ts @@ -1,10 +1,7 @@ -import { - ROLES, - TRIAL_SESSION_PROCEEDING_TYPES, -} from '../../entities/EntityConstants'; import { RawTrialSession } from '../../entities/trialSessions/TrialSession'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../entities/EntityConstants'; import { canSetTrialSessionAsCalendaredInteractor } from './canSetTrialSessionAsCalendaredInteractor'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; const MOCK_TRIAL = { maxCases: 100, @@ -16,36 +13,18 @@ const MOCK_TRIAL = { trialLocation: 'Birmingham, Alabama', }; -let user; - describe('canSetTrialSessionAsCalendaredInteractor', () => { - beforeEach(() => { - applicationContext.getCurrentUser.mockImplementation(() => user); - }); - it('throws an error if a user is unauthorized', () => { - user = { - role: 'unauthorizedRole', - userId: 'unauthorizedUser', - }; - expect(() => - canSetTrialSessionAsCalendaredInteractor(applicationContext, { + canSetTrialSessionAsCalendaredInteractor(undefined, { trialSession: MOCK_TRIAL as RawTrialSession, }), ).toThrow('Unauthorized'); }); it('gets the result back from the interactor with empty fields and an in-person trial proceeding', () => { - user = { - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }; - - applicationContext.getUniqueId.mockReturnValue('easy-as-abc-123'); - const result = canSetTrialSessionAsCalendaredInteractor( - applicationContext, + mockPetitionsClerkUser, { trialSession: MOCK_TRIAL as RawTrialSession, }, @@ -66,15 +45,8 @@ describe('canSetTrialSessionAsCalendaredInteractor', () => { }); it('gets the result back from the interactor with no empty fields and a remote trial proceeding', () => { - user = { - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }; - - applicationContext.getUniqueId.mockReturnValue('easy-as-abc-123'); - const result = canSetTrialSessionAsCalendaredInteractor( - applicationContext, + mockPetitionsClerkUser, { trialSession: { ...MOCK_TRIAL, diff --git a/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.ts b/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.ts index b135c6ee5b4..069d5f304fb 100644 --- a/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.ts +++ b/shared/src/business/useCases/trialSessions/canSetTrialSessionAsCalendaredInteractor.ts @@ -7,6 +7,7 @@ import { TrialSession, } from '../../entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * canSetTrialSessionAsCalendaredInteractor @@ -17,12 +18,10 @@ import { UnauthorizedError } from '@web-api/errors/errors'; * @returns {boolean} result of the entity method call depicting trial session calendaring eligibility */ export const canSetTrialSessionAsCalendaredInteractor = ( - applicationContext: IApplicationContext, + authorizedUser: UnknownAuthUser, { trialSession }: { trialSession: RawTrialSession }, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-client/src/presenter/actions/TrialSession/canSetTrialSessionToCalendarAction.ts b/web-client/src/presenter/actions/TrialSession/canSetTrialSessionToCalendarAction.ts index b9c66ee6a2e..a9b80fe216c 100644 --- a/web-client/src/presenter/actions/TrialSession/canSetTrialSessionToCalendarAction.ts +++ b/web-client/src/presenter/actions/TrialSession/canSetTrialSessionToCalendarAction.ts @@ -14,9 +14,10 @@ export const canSetTrialSessionToCalendarAction = ({ path, }: ActionProps) => { const trialSession = get(state.trialSession); + const user = get(state.user); const { canSetAsCalendared, emptyFields, isRemote } = applicationContext .getUseCases() - .canSetTrialSessionAsCalendaredInteractor(applicationContext, { + .canSetTrialSessionAsCalendaredInteractor(user, { trialSession, }); From 7c77326f0e1e0cd7245d11a371facc1501e4f258 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 10:37:27 -0700 Subject: [PATCH 111/523] 10417: Remove getCurrentUser from web-api --- .../updateCaseAutomaticBlock.test.ts | 5 +---- .../addExistingUserToCase.test.ts | 22 ++++++++++--------- .../caseAssociation/addExistingUserToCase.ts | 5 +++-- .../updatePetitionerInformationInteractor.ts | 4 +++- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/web-api/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts b/web-api/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts index 664d19b8d40..a7eb1d261b0 100644 --- a/web-api/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts +++ b/web-api/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts @@ -7,7 +7,6 @@ import { MOCK_CASE, MOCK_CASE_WITHOUT_PENDING, } from '../../../../../shared/src/test/mockCase'; -import { MOCK_USERS } from '../../../../../shared/src/test/mockUsers'; import { PENDING_DOCKET_ENTRY } from '../../../../../shared/src/test/mockDocketEntry'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; @@ -16,11 +15,9 @@ import { updateCaseAutomaticBlock } from './updateCaseAutomaticBlock'; describe('updateCaseAutomaticBlock', () => { let mockCase; + beforeEach(() => { mockCase = cloneDeep(MOCK_CASE); - applicationContext.getCurrentUser.mockReturnValue( - MOCK_USERS['a7d90c05-f6cd-442c-a168-202db587f16f'], - ); applicationContext.getUniqueId.mockReturnValue('unique-id-1'); }); diff --git a/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.test.ts index f1e7e048247..6cd3ecfeb05 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.test.ts @@ -8,9 +8,12 @@ import { } from '../../../../../shared/src/business/entities/cases/Case'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { addExistingUserToCase } from './addExistingUserToCase'; -import { admissionsClerkUser, petitionerUser } from '@shared/test/mockUsers'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; +import { + mockAdmissionsClerkUser, + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('addExistingUserToCase', () => { const mockUserId = '674fdded-1d17-4081-b9fa-950abc677cee'; @@ -28,11 +31,10 @@ describe('addExistingUserToCase', () => { }); it('should throw an unauthorized error when the user is not authorized to add a user to a case', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - await expect( addExistingUserToCase({ applicationContext, + authorizedUser: mockPetitionerUser, caseEntity: new Case(MOCK_CASE, { authorizedUser: mockDocketClerkUser, }), @@ -44,12 +46,12 @@ describe('addExistingUserToCase', () => { }); it('should throw an error when a user is NOT found with the provided email', async () => { - applicationContext.getCurrentUser.mockReturnValue(admissionsClerkUser); applicationContext.getUserGateway().getUserByEmail.mockReturnValue(null); await expect( addExistingUserToCase({ applicationContext, + authorizedUser: mockAdmissionsClerkUser, caseEntity: new Case(MOCK_CASE, { authorizedUser: mockDocketClerkUser, }), @@ -65,7 +67,6 @@ describe('addExistingUserToCase', () => { contactId: '60dd21b3-5abb-447f-b036-9794962252a0', contactType: CONTACT_TYPES.primary, }; - applicationContext.getCurrentUser.mockReturnValue(admissionsClerkUser); const caseEntity = new Case( { ...MOCK_CASE, petitioners: [mockExistingUser] }, { authorizedUser: mockDocketClerkUser }, @@ -74,6 +75,7 @@ describe('addExistingUserToCase', () => { await expect( addExistingUserToCase({ applicationContext, + authorizedUser: mockAdmissionsClerkUser, caseEntity, contactId: mockExistingUser.contactId, email: 'testing@example.com', @@ -83,7 +85,6 @@ describe('addExistingUserToCase', () => { }); it('should call associateUserWithCase and return the updated case with contact primary email', async () => { - applicationContext.getCurrentUser.mockReturnValue(admissionsClerkUser); const caseEntity = new Case( { ...MOCK_CASE, @@ -102,6 +103,7 @@ describe('addExistingUserToCase', () => { await addExistingUserToCase({ applicationContext, + authorizedUser: mockAdmissionsClerkUser, caseEntity, contactId: mockContactId, email: mockUpdatedEmail, @@ -123,7 +125,6 @@ describe('addExistingUserToCase', () => { }); it('should call associateUserWithCase and update the representing arrays entries with the expect contactId', async () => { - applicationContext.getCurrentUser.mockReturnValue(admissionsClerkUser); const caseEntity = new Case( { ...MOCK_CASE, @@ -165,6 +166,7 @@ describe('addExistingUserToCase', () => { await addExistingUserToCase({ applicationContext, + authorizedUser: mockAdmissionsClerkUser, caseEntity, contactId: mockContactId, email: mockUpdatedEmail, @@ -177,7 +179,6 @@ describe('addExistingUserToCase', () => { }); it("should not update the practitioner's representing array when the cognito user's ID already exists", async () => { - applicationContext.getCurrentUser.mockReturnValue(admissionsClerkUser); const caseEntity = new Case( { ...MOCK_CASE, @@ -219,6 +220,7 @@ describe('addExistingUserToCase', () => { await addExistingUserToCase({ applicationContext, + authorizedUser: mockAdmissionsClerkUser, caseEntity, contactId: mockContactId, email: mockUpdatedEmail, @@ -231,7 +233,6 @@ describe('addExistingUserToCase', () => { }); it('should not change the service indicator to electronic when the user has a pendingEmail', async () => { - applicationContext.getCurrentUser.mockReturnValue(admissionsClerkUser); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ pendingEmail: 'testing@example.com', userId: mockUserId, @@ -255,6 +256,7 @@ describe('addExistingUserToCase', () => { await addExistingUserToCase({ applicationContext, + authorizedUser: mockAdmissionsClerkUser, caseEntity, contactId: mockContactId, email: mockUpdatedEmail, diff --git a/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.ts b/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.ts index da3b2f6b7e6..bb8ae0105f5 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/addExistingUserToCase.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '@shared/business/entities/cases/Case'; import { ROLE_PERMISSIONS, @@ -10,6 +11,7 @@ import { UserCase } from '../../../../../shared/src/business/entities/UserCase'; export const addExistingUserToCase = async ({ applicationContext, + authorizedUser, caseEntity, contactId, email, @@ -20,9 +22,8 @@ export const addExistingUserToCase = async ({ contactId: string; email: string; name: string; + authorizedUser: AuthUser; }): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_USER_TO_CASE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts index cd88a921088..e9354992e95 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts @@ -13,6 +13,7 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; import { defaults, pick } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -105,7 +106,7 @@ const updateCaseEntityAndGenerateChange = async ({ * @returns {object} the updated case data */ export const updatePetitionerInformation = async ( - applicationContext, + applicationContext: ServerApplicationContext, { docketNumber, updatedPetitionerData }, ) => { const user = applicationContext.getCurrentUser(); @@ -262,6 +263,7 @@ export const updatePetitionerInformation = async ( .getUseCaseHelpers() .addExistingUserToCase({ applicationContext, + authorizedUser: user, caseEntity, contactId: updatedPetitionerData.contactId, email: updatedPetitionerData.updatedEmail, From 46d610740631370b31997f595ca53ca4a52d3a45 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 10:40:33 -0700 Subject: [PATCH 112/523] 10417: Remove getCurrentUser from web-api --- .../associateIrsPractitionerToCase.test.ts | 10 ++++------ .../associateIrsPractitionerToCase.ts | 16 +++++----------- .../submitCaseAssociationRequestInteractor.ts | 1 + ...associateIrsPractitionerWithCaseInteractor.ts | 1 + 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.test.ts index 91e3acbe5b9..22c546ce952 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.test.ts @@ -9,10 +9,8 @@ import { import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { associateIrsPractitionerToCase } from './associateIrsPractitionerToCase'; -import { - docketClerkUser, - irsPractitionerUser, -} from '../../../../../shared/src/test/mockUsers'; +import { irsPractitionerUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('associateIrsPractitionerToCase', () => { let caseRecord1 = { @@ -42,8 +40,6 @@ describe('associateIrsPractitionerToCase', () => { }; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockResolvedValue(caseRecord1); @@ -56,6 +52,7 @@ describe('associateIrsPractitionerToCase', () => { await associateIrsPractitionerToCase({ applicationContext, + authorizedUser: mockDocketClerkUser, docketNumber: caseRecord1.docketNumber, serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, user: irsPractitionerUser, @@ -76,6 +73,7 @@ describe('associateIrsPractitionerToCase', () => { await associateIrsPractitionerToCase({ applicationContext, + authorizedUser: mockDocketClerkUser, docketNumber: caseRecord1.docketNumber, serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, user: irsPractitionerUser, diff --git a/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts b/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts index 6efa4c84dc5..747dc9a324f 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts @@ -1,29 +1,23 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { IrsPractitioner } from '../../../../../shared/src/business/entities/IrsPractitioner'; import { RawUser } from '@shared/business/entities/User'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UserCase } from '../../../../../shared/src/business/entities/UserCase'; -/** - * associateIrsPractitionerToCase - * @param {object} providers the providers object - * @param {object} providers.applicationContext the application context - * @param {string} providers.docketNumber the docket number of the case - * @param {string} providers.serviceIndicator the type of service the irsPractitioner should receive - * @param {object} providers.user the user object for the logged in user - * @returns {Promise<*>} the updated case entity - */ export const associateIrsPractitionerToCase = async ({ applicationContext, + authorizedUser, docketNumber, serviceIndicator, user, }: { applicationContext: ServerApplicationContext; + authorizedUser: AuthUser; docketNumber: string; serviceIndicator?: string; user: RawUser; -}) => { +}): Promise => { const isAssociated = await applicationContext .getPersistenceGateway() .verifyCaseForUser({ @@ -50,7 +44,7 @@ export const associateIrsPractitionerToCase = async ({ }); const caseEntity = new Case(caseToUpdate, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); caseEntity.attachIrsPractitioner( diff --git a/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts b/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts index c60af66be6a..5dd6fbfa49c 100644 --- a/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts +++ b/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts @@ -56,6 +56,7 @@ const submitCaseAssociationRequest = async ( .getUseCaseHelpers() .associateIrsPractitionerToCase({ applicationContext, + authorizedUser, docketNumber, user, }); diff --git a/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.ts b/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.ts index 1be714fdda7..c3373c2a721 100644 --- a/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.ts +++ b/web-api/src/business/useCases/manualAssociation/associateIrsPractitionerWithCaseInteractor.ts @@ -38,6 +38,7 @@ export const associateIrsPractitionerWithCaseInteractor = async ( return await associateIrsPractitionerToCase({ applicationContext, + authorizedUser, docketNumber, serviceIndicator, user, From ddd6de8fb32f664905d2205565480840207a5fd4 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 10:47:56 -0700 Subject: [PATCH 113/523] 10417: Remove getCurrentUser from web-api --- ...associatePrivatePractitionerToCase.test.ts | 40 ++++++++----------- .../associatePrivatePractitionerToCase.ts | 9 +++-- .../submitCaseAssociationRequestInteractor.ts | 1 + ...tePrivatePractitionerWithCaseInteractor.ts | 1 + 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.test.ts index 0c9ae6b1b68..0d336d5ddee 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.test.ts @@ -6,27 +6,18 @@ import { ROLES, SERVICE_INDICATOR_TYPES, } from '../../../../../shared/src/business/entities/EntityConstants'; -import { MOCK_USERS } from '../../../../../shared/src/test/mockUsers'; -import { RawUser } from '@shared/business/entities/User'; +import { MOCK_PRACTITIONER } from '@shared/test/mockUsers'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { associatePrivatePractitionerToCase } from './associatePrivatePractitionerToCase'; import { getContactPrimary, getContactSecondary, } from '../../../../../shared/src/business/entities/cases/Case'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('associatePrivatePractitionerToCase', () => { let caseRecord; - const practitionerUser: RawUser = { - barNumber: 'PT1234', - email: 'emmett@example.com', - entityName: 'User', - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.privatePractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - beforeEach(() => { caseRecord = { caseCaption: 'Case Caption', @@ -92,10 +83,6 @@ describe('associatePrivatePractitionerToCase', () => { userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', }; - applicationContext.getCurrentUser.mockReturnValue( - MOCK_USERS['a7d90c05-f6cd-442c-a168-202db587f16f'], - ); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockResolvedValue(caseRecord); @@ -108,9 +95,10 @@ describe('associatePrivatePractitionerToCase', () => { await associatePrivatePractitionerToCase({ applicationContext, + authorizedUser: mockDocketClerkUser, docketNumber: caseRecord.docketNumber, representing: [caseRecord.petitioners[0].contactId], - user: practitionerUser, + user: MOCK_PRACTITIONER, }); expect( @@ -128,9 +116,10 @@ describe('associatePrivatePractitionerToCase', () => { await associatePrivatePractitionerToCase({ applicationContext, + authorizedUser: mockDocketClerkUser, docketNumber: caseRecord.docketNumber, representing: [caseRecord.petitioners[0].contactId], - user: practitionerUser, + user: MOCK_PRACTITIONER, }); expect( @@ -148,13 +137,14 @@ describe('associatePrivatePractitionerToCase', () => { await associatePrivatePractitionerToCase({ applicationContext, + authorizedUser: mockDocketClerkUser, docketNumber: caseRecord.docketNumber, representing: [ caseRecord.petitioners[0].contactId, caseRecord.petitioners[1].contactId, caseRecord.petitioners[2].contactId, ], - user: practitionerUser, + user: MOCK_PRACTITIONER, }); const updatedCase = @@ -180,9 +170,10 @@ describe('associatePrivatePractitionerToCase', () => { await associatePrivatePractitionerToCase({ applicationContext, + authorizedUser: mockDocketClerkUser, docketNumber: caseRecord.docketNumber, representing: [caseRecord.petitioners[1].contactId], - user: practitionerUser, + user: MOCK_PRACTITIONER, }); const updatedCase = @@ -216,9 +207,10 @@ describe('associatePrivatePractitionerToCase', () => { await associatePrivatePractitionerToCase({ applicationContext, + authorizedUser: mockDocketClerkUser, docketNumber: caseRecord.docketNumber, representing: [], - user: practitionerUser, + user: MOCK_PRACTITIONER, }); expect( @@ -227,7 +219,7 @@ describe('associatePrivatePractitionerToCase', () => { expect(applicationContext.logger.error).toHaveBeenCalled(); expect(applicationContext.logger.error.mock.calls[0][0]).toEqual( - `BUG 9323: Private Practitioner with userId: ${practitionerUser.userId} was already associated with case ${caseRecord.docketNumber} but did not appear in the privatePractitioners array.`, + `BUG 9323: Private Practitioner with userId: ${MOCK_PRACTITIONER.userId} was already associated with case ${caseRecord.docketNumber} but did not appear in the privatePractitioners array.`, ); }); @@ -240,20 +232,20 @@ describe('associatePrivatePractitionerToCase', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockResolvedValueOnce({ ...caseRecord, - privatePractitioners: [{ userId: practitionerUser.userId }], + privatePractitioners: [{ userId: MOCK_PRACTITIONER.userId }], }); await associatePrivatePractitionerToCase({ applicationContext, + authorizedUser: mockDocketClerkUser, docketNumber: caseRecord.docketNumber, representing: [caseRecord.petitioners[0].contactId], - user: practitionerUser, + user: MOCK_PRACTITIONER, }); expect( applicationContext.getPersistenceGateway().associateUserWithCase, ).not.toHaveBeenCalled(); - expect(applicationContext.logger.error).not.toHaveBeenCalled(); }); }); diff --git a/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts b/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts index 33d264b3530..cc0cbb0b1e9 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts @@ -1,6 +1,7 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { PrivatePractitioner } from '../../../../../shared/src/business/entities/PrivatePractitioner'; -import { RawUser } from '@shared/business/entities/User'; +import { RawPractitioner } from '@shared/business/entities/Practitioner'; import { SERVICE_INDICATOR_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UserCase } from '../../../../../shared/src/business/entities/UserCase'; @@ -17,15 +18,17 @@ import { UserCase } from '../../../../../shared/src/business/entities/UserCase'; */ export const associatePrivatePractitionerToCase = async ({ applicationContext, + authorizedUser, docketNumber, representing = [], serviceIndicator, user, }: { applicationContext: ServerApplicationContext; + authorizedUser: AuthUser; docketNumber: string; serviceIndicator?: string; - user: RawUser; + user: RawPractitioner; representing: string[]; }) => { const isAssociated = await applicationContext @@ -58,7 +61,7 @@ export const associatePrivatePractitionerToCase = async ({ }); const caseEntity = new Case(caseToUpdate, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const { petitioners } = caseEntity; diff --git a/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts b/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts index 5dd6fbfa49c..721e54ee872 100644 --- a/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts +++ b/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts @@ -47,6 +47,7 @@ const submitCaseAssociationRequest = async ( .getUseCaseHelpers() .associatePrivatePractitionerToCase({ applicationContext, + authorizedUser, docketNumber, representing: filers, user, diff --git a/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts b/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts index 3eb5b917d14..9a088e52f2e 100644 --- a/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts +++ b/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts @@ -45,6 +45,7 @@ export const associatePrivatePractitionerWithCase = async ( return await associatePrivatePractitionerToCase({ applicationContext, + authorizedUser: authenticatedUser, docketNumber, representing, serviceIndicator, From ae6b33ca252e1327655cbbaea27e5a03edb0e969 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 10:52:24 -0700 Subject: [PATCH 114/523] 10417: Remove getCurrentUser from web-api --- .../createCaseAndAssociations.test.ts | 22 ++++++++++++++++--- .../createCaseAndAssociations.ts | 5 ++++- .../useCases/createCaseFromPaperInteractor.ts | 1 + .../business/useCases/createCaseInteractor.ts | 1 + 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts index 1f8ec480741..c8f281dd1ac 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts @@ -41,6 +41,7 @@ describe('createCaseAndAssociations', () => { it('always sends valid entities to the createCase persistence method', async () => { await createCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToCreate: validMockCase, }); expect(createCaseMock).toHaveBeenCalled(); @@ -56,7 +57,11 @@ describe('createCaseAndAssociations', () => { docketEntries: [{ docketNumber: 'peaches' }], }; await expect( - createCaseAndAssociations({ applicationContext, caseToCreate }), + createCaseAndAssociations({ + applicationContext, + authorizedUser: mockDocketClerkUser, + caseToCreate, + }), ).rejects.toThrow('entity was invalid'); }); @@ -69,6 +74,7 @@ describe('createCaseAndAssociations', () => { await createCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToCreate, }); @@ -114,13 +120,18 @@ describe('createCaseAndAssociations', () => { irsPractitioners: [{ barNumber: 0, role: 'spring', userId: 'yoohoo' }], }; await expect( - createCaseAndAssociations({ applicationContext, caseToCreate }), + createCaseAndAssociations({ + applicationContext, + authorizedUser: mockDocketClerkUser, + caseToCreate, + }), ).rejects.toThrow('entity was invalid'); }); it('calls updateIrsPractitionerOnCase once for each IRS practitioner on the case', async () => { await createCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToCreate: mockCaseWithIrsPractitioners, }); @@ -163,13 +174,18 @@ describe('createCaseAndAssociations', () => { ], }; await expect( - createCaseAndAssociations({ applicationContext, caseToCreate }), + createCaseAndAssociations({ + applicationContext, + authorizedUser: mockDocketClerkUser, + caseToCreate, + }), ).rejects.toThrow('entity was invalid'); }); it('calls updateprivatePractitionerOnCase once for each private practitioner on the case', async () => { await createCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToCreate: mockCaseWithPrivatePractitioners, }); diff --git a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts index 8c6ff311c46..56140118588 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; import { IrsPractitioner } from '../../../../../shared/src/business/entities/IrsPractitioner'; @@ -99,15 +100,17 @@ const connectPrivatePractitioners = ({ */ export const createCaseAndAssociations = async ({ applicationContext, + authorizedUser, caseToCreate, }: { applicationContext: ServerApplicationContext; + authorizedUser: AuthUser; caseToCreate: any; }) => { const caseEntity = caseToCreate.validate ? caseToCreate : new Case(caseToCreate, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const validRawCaseEntity = caseEntity.validate().toRawObject(); diff --git a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts index e3525c443e8..613f0b2cd68 100644 --- a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts +++ b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts @@ -286,6 +286,7 @@ export const createCaseFromPaperInteractor = async ( await Promise.all([ applicationContext.getUseCaseHelpers().createCaseAndAssociations({ applicationContext, + authorizedUser, caseToCreate: caseToAdd.validate().toRawObject(), }), applicationContext.getPersistenceGateway().saveWorkItem({ diff --git a/web-api/src/business/useCases/createCaseInteractor.ts b/web-api/src/business/useCases/createCaseInteractor.ts index fec6318eaf9..2317b7fe905 100644 --- a/web-api/src/business/useCases/createCaseInteractor.ts +++ b/web-api/src/business/useCases/createCaseInteractor.ts @@ -273,6 +273,7 @@ export const createCaseInteractor = async ( await applicationContext.getUseCaseHelpers().createCaseAndAssociations({ applicationContext, + authorizedUser, caseToCreate: caseToAdd.validate().toRawObject(), }); From 790dc1b6c4438872a57ef65a54e41ee04a0907a4 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 10:56:45 -0700 Subject: [PATCH 115/523] 10417: Remove getCurrentUser from web-api --- .../createUserForContact.test.ts | 10 ++++---- .../caseAssociation/createUserForContact.ts | 24 +++++++++---------- .../updatePetitionerInformationInteractor.ts | 1 + 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.test.ts index d492c41caa8..f82e6095ba0 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.test.ts @@ -13,6 +13,7 @@ import { createUserForContact } from './createUserForContact'; import { mockAdmissionsClerkUser, mockDocketClerkUser, + mockPetitionerUser, } from '@shared/test/mockAuthUsers'; describe('createUserForContact', () => { @@ -23,11 +24,10 @@ describe('createUserForContact', () => { }); it('should throw an unauthorized error for non admissionsclerk users', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( createUserForContact({ applicationContext, + authorizedUser: mockPetitionerUser, caseEntity: new Case(MOCK_CASE, { authorizedUser: mockDocketClerkUser, }), @@ -40,7 +40,6 @@ describe('createUserForContact', () => { it('should call createNewPetitionerUser with the new user entity', async () => { const UPDATED_EMAIL = 'testing@example.com'; - const caseEntity = new Case( { ...MOCK_CASE, @@ -60,6 +59,7 @@ describe('createUserForContact', () => { await createUserForContact({ applicationContext, + authorizedUser: mockAdmissionsClerkUser, caseEntity, contactId: USER_ID, email: UPDATED_EMAIL, @@ -80,7 +80,6 @@ describe('createUserForContact', () => { it('should return the caseEntity', async () => { const UPDATED_EMAIL = 'testing@example.com'; - const caseEntity = new Case( { ...MOCK_CASE, @@ -99,6 +98,7 @@ describe('createUserForContact', () => { const updatedCase = await createUserForContact({ applicationContext, + authorizedUser: mockAdmissionsClerkUser, caseEntity, contactId: USER_ID, email: UPDATED_EMAIL, @@ -110,7 +110,6 @@ describe('createUserForContact', () => { it('should call associateUserWithCase', async () => { const UPDATED_EMAIL = 'testing@example.com'; - const caseEntity = new Case( { ...MOCK_CASE, @@ -129,6 +128,7 @@ describe('createUserForContact', () => { await createUserForContact({ applicationContext, + authorizedUser: mockAdmissionsClerkUser, caseEntity, contactId: USER_ID, email: UPDATED_EMAIL, diff --git a/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.ts b/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.ts index 06533c737be..e9f14d0a933 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/createUserForContact.ts @@ -1,30 +1,30 @@ +import { Case } from '@shared/business/entities/cases/Case'; import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ROLE_PERMISSIONS, isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; import { UserCase } from '../../../../../shared/src/business/entities/UserCase'; -/** - * createUserForContact - * - * @param {object} options.contactId the id of the contact to create user for - * @param {object} options.caseEntity the case entity to modify and return - * @param {string} options.email the email address for the user we are attaching to the case - * @param {string} options.name the name of the user to update the case with - * @returns {Case} the updated case entity - */ export const createUserForContact = async ({ applicationContext, + authorizedUser, caseEntity, contactId, email, name, -}) => { - const authorizedUser = applicationContext.getCurrentUser(); - +}: { + applicationContext: ServerApplicationContext; + authorizedUser: UnknownAuthUser; + caseEntity: Case; + contactId: string; + email: string; + name: string; +}): Promise => { if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_USER_TO_CASE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts index e9354992e95..2855c82dcdb 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts @@ -253,6 +253,7 @@ export const updatePetitionerInformation = async ( .getUseCaseHelpers() .createUserForContact({ applicationContext, + authorizedUser: user, caseEntity, contactId: updatedPetitionerData.contactId, email: updatedPetitionerData.updatedEmail, From 3b94dd1a546a0c59ad5c1e9dd17fcd1aec6386df Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 11:29:05 -0700 Subject: [PATCH 116/523] 10417: Remove getCurrentUser from getFormattedCaseDetail --- .../src/authorization/getUserPermissions.ts | 1 + .../utilities/getFormattedCaseDetail.test.ts | 473 +++++++++++------- .../utilities/getFormattedCaseDetail.ts | 13 +- shared/src/test/mockUsers.ts | 3 + ...faultDraftViewerDocumentToDisplayAction.ts | 3 +- ...aultViewerCorrespondenceToDisplayAction.ts | 3 +- .../computeds/caseInventoryReportHelper.ts | 3 +- ....getCalendarDetailsForTrialSession.test.ts | 6 +- .../computeds/formattedCaseDetail.test.ts | 7 +- .../computeds/formattedCaseDetail.ts | 12 +- .../computeds/formattedDocketEntries.test.ts | 7 +- .../computeds/formattedDocketEntries.ts | 4 +- .../computeds/formattedMessageDetail.test.ts | 12 +- .../computeds/formattedMessageDetail.ts | 4 +- .../computeds/messageDocumentHelper.test.ts | 7 +- .../computeds/messageDocumentHelper.ts | 4 +- 16 files changed, 326 insertions(+), 236 deletions(-) diff --git a/shared/src/authorization/getUserPermissions.ts b/shared/src/authorization/getUserPermissions.ts index 4b9d605f7dd..7dca670b56b 100644 --- a/shared/src/authorization/getUserPermissions.ts +++ b/shared/src/authorization/getUserPermissions.ts @@ -1,5 +1,6 @@ import { ROLE_PERMISSIONS, isAuthorized } from './authorizationClientService'; import { RawIrsPractitioner } from '@shared/business/entities/IrsPractitioner'; +import { RawPractitioner } from '@shared/business/entities/Practitioner'; import { RawUser } from '@shared/business/entities/User'; /** diff --git a/shared/src/business/utilities/getFormattedCaseDetail.test.ts b/shared/src/business/utilities/getFormattedCaseDetail.test.ts index 9bc7b1cb9d6..4bd2546393b 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.test.ts +++ b/shared/src/business/utilities/getFormattedCaseDetail.test.ts @@ -1,42 +1,47 @@ import { CASE_STATUS_TYPES, PAYMENT_STATUS } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; -import { MOCK_USERS } from '../../test/mockUsers'; import { applicationContext } from '../../../../web-client/src/applicationContext'; import { formatCase, getFormattedCaseDetail } from './getFormattedCaseDetail'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getFormattedCaseDetail', () => { - applicationContext.getCurrentUser = () => - MOCK_USERS['a7d90c05-f6cd-442c-a168-202db587f16f']; - const getDateISO = () => applicationContext.getUtilities().createISODateString(); describe('formatCase', () => { it('should set showPrintConfirmationLink to true for served cases without legacy docket entries', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - docketEntries: [ - { - ...MOCK_CASE.docketEntries[0], - servedAt: getDateISO(), - }, - ], - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + docketEntries: [ + { + ...MOCK_CASE.docketEntries[0], + servedAt: getDateISO(), + }, + ], + }, + mockDocketClerkUser, + ); expect(result.showPrintConfirmationLink).toBeTruthy(); }); it('should set showPrintConfirmationLink to false for served cases with legacy docket entries', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - docketEntries: [ - { - ...MOCK_CASE.docketEntries[0], - isLegacy: true, - servedAt: getDateISO(), - }, - ], - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + docketEntries: [ + { + ...MOCK_CASE.docketEntries[0], + isLegacy: true, + servedAt: getDateISO(), + }, + ], + }, + mockDocketClerkUser, + ); expect(result.showPrintConfirmationLink).toBeFalsy(); }); @@ -44,59 +49,71 @@ describe('getFormattedCaseDetail', () => { it('should return an empty object if caseDetail is empty', () => { const mockApplicationContext = {}; const caseDetail = {}; - const result = formatCase(mockApplicationContext, caseDetail); + const result = formatCase( + mockApplicationContext, + caseDetail, + mockDocketClerkUser, + ); expect(result).toMatchObject({}); }); it('should format the filing date of all correspondence documents', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - correspondence: [ - { - documentTitle: 'Test Correspondence', - filedBy: 'Test Docket Clerk', - filingDate: '2020-05-21T18:21:59.818Z', - }, - ], - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + correspondence: [ + { + documentTitle: 'Test Correspondence', + filedBy: 'Test Docket Clerk', + filingDate: '2020-05-21T18:21:59.818Z', + }, + ], + }, + mockDocketClerkUser, + ); expect(result.correspondence[0].formattedFilingDate).toEqual('05/21/20'); }); it('should return docket entries with pending and served documents for pendingItemsDocketEntries', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - docketEntries: [ - { - createdAt: getDateISO(), - docketEntryId: '47d9735b-ac41-4adf-8a3c-74d73d3622fb', - documentType: 'Administrative Record', - filingDate: getDateISO(), - index: '1', - isOnDocketRecord: true, - pending: true, - servedAt: '2019-08-25T05:00:00.000Z', - }, - { - createdAt: getDateISO(), - docketEntryId: 'dabe913f-5310-48df-b63d-44cfccb83326', - documentType: 'Administrative Record', - filingDate: getDateISO(), - index: '2', - isOnDocketRecord: true, - pending: true, - }, - { - createdAt: getDateISO(), - docketEntryId: '6936570f-04ad-40bf-b8a2-a7ac648c30c4', - documentType: 'Administrative Record', - filingDate: getDateISO(), - index: '3', - isOnDocketRecord: true, - }, - ], - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + docketEntries: [ + { + createdAt: getDateISO(), + docketEntryId: '47d9735b-ac41-4adf-8a3c-74d73d3622fb', + documentType: 'Administrative Record', + filingDate: getDateISO(), + index: '1', + isOnDocketRecord: true, + pending: true, + servedAt: '2019-08-25T05:00:00.000Z', + }, + { + createdAt: getDateISO(), + docketEntryId: 'dabe913f-5310-48df-b63d-44cfccb83326', + documentType: 'Administrative Record', + filingDate: getDateISO(), + index: '2', + isOnDocketRecord: true, + pending: true, + }, + { + createdAt: getDateISO(), + docketEntryId: '6936570f-04ad-40bf-b8a2-a7ac648c30c4', + documentType: 'Administrative Record', + filingDate: getDateISO(), + index: '3', + isOnDocketRecord: true, + }, + ], + }, + mockDocketClerkUser, + ); expect(result.pendingItemsDocketEntries).toMatchObject([ { @@ -106,16 +123,20 @@ describe('getFormattedCaseDetail', () => { }); it('should return docket entries with pending and isLegacyServed for pendingItemsDocketEntries', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - docketEntries: [ - { - ...MOCK_CASE.docketEntries[0], - isLegacyServed: true, - pending: true, - }, - ], - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + docketEntries: [ + { + ...MOCK_CASE.docketEntries[0], + isLegacyServed: true, + pending: true, + }, + ], + }, + mockDocketClerkUser, + ); expect(result.pendingItemsDocketEntries).toMatchObject([ { @@ -125,24 +146,32 @@ describe('getFormattedCaseDetail', () => { }); it('should return an empty array for formattedDocketEntries and pendingItemsDocketEntries if docketRecord does not exist', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - docketEntries: [], - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + docketEntries: [], + }, + mockDocketClerkUser, + ); expect(result.formattedDocketEntries).toEqual([]); expect(result.pendingItemsDocketEntries).toEqual([]); }); it('should format irsPractitioners if the irsPractitioners array is set', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - irsPractitioners: [ - { - name: 'Test Respondent', - }, - ], - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + irsPractitioners: [ + { + name: 'Test Respondent', + }, + ], + }, + mockDocketClerkUser, + ); expect(result.irsPractitioners[0].formattedName).toEqual( 'Test Respondent', @@ -150,16 +179,20 @@ describe('getFormattedCaseDetail', () => { }); it('should format privatePractitioners if the privatePractitioners array is set', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - privatePractitioners: [ - { - barNumber: 'b1234', - name: 'Test Practitioner', - representing: [MOCK_CASE.petitioners[0].contactId], - }, - ], - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + privatePractitioners: [ + { + barNumber: 'b1234', + name: 'Test Practitioner', + representing: [MOCK_CASE.petitioners[0].contactId], + }, + ], + }, + mockDocketClerkUser, + ); expect(result.privatePractitioners[0].formattedName).toEqual( 'Test Practitioner (b1234)', @@ -174,14 +207,18 @@ describe('getFormattedCaseDetail', () => { }); it('should format the general properties of case details', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - caseCaption: 'Johnny Joe Jacobson, Petitioner', - hasVerifiedIrsNotice: true, - irsNoticeDate: undefined, - preferredTrialCity: undefined, - trialTime: 11, - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + caseCaption: 'Johnny Joe Jacobson, Petitioner', + hasVerifiedIrsNotice: true, + irsNoticeDate: undefined, + preferredTrialCity: undefined, + trialTime: 11, + }, + mockDocketClerkUser, + ); expect(result).toHaveProperty('createdAtFormatted'); expect(result).toHaveProperty('receivedAtFormatted'); @@ -194,10 +231,14 @@ describe('getFormattedCaseDetail', () => { }); it('should format irs notice date', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - irsNoticeDate: getDateISO(), - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + irsNoticeDate: getDateISO(), + }, + mockDocketClerkUser, + ); expect(result.irsNoticeDateFormatted).toEqual( applicationContext @@ -207,22 +248,30 @@ describe('getFormattedCaseDetail', () => { }); it("should return 'No notice provided' when there is no irs notice date", () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - irsNoticeDate: undefined, - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + irsNoticeDate: undefined, + }, + mockDocketClerkUser, + ); expect(result.irsNoticeDateFormatted).toEqual('No notice provided'); }); describe('should indicate blocked status', () => { it('should format blockedDate and when blocked is true', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - blocked: true, - blockedDate: getDateISO(), - blockedReason: 'for reasons', - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + blocked: true, + blockedDate: getDateISO(), + blockedReason: 'for reasons', + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ blockedDateFormatted: applicationContext @@ -234,13 +283,17 @@ describe('getFormattedCaseDetail', () => { }); it('should format trial details if case status is calendared', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - status: CASE_STATUS_TYPES.calendared, - trialDate: '2011-11-11T05:00:00.000Z', - trialLocation: 'Boise, Idaho', - trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + status: CASE_STATUS_TYPES.calendared, + trialDate: '2011-11-11T05:00:00.000Z', + trialLocation: 'Boise, Idaho', + trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ formattedAssociatedJudge: 'Not assigned', @@ -254,13 +307,17 @@ describe('getFormattedCaseDetail', () => { }); it('should format trial details if case status is not calendared but the case has a trialSessionId', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - trialDate: '2011-11-11T05:00:00.000Z', - trialLocation: 'Boise, Idaho', - trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - trialTime: '2:00', - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + trialDate: '2011-11-11T05:00:00.000Z', + trialLocation: 'Boise, Idaho', + trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + trialTime: '2:00', + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ formattedAssociatedJudge: 'Not assigned', @@ -274,23 +331,27 @@ describe('getFormattedCaseDetail', () => { }); it('should format hearing details if the case has associated hearings', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - hearings: [ - { - judge: { - name: 'Judge Dredd', + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + hearings: [ + { + judge: { + name: 'Judge Dredd', + }, + startDate: '2011-11-11T05:00:00.000Z', + startTime: '10:00', + trialLocation: 'Megacity One', }, - startDate: '2011-11-11T05:00:00.000Z', - startTime: '10:00', - trialLocation: 'Megacity One', - }, - ], - status: CASE_STATUS_TYPES.calendared, - trialDate: '2011-11-11T05:00:00.000Z', - trialLocation: 'Boise, Idaho', - trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - }); + ], + status: CASE_STATUS_TYPES.calendared, + trialDate: '2011-11-11T05:00:00.000Z', + trialLocation: 'Boise, Idaho', + trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ formattedAssociatedJudge: 'Not assigned', @@ -317,13 +378,17 @@ describe('getFormattedCaseDetail', () => { }); it('should format trial details with incomplete trial information', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - status: CASE_STATUS_TYPES.calendared, - trialDate: undefined, - trialLocation: undefined, - trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + status: CASE_STATUS_TYPES.calendared, + trialDate: undefined, + trialLocation: undefined, + trialSessionId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ formattedTrialCity: 'Not assigned', @@ -332,7 +397,11 @@ describe('getFormattedCaseDetail', () => { }); it('should show not scheduled section if case status is not calendared and case is not blocked', () => { - const result = formatCase(applicationContext, MOCK_CASE); + const result = formatCase( + applicationContext, + MOCK_CASE, + mockDocketClerkUser, + ); expect(result).toMatchObject({ showNotScheduled: true, @@ -340,39 +409,55 @@ describe('getFormattedCaseDetail', () => { }); it('should return showNotScheduled as true when the case has not been added to a trial session', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - status: CASE_STATUS_TYPES.closed, - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + status: CASE_STATUS_TYPES.closed, + }, + mockDocketClerkUser, + ); expect(result.showNotScheduled).toBeTruthy(); }); it('should return showNotScheduled as false when the case status is closed and has been added to a trial session', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - status: CASE_STATUS_TYPES.closed, - trialSessionId: '4f8bd637-fc3b-4073-85b4-388f22731854', - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + status: CASE_STATUS_TYPES.closed, + trialSessionId: '4f8bd637-fc3b-4073-85b4-388f22731854', + }, + mockDocketClerkUser, + ); expect(result.showNotScheduled).toBeFalsy(); }); it('should return showScheduled as true when case status is closed and has been added to a trial session', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - status: CASE_STATUS_TYPES.closed, - trialSessionId: '4f8bd637-fc3b-4073-85b4-388f22731854', - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + status: CASE_STATUS_TYPES.closed, + trialSessionId: '4f8bd637-fc3b-4073-85b4-388f22731854', + }, + mockDocketClerkUser, + ); expect(result.showScheduled).toBeTruthy(); }); it('should set defaults for formattedTrialDate and formattedAssociatedJudge and show the prioritized section if case is high priority', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - highPriority: true, - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + highPriority: true, + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ formattedAssociatedJudge: 'Not assigned', @@ -382,10 +467,14 @@ describe('getFormattedCaseDetail', () => { }); it("should set lead case attributes when the leadDocketNumber matches the current case's docketNumber", () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - leadDocketNumber: MOCK_CASE.docketNumber, - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + leadDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ consolidatedIconTooltipText: 'Lead case', @@ -394,10 +483,14 @@ describe('getFormattedCaseDetail', () => { }); it("should not set lead case attributes when the leadDocketNumber does not match the current case's docket number", () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - leadDocketNumber: 'notthedocketNumber', - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + leadDocketNumber: 'notthedocketNumber', + }, + mockDocketClerkUser, + ); expect(result).toMatchObject({ consolidatedIconTooltipText: 'Consolidated case', @@ -406,10 +499,14 @@ describe('getFormattedCaseDetail', () => { }); it('should set consolidated cases if there are any', () => { - const result = formatCase(applicationContext, { - ...MOCK_CASE, - consolidatedCases: [MOCK_CASE], - }); + const result = formatCase( + applicationContext, + { + ...MOCK_CASE, + consolidatedCases: [MOCK_CASE], + }, + mockDocketClerkUser, + ); expect(result).toHaveProperty('consolidatedCases'); expect(result.consolidatedCases).toMatchObject([MOCK_CASE]); diff --git a/shared/src/business/utilities/getFormattedCaseDetail.ts b/shared/src/business/utilities/getFormattedCaseDetail.ts index 884191d4c73..dd8800f004d 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.ts +++ b/shared/src/business/utilities/getFormattedCaseDetail.ts @@ -15,6 +15,7 @@ import { combineISOandEasternTime, formatDateString, } from './DateHandler'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { cloneDeep, isEmpty, sortBy } from 'lodash'; const computeIsInProgress = ({ formattedEntry }) => { @@ -262,7 +263,11 @@ export const getEditUrl = ({ : `/case-detail/${docketNumber}/edit-order/${docketEntryId}`; }; -export const formatCase = (applicationContext, caseDetail) => { +export const formatCase = ( + applicationContext, + caseDetail, + authorizedUser: UnknownAuthUser, +) => { if (isEmpty(caseDetail)) { return {}; } @@ -376,7 +381,7 @@ export const formatCase = (applicationContext, caseDetail) => { result.filingFee = `${caseDetail.petitionPaymentStatus} ${paymentDate} ${paymentMethod}`; const caseEntity = new Case(caseDetail, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); result.canConsolidate = caseEntity.canConsolidate(); result.canUnconsolidate = !!caseEntity.leadDocketNumber; @@ -387,7 +392,7 @@ export const formatCase = (applicationContext, caseDetail) => { if (result.consolidatedCases) { result.consolidatedCases = result.consolidatedCases.map( consolidatedCase => { - return formatCase(applicationContext, consolidatedCase); + return formatCase(applicationContext, consolidatedCase, authorizedUser); }, ); } @@ -494,7 +499,7 @@ export const getFormattedCaseDetail = ({ ...applicationContext .getUtilities() .setServiceIndicatorsForCase(caseDetail), - ...formatCase(applicationContext, caseDetail), + ...formatCase(applicationContext, caseDetail), // TODO 10417 Needd to get an authorizedUser here }; result.formattedDocketEntries = sortDocketEntries( result.formattedDocketEntries, diff --git a/shared/src/test/mockUsers.ts b/shared/src/test/mockUsers.ts index c30b2a03d8c..90490462bed 100644 --- a/shared/src/test/mockUsers.ts +++ b/shared/src/test/mockUsers.ts @@ -40,6 +40,8 @@ export const colvinsChambersUser = { }; export const clerkOfCourtUser = { + email: 'theClerkUser@example.com', + name: 'Caster Clerk', role: ROLES.clerkOfCourt, userId: 'b6e4a5ac-c006-4b47-a5f0-67028372cd63', }; @@ -140,6 +142,7 @@ export const caseServicesSupervisorUser = { }; export const docketClerkUser = { + email: 'theDocketMocket@example.com', name: 'Docketclerk', role: ROLES.docketClerk, section: DOCKET_SECTION, diff --git a/web-client/src/presenter/actions/getDefaultDraftViewerDocumentToDisplayAction.ts b/web-client/src/presenter/actions/getDefaultDraftViewerDocumentToDisplayAction.ts index c1786f1b220..41f75dc8cdb 100644 --- a/web-client/src/presenter/actions/getDefaultDraftViewerDocumentToDisplayAction.ts +++ b/web-client/src/presenter/actions/getDefaultDraftViewerDocumentToDisplayAction.ts @@ -13,6 +13,7 @@ export const getDefaultDraftViewerDocumentToDisplayAction = ({ applicationContext, get, }: ActionProps) => { + const user = get(state.user); const draftDocketEntryId = get(state.draftDocumentViewerDocketEntryId) || get(state.screenMetadata.draftDocumentViewerDocketEntryId); @@ -20,7 +21,7 @@ export const getDefaultDraftViewerDocumentToDisplayAction = ({ const caseDetail = get(state.caseDetail); const { draftDocuments } = applicationContext .getUtilities() - .formatCase(applicationContext, cloneDeep(caseDetail)); + .formatCase(applicationContext, cloneDeep(caseDetail), user); let viewerDraftDocumentToDisplay = draftDocuments[0]; diff --git a/web-client/src/presenter/actions/getDefaultViewerCorrespondenceToDisplayAction.ts b/web-client/src/presenter/actions/getDefaultViewerCorrespondenceToDisplayAction.ts index ccbe6f7aea1..169216eb2a0 100644 --- a/web-client/src/presenter/actions/getDefaultViewerCorrespondenceToDisplayAction.ts +++ b/web-client/src/presenter/actions/getDefaultViewerCorrespondenceToDisplayAction.ts @@ -16,12 +16,13 @@ export const getDefaultViewerCorrespondenceToDisplayAction = ({ }: ActionProps) => { const { correspondenceId } = props; let viewerCorrespondenceToDisplay = null; + const user = get(state.user); const caseDetail = get(state.caseDetail); const { correspondence } = applicationContext .getUtilities() - .formatCase(applicationContext, cloneDeep(caseDetail)); + .formatCase(applicationContext, cloneDeep(caseDetail), user); if (correspondenceId) { viewerCorrespondenceToDisplay = correspondence.find( diff --git a/web-client/src/presenter/computeds/caseInventoryReportHelper.ts b/web-client/src/presenter/computeds/caseInventoryReportHelper.ts index 9d3772ba348..7021e37fe0e 100644 --- a/web-client/src/presenter/computeds/caseInventoryReportHelper.ts +++ b/web-client/src/presenter/computeds/caseInventoryReportHelper.ts @@ -35,10 +35,11 @@ export const caseInventoryReportHelper = ( } const reportData = get(state.caseInventoryReportData.foundCases) || []; + const user = get(state.user); const formattedReportData = reportData .sort(applicationContext.getUtilities().compareCasesByDocketNumber) - .map(item => formatCase(applicationContext, item)); + .map(item => formatCase(applicationContext, item, user)); let displayedCount = resultCount < CASE_INVENTORY_PAGE_SIZE diff --git a/web-client/src/presenter/computeds/formattedCaseDetail.getCalendarDetailsForTrialSession.test.ts b/web-client/src/presenter/computeds/formattedCaseDetail.getCalendarDetailsForTrialSession.test.ts index 28cf341571a..ed8f43710bc 100644 --- a/web-client/src/presenter/computeds/formattedCaseDetail.getCalendarDetailsForTrialSession.test.ts +++ b/web-client/src/presenter/computeds/formattedCaseDetail.getCalendarDetailsForTrialSession.test.ts @@ -6,7 +6,6 @@ import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; describe('getCalendarDetailsForTrialSession', () => { - let globalUser; const { STATUS_TYPES, USER_ROLES } = applicationContext.getConstants(); const petitionsClerkUser = { @@ -18,16 +17,13 @@ describe('getCalendarDetailsForTrialSession', () => { formattedCaseDetailComputed, { ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, }, ); const getBaseState = user => { - globalUser = user; return { permissions: getUserPermissions(user), + user, }; }; diff --git a/web-client/src/presenter/computeds/formattedCaseDetail.test.ts b/web-client/src/presenter/computeds/formattedCaseDetail.test.ts index d6cf014597b..16c5ac14af4 100644 --- a/web-client/src/presenter/computeds/formattedCaseDetail.test.ts +++ b/web-client/src/presenter/computeds/formattedCaseDetail.test.ts @@ -45,23 +45,19 @@ export const mockPetitioners = [ ]; describe('formattedCaseDetail', () => { - let globalUser; const { STATUS_TYPES } = applicationContext.getConstants(); const formattedCaseDetail = withAppContextDecorator( formattedCaseDetailComputed, { ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, }, ); const getBaseState = user => { - globalUser = user; return { permissions: getUserPermissions(user), + user, }; }; @@ -214,6 +210,7 @@ describe('formattedCaseDetail', () => { it('should set contactTypeDisplay on a contact/petitioner', () => { const result = runCompute(formattedCaseDetail, { state: { + ...getBaseState(petitionsClerkUser), caseDetail: { ...MOCK_CASE, petitioners: [ diff --git a/web-client/src/presenter/computeds/formattedCaseDetail.ts b/web-client/src/presenter/computeds/formattedCaseDetail.ts index dcae982cd60..664a579ca64 100644 --- a/web-client/src/presenter/computeds/formattedCaseDetail.ts +++ b/web-client/src/presenter/computeds/formattedCaseDetail.ts @@ -9,7 +9,9 @@ export const formattedOpenCases = ( const { formatCase } = applicationContext.getUtilities(); const cases = get(state.openCases); - return cases.map(myCase => formatCase(applicationContext, myCase)); + const user = get(state.user); + + return cases.map(myCase => formatCase(applicationContext, myCase, user)); }; export const formattedClosedCases = ( @@ -17,9 +19,10 @@ export const formattedClosedCases = ( applicationContext: ClientApplicationContext, ): any => { const { formatCase } = applicationContext.getUtilities(); + const user = get(state.user); const cases = get(state.closedCases); - return cases.map(myCase => formatCase(applicationContext, myCase)); + return cases.map(myCase => formatCase(applicationContext, myCase, user)); }; export const getUserIsAssignedToSession = ({ @@ -82,16 +85,15 @@ export const formattedCaseDetail = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const user = applicationContext.getCurrentUser(); - const { formatCase, setServiceIndicatorsForCase } = applicationContext.getUtilities(); const caseDetail = get(state.caseDetail); + const user = get(state.user); const result = { ...setServiceIndicatorsForCase(caseDetail), - ...formatCase(applicationContext, caseDetail), + ...formatCase(applicationContext, caseDetail, user), }; result.petitioners = applicationContext diff --git a/web-client/src/presenter/computeds/formattedDocketEntries.test.ts b/web-client/src/presenter/computeds/formattedDocketEntries.test.ts index b93fdeeda1d..6742f25475f 100644 --- a/web-client/src/presenter/computeds/formattedDocketEntries.test.ts +++ b/web-client/src/presenter/computeds/formattedDocketEntries.test.ts @@ -44,14 +44,10 @@ describe('formattedDocketEntries', () => { formattedDocketEntriesComputed, { ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, }, ); const getBaseState = user => { - globalUser = user; return { documentsSelectedForDownload: [], featureFlags: { @@ -62,11 +58,10 @@ describe('formattedDocketEntries', () => { sessionMetadata: { docketRecordFilter: DOCKET_RECORD_FILTER_OPTIONS.allDocuments, }, + user, }; }; - let globalUser; - it('does not error and returns expected empty values on empty caseDetail', () => { const result = runCompute(formattedDocketEntries, { state: { diff --git a/web-client/src/presenter/computeds/formattedDocketEntries.ts b/web-client/src/presenter/computeds/formattedDocketEntries.ts index 1beeafe4d2b..cd44210db60 100644 --- a/web-client/src/presenter/computeds/formattedDocketEntries.ts +++ b/web-client/src/presenter/computeds/formattedDocketEntries.ts @@ -203,7 +203,7 @@ export const formattedDocketEntries = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const permissions = get(state.permissions); const { docketRecordFilter } = get(state.sessionMetadata); const { ALLOWLIST_FEATURE_FLAGS } = applicationContext.getConstants(); @@ -225,7 +225,7 @@ export const formattedDocketEntries = ( .getUtilities() .prepareDateFromString(DOCUMENT_VISIBILITY_POLICY_CHANGE_DATE) .toISO(); - const result = formatCase(applicationContext, caseDetail); + const result = formatCase(applicationContext, caseDetail, user); const documentsSelectedForDownload = get(state.documentsSelectedForDownload); result.formattedDocketEntries = applicationContext diff --git a/web-client/src/presenter/computeds/formattedMessageDetail.test.ts b/web-client/src/presenter/computeds/formattedMessageDetail.test.ts index c93a4ea791e..3e20bcd78c8 100644 --- a/web-client/src/presenter/computeds/formattedMessageDetail.test.ts +++ b/web-client/src/presenter/computeds/formattedMessageDetail.test.ts @@ -348,8 +348,6 @@ describe('formattedMessageDetail', () => { describe('showActionButtons', () => { it('should be true when message is NOT completed and user role is NOT general', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - const result = runCompute(formattedMessageDetail, { state: { caseDetail: { @@ -371,6 +369,7 @@ describe('formattedMessageDetail', () => { messageId: '98a9dbc4-a8d1-459b-98b2-30235b596d70', }, ], + user: petitionsClerkUser, }, }); @@ -378,8 +377,6 @@ describe('formattedMessageDetail', () => { }); it('should be false when message is NOT completed and user role is general', () => { - applicationContext.getCurrentUser.mockReturnValue(generalUser); - const result = runCompute(formattedMessageDetail, { state: { caseDetail: { @@ -401,6 +398,7 @@ describe('formattedMessageDetail', () => { messageId: '98a9dbc4-a8d1-459b-98b2-30235b596d70', }, ], + user: generalUser, }, }); @@ -408,8 +406,6 @@ describe('formattedMessageDetail', () => { }); it('should be false when message is completed and user role is NOT general', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - const result = runCompute(formattedMessageDetail, { state: { caseDetail: { @@ -431,6 +427,7 @@ describe('formattedMessageDetail', () => { messageId: '98a9dbc4-a8d1-459b-98b2-30235b596d70', }, ], + user: petitionsClerkUser, }, }); @@ -438,8 +435,6 @@ describe('formattedMessageDetail', () => { }); it('should be false when message is completed and user role is general', () => { - applicationContext.getCurrentUser.mockReturnValue(generalUser); - const result = runCompute(formattedMessageDetail, { state: { caseDetail: { @@ -461,6 +456,7 @@ describe('formattedMessageDetail', () => { messageId: '98a9dbc4-a8d1-459b-98b2-30235b596d70', }, ], + user: generalUser, }, }); diff --git a/web-client/src/presenter/computeds/formattedMessageDetail.ts b/web-client/src/presenter/computeds/formattedMessageDetail.ts index 8e45d01de41..e74d0d1abe2 100644 --- a/web-client/src/presenter/computeds/formattedMessageDetail.ts +++ b/web-client/src/presenter/computeds/formattedMessageDetail.ts @@ -34,12 +34,12 @@ export const formattedMessageDetail = ( const messageDetail = get(state.messageDetail); const caseDetail = get(state.caseDetail); const isExpanded = get(state.isExpanded); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); const { draftDocuments } = applicationContext .getUtilities() - .formatCase(applicationContext, caseDetail); + .formatCase(applicationContext, caseDetail, user); const formattedMessages = orderBy( messageDetail.map(message => diff --git a/web-client/src/presenter/computeds/messageDocumentHelper.test.ts b/web-client/src/presenter/computeds/messageDocumentHelper.test.ts index 5f7029b23d4..27da128c202 100644 --- a/web-client/src/presenter/computeds/messageDocumentHelper.test.ts +++ b/web-client/src/presenter/computeds/messageDocumentHelper.test.ts @@ -18,15 +18,10 @@ import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; describe('messageDocumentHelper', () => { - let globalUser; - const messageDocumentHelper = withAppContextDecorator( messageDocumentHeperComputed, { ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, }, ); @@ -61,7 +56,6 @@ describe('messageDocumentHelper', () => { }; const getBaseState = user => { - globalUser = user; return { caseDetail: { ...baseCaseDetail, @@ -72,6 +66,7 @@ describe('messageDocumentHelper', () => { }, parentMessageId: mockParentMessageId, permissions: getUserPermissions(user), + user, }; }; diff --git a/web-client/src/presenter/computeds/messageDocumentHelper.ts b/web-client/src/presenter/computeds/messageDocumentHelper.ts index 43f286e8edc..9c9f1e0069f 100644 --- a/web-client/src/presenter/computeds/messageDocumentHelper.ts +++ b/web-client/src/presenter/computeds/messageDocumentHelper.ts @@ -28,7 +28,7 @@ export const messageDocumentHelper = ( STAMPED_DOCUMENTS_ALLOWLIST, STIPULATED_DECISION_EVENT_CODE, } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const permissions = get(state.permissions); const caseDetail = get(state.caseDetail); const parentMessageId = get(state.parentMessageId); @@ -58,7 +58,7 @@ export const messageDocumentHelper = ( const { draftDocuments } = applicationContext .getUtilities() - .formatCase(applicationContext, caseDetail); + .formatCase(applicationContext, caseDetail, user); let editUrl = ''; const formattedDocument = draftDocuments.find( From 65b80c187500b758b215efb26f966a1700201c18 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 11:29:07 -0700 Subject: [PATCH 117/523] 10417: Remove getCurrentUser from web-api --- .../generateCaseInventoryReportPdf.test.ts | 81 ++++++++++++++----- .../generateCaseInventoryReportPdf.ts | 15 +--- ...ePrintableCaseInventoryReportInteractor.ts | 1 + 3 files changed, 64 insertions(+), 33 deletions(-) diff --git a/web-api/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.test.ts b/web-api/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.test.ts index a0fb5895714..7fe32024156 100644 --- a/web-api/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.test.ts +++ b/web-api/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.test.ts @@ -1,32 +1,65 @@ import { CASE_STATUS_TYPES, + CASE_TYPES_MAP, CHIEF_JUDGE, - ROLES, + PARTY_TYPES, + PAYMENT_STATUS, + PROCEDURE_TYPES_MAP, } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generateCaseInventoryReportPdf } from './generateCaseInventoryReportPdf'; - -const mockCases = [ - { - associatedJudge: CHIEF_JUDGE, - docketNumber: '101-19', - status: CASE_STATUS_TYPES.new, - }, - { - associatedJudge: CHIEF_JUDGE, - docketNumber: '101-20', - status: CASE_STATUS_TYPES.new, - }, -]; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('generateCaseInventoryReportPdf', () => { - let user; + const mockCases: RawCase[] = [ + { + associatedJudge: CHIEF_JUDGE, + canAllowPrintableDocketRecord: false, + caseCaption: 'Test Caption, Petitioner', + caseStatusHistory: [], + caseType: CASE_TYPES_MAP.disclosure, + consolidatedCases: [], + correspondence: [], + createdAt: '2018-11-21T20:49:28.192Z', + docketEntries: [], + docketNumber: '101-19', + entityName: 'Case', + hearings: [], + partyType: PARTY_TYPES.donor, + petitionPaymentStatus: PAYMENT_STATUS.PAID, + petitioners: [], + procedureType: PROCEDURE_TYPES_MAP.regular, + receivedAt: '2018-11-20T20:49:28.192Z', + sortableDocketNumber: 2001000101, + status: CASE_STATUS_TYPES.new, + }, + { + associatedJudge: CHIEF_JUDGE, + canAllowPrintableDocketRecord: true, + caseCaption: 'Test Caption Again, Petitioner', + caseStatusHistory: [], + caseType: CASE_TYPES_MAP.other, + consolidatedCases: [], + correspondence: [], + createdAt: '2020-07-21T20:49:28.192Z', + docketEntries: [], + docketNumber: '101-20', + entityName: 'Case', + hearings: [], + partyType: PARTY_TYPES.petitioner, + petitionPaymentStatus: PAYMENT_STATUS.PAID, + petitioners: [], + procedureType: PROCEDURE_TYPES_MAP.regular, + receivedAt: '2020-06-29T20:49:28.192Z', + sortableDocketNumber: 2001000111, + status: CASE_STATUS_TYPES.new, + }, + ]; beforeEach(() => { - user = { role: ROLES.petitionsClerk, userId: 'petitionsClerk' }; - - applicationContext.getCurrentUser.mockReturnValue(user); - applicationContext .getUseCaseHelpers() .saveFileAndGenerateUrl.mockReturnValue({ @@ -39,12 +72,10 @@ describe('generateCaseInventoryReportPdf', () => { }); it('throws an error if the user is unauthorized', async () => { - user = { role: ROLES.petitioner, userId: 'petitioner' }; - - applicationContext.getCurrentUser.mockReturnValue(user); await expect( generateCaseInventoryReportPdf({ applicationContext, + authorizedUser: mockPetitionerUser, cases: mockCases, filters: { associatedJudge: CHIEF_JUDGE }, }), @@ -54,6 +85,7 @@ describe('generateCaseInventoryReportPdf', () => { it('calls the pdf report generator', async () => { await generateCaseInventoryReportPdf({ applicationContext, + authorizedUser: mockPetitionsClerkUser, cases: mockCases, filters: { associatedJudge: CHIEF_JUDGE }, }); @@ -72,6 +104,7 @@ describe('generateCaseInventoryReportPdf', () => { it('returns the pre-signed url to the document', async () => { const result = await generateCaseInventoryReportPdf({ applicationContext, + authorizedUser: mockPetitionsClerkUser, cases: mockCases, filters: { associatedJudge: CHIEF_JUDGE }, }); @@ -87,6 +120,7 @@ describe('generateCaseInventoryReportPdf', () => { await expect( generateCaseInventoryReportPdf({ applicationContext, + authorizedUser: mockPetitionsClerkUser, cases: mockCases, filters: { associatedJudge: CHIEF_JUDGE }, }), @@ -100,6 +134,7 @@ describe('generateCaseInventoryReportPdf', () => { await generateCaseInventoryReportPdf({ applicationContext, + authorizedUser: mockPetitionsClerkUser, cases: mockCases, filters: { status: CASE_STATUS_TYPES.new }, }); @@ -118,6 +153,7 @@ describe('generateCaseInventoryReportPdf', () => { await generateCaseInventoryReportPdf({ applicationContext, + authorizedUser: mockPetitionsClerkUser, cases: mockCases, filters: { associatedJudge: CHIEF_JUDGE }, }); @@ -136,6 +172,7 @@ describe('generateCaseInventoryReportPdf', () => { await generateCaseInventoryReportPdf({ applicationContext, + authorizedUser: mockPetitionsClerkUser, cases: mockCases, filters: { associatedJudge: CHIEF_JUDGE, diff --git a/web-api/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.ts b/web-api/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.ts index d77257d23cf..8abd58223fb 100644 --- a/web-api/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.ts +++ b/web-api/src/business/useCaseHelper/caseInventoryReport/generateCaseInventoryReportPdf.ts @@ -4,17 +4,11 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * Generate Case Inventory Report PDF - * - * @param {object} providers the providers object - * @param {object} providers.applicationContext the application context - * @param {string} providers.caseEntity a case entity with its documents - * @returns {Promise<*>} the promise of the document having been uploaded - */ export const generateCaseInventoryReportPdf = async ({ applicationContext, + authorizedUser, cases, filters, }: { @@ -24,10 +18,9 @@ export const generateCaseInventoryReportPdf = async ({ associatedJudge?: string; status?: string; }; + authorizedUser: UnknownAuthUser; }): Promise<{ fileId: string; url: string }> => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_INVENTORY_REPORT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_INVENTORY_REPORT)) { throw new UnauthorizedError('Unauthorized for case inventory report'); } diff --git a/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.ts b/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.ts index 6722d28cb08..6063adf9a0c 100644 --- a/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.ts +++ b/web-api/src/business/useCases/caseInventoryReport/generatePrintableCaseInventoryReportInteractor.ts @@ -37,6 +37,7 @@ export const generatePrintableCaseInventoryReportInteractor = async ( .getUseCaseHelpers() .generateCaseInventoryReportPdf({ applicationContext, + authorizedUser, cases: foundCases, filters: { associatedJudge, status }, }); From 69fa698f318aadb252946c1ee3aa32721009b3fd Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 11:55:02 -0700 Subject: [PATCH 118/523] 10417: Remove getCurrentUser from web-api --- .../createAndServeNoticeDocketEntry.test.ts | 58 +++++++++++-------- .../createAndServeNoticeDocketEntry.ts | 9 ++- .../setNoticeOfChangeOfTrialJudge.test.ts | 3 - .../setNoticeOfChangeOfTrialJudge.ts | 16 ++--- ...NoticeOfChangeToInPersonProceeding.test.ts | 4 -- .../setNoticeOfChangeToInPersonProceeding.ts | 21 ++++--- ...etNoticeOfChangeToRemoteProceeding.test.ts | 3 - .../setNoticeOfChangeToRemoteProceeding.ts | 21 ++++--- .../serveThirtyDayNoticeInteractor.test.ts | 39 +++++++------ .../serveThirtyDayNoticeInteractor.ts | 45 +++++++------- .../updateTrialSessionInteractor.ts | 1 - 11 files changed, 120 insertions(+), 100 deletions(-) diff --git a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.test.ts b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.test.ts index b0b3d0a0832..72fef507ea5 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.test.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.test.ts @@ -1,5 +1,3 @@ -import { getFakeFile } from '../../../../../shared/src/business/test/getFakeFile'; - import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { @@ -8,7 +6,7 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createAndServeNoticeDocketEntry } from './createAndServeNoticeDocketEntry'; -import { docketClerk1User } from '../../../../../shared/src/test/mockUsers'; +import { getFakeFile } from '../../../../../shared/src/business/test/getFakeFile'; import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('createAndServeDocketEntry', () => { @@ -37,13 +35,17 @@ describe('createAndServeDocketEntry', () => { }); it('should save the generated notice to s3', async () => { - await createAndServeNoticeDocketEntry(applicationContext, { - caseEntity: mockCaseEntity, - documentInfo: SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeOfTrialJudge, - newPdfDoc: getFakeFile, - noticePdf: mockNotice, - user: docketClerk1User, - }); + await createAndServeNoticeDocketEntry( + applicationContext, + { + caseEntity: mockCaseEntity, + documentInfo: + SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeOfTrialJudge, + newPdfDoc: getFakeFile, + noticePdf: mockNotice, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda.mock @@ -55,13 +57,17 @@ describe('createAndServeDocketEntry', () => { }); it('should create and serve a docket entry and add it to the docket record', async () => { - await createAndServeNoticeDocketEntry(applicationContext, { - caseEntity: mockCaseEntity, - documentInfo: SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeOfTrialJudge, - newPdfDoc: getFakeFile, - noticePdf: mockNotice, - user: docketClerk1User, - }); + await createAndServeNoticeDocketEntry( + applicationContext, + { + caseEntity: mockCaseEntity, + documentInfo: + SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeOfTrialJudge, + newPdfDoc: getFakeFile, + noticePdf: mockNotice, + }, + mockDocketClerkUser, + ); const expectedNotice = mockCaseEntity.docketEntries.find( doc => @@ -96,13 +102,17 @@ describe('createAndServeDocketEntry', () => { { authorizedUser: mockDocketClerkUser }, ); - await createAndServeNoticeDocketEntry(applicationContext, { - caseEntity: mockCaseWithPaperService, - documentInfo: SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeOfTrialJudge, - newPdfDoc: getFakeFile, - noticePdf: mockNotice, - user: docketClerk1User, - }); + await createAndServeNoticeDocketEntry( + applicationContext, + { + caseEntity: mockCaseWithPaperService, + documentInfo: + SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeOfTrialJudge, + newPdfDoc: getFakeFile, + noticePdf: mockNotice, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().serveGeneratedNoticesOnCase, diff --git a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts index 030b2415275..bd0b96d2454 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { DOCUMENT_PROCESSING_STATUS_OPTIONS, @@ -7,7 +8,6 @@ import { DocketEntry, getServedPartiesCode, } from '../../../../../shared/src/business/entities/DocketEntry'; -import { RawUser } from '@shared/business/entities/User'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; import { createISODateString } from '../../../../../shared/src/business/utilities/DateHandler'; @@ -21,7 +21,6 @@ export const createAndServeNoticeDocketEntry = async ( newPdfDoc, noticePdf, onlyProSePetitioners, - user, }: { additionalDocketEntryInfo?: any; caseEntity: Case; @@ -32,9 +31,9 @@ export const createAndServeNoticeDocketEntry = async ( }; newPdfDoc: any; noticePdf: Buffer; - user: RawUser; onlyProSePetitioners?: boolean; }, + authorizedUser: AuthUser, ) => { const docketEntryId = applicationContext.getUniqueId(); @@ -73,10 +72,10 @@ export const createAndServeNoticeDocketEntry = async ( : getServedPartiesCode(servedParties.all), ...additionalDocketEntryInfo, }, - { authorizedUser: applicationContext.getCurrentUser() }, + { authorizedUser }, ); - noticeDocketEntry.setFiledBy(user); + noticeDocketEntry.setFiledBy(authorizedUser); caseEntity.addDocketEntry(noticeDocketEntry); diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts index d1226209197..3288e0b5999 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts @@ -13,7 +13,6 @@ jest.mock('@shared/business/utilities/getJudgeWithTitle', () => ({ describe('setNoticeOfChangeOfTrialJudge', () => { const trialSessionId = '76a5b1c8-1eed-44b6-932a-967af060597a'; - const userId = '85a5b1c8-1eed-44b6-932a-967af060597a'; const currentTrialSession = { ...MOCK_TRIAL_INPERSON, @@ -59,7 +58,6 @@ describe('setNoticeOfChangeOfTrialJudge', () => { currentTrialSession, newPdfDoc: getFakeFile, newTrialSessionEntity: updatedTrialSession, - userId, }); expect(getJudgeWithTitle.mock.calls[0][0]).toMatchObject({ @@ -78,7 +76,6 @@ describe('setNoticeOfChangeOfTrialJudge', () => { currentTrialSession, newPdfDoc: getFakeFile, newTrialSessionEntity: updatedTrialSession, - userId, }); expect( diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.ts index 51781b08c4e..046af028757 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.ts @@ -1,9 +1,10 @@ import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { getJudgeWithTitle } from '../../../../../shared/src/business/utilities/getJudgeWithTitle'; export const setNoticeOfChangeOfTrialJudge = async ( - applicationContext, - { caseEntity, currentTrialSession, newPdfDoc, newTrialSessionEntity, user }, + applicationContext: ServerApplicationContext, + { caseEntity, currentTrialSession, newPdfDoc, newTrialSessionEntity }, ) => { const priorJudgeTitleWithFullName = await getJudgeWithTitle({ applicationContext, @@ -35,13 +36,14 @@ export const setNoticeOfChangeOfTrialJudge = async ( trialSessionInformation, }); - await applicationContext - .getUseCaseHelpers() - .createAndServeNoticeDocketEntry(applicationContext, { + await applicationContext.getUseCaseHelpers().createAndServeNoticeDocketEntry( + applicationContext, + { caseEntity, documentInfo: SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeOfTrialJudge, newPdfDoc, noticePdf, - user, - }); + }, + applicationContext.getCurrentUser(), + ); }; diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts index 8e9edd108c1..dcc56b8945f 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts @@ -5,7 +5,6 @@ import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/busin import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getFakeFile } from '../../../../../shared/src/business/test/getFakeFile'; import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; -import { petitionsClerkUser } from '../../../../../shared/src/test/mockUsers'; import { setNoticeOfChangeToInPersonProceeding } from './setNoticeOfChangeToInPersonProceeding'; describe('setNoticeOfChangeToInPersonProceeding', () => { @@ -37,7 +36,6 @@ describe('setNoticeOfChangeToInPersonProceeding', () => { caseEntity: mockOpenCase, newPdfDoc: getFakeFile, newTrialSessionEntity: mockInPersonCalendaredTrialSession, - user: petitionsClerkUser, }); expect( @@ -67,7 +65,6 @@ describe('setNoticeOfChangeToInPersonProceeding', () => { caseEntity: mockOpenCase, newPdfDoc: getFakeFile, newTrialSessionEntity: mockInPersonCalendaredTrialSession, - user: petitionsClerkUser, }); expect( @@ -84,7 +81,6 @@ describe('setNoticeOfChangeToInPersonProceeding', () => { SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeToInPersonProceeding, newPdfDoc: getFakeFile, noticePdf: getFakeFile, - user: petitionsClerkUser, }); }); }); diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.ts index 2ea20ec1834..ca7c6e53dc1 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.ts @@ -1,4 +1,6 @@ +import { Case } from '@shared/business/entities/cases/Case'; import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; +import { ServerApplicationContext } from '@web-api/applicationContext'; /** * setNoticeOfChangeToInPersonProceeding @@ -11,8 +13,12 @@ import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/busin * @param {object} providers.userId the user ID */ export const setNoticeOfChangeToInPersonProceeding = async ( - applicationContext, - { caseEntity, newPdfDoc, newTrialSessionEntity, user }, + applicationContext: ServerApplicationContext, + { + caseEntity, + newPdfDoc, + newTrialSessionEntity, + }: { caseEntity: Case; newPdfDoc: any; newTrialSessionEntity: any }, ) => { const trialSessionInformation = { address1: newTrialSessionEntity.address1, @@ -41,15 +47,16 @@ export const setNoticeOfChangeToInPersonProceeding = async ( trialLocation: newTrialSessionEntity.trialLocation, }; - await applicationContext - .getUseCaseHelpers() - .createAndServeNoticeDocketEntry(applicationContext, { + await applicationContext.getUseCaseHelpers().createAndServeNoticeDocketEntry( + applicationContext, + { additionalDocketEntryInfo, caseEntity, documentInfo: SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeToInPersonProceeding, newPdfDoc, noticePdf, - user, - }); + }, + applicationContext.getCurrentUser(), + ); }; diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts index 6f33a8c7ffc..b868fd7a5e5 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts @@ -7,7 +7,6 @@ import { import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; -import { petitionsClerkUser } from '../../../../../shared/src/test/mockUsers'; import { setNoticeOfChangeToRemoteProceeding } from './setNoticeOfChangeToRemoteProceeding'; describe('setNoticeOfChangeToRemoteProceeding', () => { @@ -36,7 +35,6 @@ describe('setNoticeOfChangeToRemoteProceeding', () => { caseEntity: mockOpenCase, newPdfDoc: mockNewPdf, newTrialSessionEntity: MOCK_TRIAL_REMOTE, - user: petitionsClerkUser, }); expect( @@ -64,7 +62,6 @@ describe('setNoticeOfChangeToRemoteProceeding', () => { SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeToRemoteProceeding, newPdfDoc: mockNewPdf, noticePdf: mockNoticePdf, - user: petitionsClerkUser, }); }); }); diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.ts index ae1139abe3d..7959664dcd1 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.ts @@ -1,4 +1,6 @@ +import { Case } from '@shared/business/entities/cases/Case'; import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; +import { ServerApplicationContext } from '@web-api/applicationContext'; export type TrialSessionInformationType = { chambersPhoneNumber: string; @@ -22,8 +24,12 @@ export type TrialSessionInformationType = { * @param {object} providers.userId the user ID */ export const setNoticeOfChangeToRemoteProceeding = async ( - applicationContext, - { caseEntity, newPdfDoc, newTrialSessionEntity, user }, + applicationContext: ServerApplicationContext, + { + caseEntity, + newPdfDoc, + newTrialSessionEntity, + }: { caseEntity: Case; newPdfDoc: any; newTrialSessionEntity: any }, ): Promise => { const trialSessionInformation: TrialSessionInformationType = { chambersPhoneNumber: newTrialSessionEntity.chambersPhoneNumber, @@ -43,14 +49,15 @@ export const setNoticeOfChangeToRemoteProceeding = async ( trialSessionInformation, }); - await applicationContext - .getUseCaseHelpers() - .createAndServeNoticeDocketEntry(applicationContext, { + await applicationContext.getUseCaseHelpers().createAndServeNoticeDocketEntry( + applicationContext, + { caseEntity, documentInfo: SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfChangeToRemoteProceeding, newPdfDoc, noticePdf, - user, - }); + }, + applicationContext.getCurrentUser(), + ); }; diff --git a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.test.ts b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.test.ts index de397ca0c09..5623104a5a2 100644 --- a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.test.ts @@ -146,25 +146,28 @@ describe('serveThirtyDayNoticeInteractor', () => { ).toHaveBeenCalledTimes(1); expect( applicationContext.getUseCaseHelpers().createAndServeNoticeDocketEntry, - ).toHaveBeenCalledWith(expect.anything(), { - additionalDocketEntryInfo: { - date: expect.anything(), - trialLocation: expect.anything(), - }, - caseEntity: expect.anything(), - documentInfo: { - documentTitle: `30 Day Notice of Trial on ${formatDateString( - trialSession.startDate, - FORMATS.MMDDYYYY_DASHED, - )} at ${trialSession.trialLocation}`, - documentType: '30-Day Notice of Trial', - eventCode: 'NOTT', + ).toHaveBeenCalledWith( + expect.anything(), + { + additionalDocketEntryInfo: { + date: expect.anything(), + trialLocation: expect.anything(), + }, + caseEntity: expect.anything(), + documentInfo: { + documentTitle: `30 Day Notice of Trial on ${formatDateString( + trialSession.startDate, + FORMATS.MMDDYYYY_DASHED, + )} at ${trialSession.trialLocation}`, + documentType: '30-Day Notice of Trial', + eventCode: 'NOTT', + }, + newPdfDoc: expect.anything(), + noticePdf: expect.anything(), + onlyProSePetitioners: true, }, - newPdfDoc: expect.anything(), - noticePdf: expect.anything(), - onlyProSePetitioners: true, - user: petitionsClerkUser, - }); + petitionsClerkUser, + ); }); it('should notify the user after processing each case in the trial session', async () => { diff --git a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts index 36c89cafa1b..47d0d309a93 100644 --- a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts @@ -175,29 +175,32 @@ export const serveThirtyDayNoticeInteractor = async ( await applicationContext .getUseCaseHelpers() - .createAndServeNoticeDocketEntry(applicationContext, { - additionalDocketEntryInfo: { - date: trialSession.startDate, - trialLocation: trialSession.trialLocation, - }, - caseEntity, - documentInfo: { - documentTitle: replaceBracketed( - thirtyDayNoticeDocumentInfo!.documentTitle, - formatDateString( - trialSession.startDate, - FORMATS.MMDDYYYY_DASHED, + .createAndServeNoticeDocketEntry( + applicationContext, + { + additionalDocketEntryInfo: { + date: trialSession.startDate, + trialLocation: trialSession.trialLocation, + }, + caseEntity, + documentInfo: { + documentTitle: replaceBracketed( + thirtyDayNoticeDocumentInfo!.documentTitle, + formatDateString( + trialSession.startDate, + FORMATS.MMDDYYYY_DASHED, + ), + trialSession.trialLocation!, ), - trialSession.trialLocation!, - ), - documentType: thirtyDayNoticeDocumentInfo!.documentType, - eventCode: thirtyDayNoticeDocumentInfo!.eventCode, + documentType: thirtyDayNoticeDocumentInfo!.documentType, + eventCode: thirtyDayNoticeDocumentInfo!.eventCode, + }, + newPdfDoc: paperServicePdf, + noticePdf, + onlyProSePetitioners: true, }, - newPdfDoc: paperServicePdf, - noticePdf, - onlyProSePetitioners: true, - user: currentUser, - }); + currentUser, + ); await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index 4fac8f6597b..f8582edaf24 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -275,7 +275,6 @@ const updateCasesAndSetNoticeOfChange = async ({ currentTrialSession, newPdfDoc: paperServicePdfsCombined, newTrialSessionEntity: updatedTrialSessionEntity, - user, }); } From a1d9172108d26e19098f64431e8b7c9c4017dd75 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 12:11:34 -0700 Subject: [PATCH 119/523] 10417: Remove getCurrentUser from web-api --- .../associateSwingTrialSessions.test.ts | 85 ++++++++++--------- .../associateSwingTrialSessions.ts | 22 ++--- .../createTrialSessionInteractor.ts | 20 ++--- .../updateTrialSessionInteractor.ts | 10 ++- 4 files changed, 68 insertions(+), 69 deletions(-) diff --git a/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.test.ts b/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.test.ts index ea8cdef3abf..bf9eea50bdf 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.test.ts @@ -4,35 +4,33 @@ import { TrialSession } from '../../../../../shared/src/business/entities/trialS import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { associateSwingTrialSessions } from '@web-api/business/useCaseHelper/trialSessions/associateSwingTrialSessions'; import { - petitionerUser, - petitionsClerkUser, -} from '../../../../../shared/src/test/mockUsers'; + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; -const MOCK_TRIAL_SESSION = { - ...MOCK_TRIAL_REGULAR, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, - sessionType: 'Regular', - startDate: '3000-03-01T00:00:00.000Z', - term: 'Fall', - termYear: '3000', - trialSessionId: '959c4338-0fac-42eb-b0eb-d53b8d0195cc', -}; +describe('associateSwingTrialSessions', () => { + let mockCurrentTrialSessionEntity; -const MOCK_TRIAL_SESSION_FOR_ASSOCIATION = { - ...MOCK_TRIAL_REGULAR, - sessionType: 'Small', - startDate: '3000-03-03T00:00:00.000Z', - term: 'Fall', - termYear: '3000', - trialSessionId: '208a959f-9526-4db5-b262-e58c476a4604', -}; + const MOCK_TRIAL_SESSION = { + ...MOCK_TRIAL_REGULAR, + proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, + sessionType: 'Regular', + startDate: '3000-03-01T00:00:00.000Z', + term: 'Fall', + termYear: '3000', + trialSessionId: '959c4338-0fac-42eb-b0eb-d53b8d0195cc', + }; -let mockCurrentTrialSessionEntity; + const MOCK_TRIAL_SESSION_FOR_ASSOCIATION = { + ...MOCK_TRIAL_REGULAR, + sessionType: 'Small', + startDate: '3000-03-03T00:00:00.000Z', + term: 'Fall', + termYear: '3000', + trialSessionId: '208a959f-9526-4db5-b262-e58c476a4604', + }; -describe('associateSwingTrialSessions', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - applicationContext .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_SESSION_FOR_ASSOCIATION); @@ -41,21 +39,27 @@ describe('associateSwingTrialSessions', () => { }); it('throws an error if user is unauthorized to associate swing sessions', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - await expect( - associateSwingTrialSessions(applicationContext, { - swingSessionId: MOCK_TRIAL_SESSION_FOR_ASSOCIATION.trialSessionId, - trialSessionEntity: mockCurrentTrialSessionEntity, - }), + associateSwingTrialSessions( + applicationContext, + { + swingSessionId: MOCK_TRIAL_SESSION_FOR_ASSOCIATION.trialSessionId, + trialSessionEntity: mockCurrentTrialSessionEntity, + }, + mockPetitionerUser, + ), ).rejects.toThrow(); }); it('retrieves the swing session to be associated with the current session from persistence', async () => { - await associateSwingTrialSessions(applicationContext, { - swingSessionId: MOCK_TRIAL_SESSION_FOR_ASSOCIATION.trialSessionId, - trialSessionEntity: mockCurrentTrialSessionEntity, - }); + await associateSwingTrialSessions( + applicationContext, + { + swingSessionId: MOCK_TRIAL_SESSION_FOR_ASSOCIATION.trialSessionId, + trialSessionEntity: mockCurrentTrialSessionEntity, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getTrialSessionById.mock @@ -64,10 +68,14 @@ describe('associateSwingTrialSessions', () => { }); it('updates the trial session to be associated with swing session information', async () => { - await associateSwingTrialSessions(applicationContext, { - swingSessionId: MOCK_TRIAL_SESSION_FOR_ASSOCIATION.trialSessionId, - trialSessionEntity: mockCurrentTrialSessionEntity, - }); + await associateSwingTrialSessions( + applicationContext, + { + swingSessionId: MOCK_TRIAL_SESSION_FOR_ASSOCIATION.trialSessionId, + trialSessionEntity: mockCurrentTrialSessionEntity, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateTrialSession.mock @@ -86,6 +94,7 @@ describe('associateSwingTrialSessions', () => { swingSessionId: MOCK_TRIAL_SESSION_FOR_ASSOCIATION.trialSessionId, trialSessionEntity: mockCurrentTrialSessionEntity, }, + mockPetitionsClerkUser, ); expect(updatedTrialSession).toMatchObject({ diff --git a/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.ts b/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.ts index d1a85202592..ad752243784 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/associateSwingTrialSessions.ts @@ -3,29 +3,23 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; +import { + RawTrialSession, + TrialSession, +} from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { ServerApplicationContext } from '@web-api/applicationContext'; -import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * associateSwingTrialSessions - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.swingSessionId the id of the trial session to add as a swing session - * @param {string} providers.trialSession the trial session to add the swing session to - * @returns {Object} the updated trial session object - */ export const associateSwingTrialSessions = async ( applicationContext: ServerApplicationContext, { swingSessionId, trialSessionEntity, }: { swingSessionId: string; trialSessionEntity: TrialSession }, -) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + authorizedUser: UnknownAuthUser, +): Promise => { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts index f05e110757c..a642167ef7c 100644 --- a/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts @@ -9,18 +9,10 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; -/** - * createTrialSessionInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.trialSession the trial session data - * @returns {object} the created trial session - */ export const createTrialSessionInteractor = async ( applicationContext: ServerApplicationContext, { trialSession }: { trialSession: RawTrialSession }, -) => { +): Promise => { const user = applicationContext.getCurrentUser(); if (!isAuthorized(user, ROLE_PERMISSIONS.CREATE_TRIAL_SESSION)) { @@ -37,12 +29,14 @@ export const createTrialSessionInteractor = async ( } if (trialSessionToAdd.swingSession && trialSessionToAdd.swingSessionId) { - await applicationContext - .getUseCaseHelpers() - .associateSwingTrialSessions(applicationContext, { + await applicationContext.getUseCaseHelpers().associateSwingTrialSessions( + applicationContext, + { swingSessionId: trialSessionToAdd.swingSessionId, trialSessionEntity: trialSessionToAdd, - }); + }, + user, + ); } return await applicationContext diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index f8582edaf24..94b082ac170 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -179,12 +179,14 @@ export const updateTrialSession = async ( } if (trialSession.swingSession && trialSession.swingSessionId) { - await applicationContext - .getUseCaseHelpers() - .associateSwingTrialSessions(applicationContext, { + await applicationContext.getUseCaseHelpers().associateSwingTrialSessions( + applicationContext, + { swingSessionId: trialSession.swingSessionId, trialSessionEntity: updatedTrialSessionEntity, - }); + }, + user, + ); } await applicationContext.getPersistenceGateway().updateTrialSession({ From 377520e54090ddc81f0555c7f83aaf4aef8b9cbc Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 13:11:34 -0700 Subject: [PATCH 120/523] 10417: Remove getCurrentUser from getFormattedCaseDetail --- .../utilities/getFormattedCaseDetail.test.ts | 6 +++ .../utilities/getFormattedCaseDetail.ts | 8 ++-- shared/src/test/mockAuthUsers.ts | 7 +++ .../generateDocketRecordPdfInteractor.ts | 4 +- .../journey/chambersUserAddsOrderToCase.ts | 1 + .../petitionsClerkAddsGenericOrderToCase.ts | 1 + .../journey/petitionsClerkAddsNoticeToCase.ts | 1 + .../journey/petitionsClerkAddsOrderToCase.ts | 1 + .../journey/petitionsClerkCreateOrder.ts | 1 + .../computeds/documentViewerHelper.test.ts | 7 +-- .../computeds/documentViewerHelper.ts | 2 + .../draftDocumentViewerHelper.test.ts | 43 +------------------ .../computeds/draftDocumentViewerHelper.ts | 3 +- .../presenter/computeds/messageModalHelper.ts | 9 ++-- 14 files changed, 38 insertions(+), 56 deletions(-) diff --git a/shared/src/business/utilities/getFormattedCaseDetail.test.ts b/shared/src/business/utilities/getFormattedCaseDetail.test.ts index 4bd2546393b..0267dc9ff9c 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.test.ts +++ b/shared/src/business/utilities/getFormattedCaseDetail.test.ts @@ -517,6 +517,7 @@ describe('getFormattedCaseDetail', () => { it('should call formatCase and add additional details on the given case', () => { const result = getFormattedCaseDetail({ applicationContext, + authorizedUser: undefined, caseDetail: { ...MOCK_CASE }, docketRecordSort: 'byDate', }); @@ -529,6 +530,7 @@ describe('getFormattedCaseDetail', () => { it('should format draft documents', () => { const result = getFormattedCaseDetail({ applicationContext, + authorizedUser: undefined, caseDetail: { ...MOCK_CASE, docketEntries: [ @@ -580,6 +582,7 @@ describe('getFormattedCaseDetail', () => { it('should sort draft documents by their receivedAt', () => { const result = getFormattedCaseDetail({ applicationContext, + authorizedUser: undefined, caseDetail: { ...MOCK_CASE, docketEntries: [ @@ -616,6 +619,7 @@ describe('getFormattedCaseDetail', () => { it('should format filing fee string for a paid petition fee', () => { const result = getFormattedCaseDetail({ applicationContext, + authorizedUser: undefined, caseDetail: { ...MOCK_CASE, petitionPaymentDate: '2019-03-01T21:40:46.415Z', @@ -630,6 +634,7 @@ describe('getFormattedCaseDetail', () => { it('should format filing fee string for a waived petition fee', () => { const result = getFormattedCaseDetail({ applicationContext, + authorizedUser: undefined, caseDetail: { ...MOCK_CASE, petitionPaymentStatus: PAYMENT_STATUS.WAIVED, @@ -643,6 +648,7 @@ describe('getFormattedCaseDetail', () => { it('should format filing fee string for an unpaid petition fee', () => { const result = getFormattedCaseDetail({ applicationContext, + authorizedUser: undefined, caseDetail: { ...MOCK_CASE, petitionPaymentStatus: PAYMENT_STATUS.UNPAID, diff --git a/shared/src/business/utilities/getFormattedCaseDetail.ts b/shared/src/business/utilities/getFormattedCaseDetail.ts index dd8800f004d..2abf57d078a 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.ts +++ b/shared/src/business/utilities/getFormattedCaseDetail.ts @@ -7,7 +7,6 @@ import { TRANSCRIPT_EVENT_CODE, } from '../entities/EntityConstants'; import { Case } from '../entities/cases/Case'; -import { ClientApplicationContext } from '@web-client/applicationContext'; import { DocketEntry } from '../entities/DocketEntry'; import { FORMATS, @@ -486,20 +485,23 @@ export const sortDocketEntries = ( return docketEntries.sort(sortUndefined); }; +// Used by both front and backend export const getFormattedCaseDetail = ({ applicationContext, + authorizedUser, caseDetail, docketRecordSort, }: { - applicationContext: ClientApplicationContext; + applicationContext: IApplicationContext; caseDetail: RawCase; docketRecordSort?: string; + authorizedUser: UnknownAuthUser; }) => { const result = { ...applicationContext .getUtilities() .setServiceIndicatorsForCase(caseDetail), - ...formatCase(applicationContext, caseDetail), // TODO 10417 Needd to get an authorizedUser here + ...formatCase(applicationContext, caseDetail, authorizedUser), }; result.formattedDocketEntries = sortDocketEntries( result.formattedDocketEntries, diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index 742bd3f0be0..3627155f268 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -77,3 +77,10 @@ export const mockIrsSuperuser: AuthUser = { role: ROLES.irsSuperuser, userId: '192b629a-aa9c-4a7d-9379-b2a1331a6848', }; + +export const mockChambersUser: AuthUser = { + email: 'mockChambersUser@example.com', + name: 'Chitty Chambers', + role: ROLES.chambers, + userId: 'e28c2f91-6925-48ac-8441-22b522b0c044', +}; diff --git a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts index 2a8e77d45cd..a18f2f16a20 100644 --- a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts +++ b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts @@ -6,6 +6,7 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../../../shared/src/authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; import { getCaseCaptionMeta } from '../../../../shared/src/business/utilities/getCaseCaptionMeta'; @@ -17,7 +18,7 @@ import { getCaseCaptionMeta } from '../../../../shared/src/business/utilities/ge * @returns {Uint8Array} docket record pdf */ export const generateDocketRecordPdfInteractor = async ( - applicationContext, + applicationContext: ServerApplicationContext, { docketNumber, docketRecordSort, @@ -81,6 +82,7 @@ export const generateDocketRecordPdfInteractor = async ( .getUtilities() .getFormattedCaseDetail({ applicationContext, + authorizedUser: user, caseDetail: caseEntity, docketRecordSort, }); diff --git a/web-client/integration-tests/journey/chambersUserAddsOrderToCase.ts b/web-client/integration-tests/journey/chambersUserAddsOrderToCase.ts index 591a4cb1e53..ec610fddc99 100644 --- a/web-client/integration-tests/journey/chambersUserAddsOrderToCase.ts +++ b/web-client/integration-tests/journey/chambersUserAddsOrderToCase.ts @@ -43,6 +43,7 @@ export const chambersUserAddsOrderToCase = cerebralTest => { .getUtilities() .getFormattedCaseDetail({ applicationContext, + authorizedUser: cerebralTest.getState('user'), caseDetail: cerebralTest.getState('caseDetail'), }); diff --git a/web-client/integration-tests/journey/petitionsClerkAddsGenericOrderToCase.ts b/web-client/integration-tests/journey/petitionsClerkAddsGenericOrderToCase.ts index 8a0c4e72b09..599b3570d1f 100644 --- a/web-client/integration-tests/journey/petitionsClerkAddsGenericOrderToCase.ts +++ b/web-client/integration-tests/journey/petitionsClerkAddsGenericOrderToCase.ts @@ -44,6 +44,7 @@ export const petitionsClerkAddsGenericOrderToCase = cerebralTest => { .getUtilities() .getFormattedCaseDetail({ applicationContext, + authorizedUser: cerebralTest.getState('user'), caseDetail: cerebralTest.getState('caseDetail'), }); diff --git a/web-client/integration-tests/journey/petitionsClerkAddsNoticeToCase.ts b/web-client/integration-tests/journey/petitionsClerkAddsNoticeToCase.ts index 5afecc9e8c3..086bffc97a2 100644 --- a/web-client/integration-tests/journey/petitionsClerkAddsNoticeToCase.ts +++ b/web-client/integration-tests/journey/petitionsClerkAddsNoticeToCase.ts @@ -48,6 +48,7 @@ export const petitionsClerkAddsNoticeToCase = cerebralTest => { .getUtilities() .getFormattedCaseDetail({ applicationContext, + authorizedUser: cerebralTest.getState('user'), caseDetail: cerebralTest.getState('caseDetail'), }); diff --git a/web-client/integration-tests/journey/petitionsClerkAddsOrderToCase.ts b/web-client/integration-tests/journey/petitionsClerkAddsOrderToCase.ts index 667b1593d9d..5c35e0d1548 100644 --- a/web-client/integration-tests/journey/petitionsClerkAddsOrderToCase.ts +++ b/web-client/integration-tests/journey/petitionsClerkAddsOrderToCase.ts @@ -39,6 +39,7 @@ export const petitionsClerkAddsOrderToCase = cerebralTest => { .getUtilities() .getFormattedCaseDetail({ applicationContext, + authorizedUser: cerebralTest.getState('user'), caseDetail: cerebralTest.getState('caseDetail'), }); diff --git a/web-client/integration-tests/journey/petitionsClerkCreateOrder.ts b/web-client/integration-tests/journey/petitionsClerkCreateOrder.ts index 6fb339666d0..854b7ad4e7e 100644 --- a/web-client/integration-tests/journey/petitionsClerkCreateOrder.ts +++ b/web-client/integration-tests/journey/petitionsClerkCreateOrder.ts @@ -45,6 +45,7 @@ export const petitionsClerkCreateOrder = cerebralTest => { .getUtilities() .getFormattedCaseDetail({ applicationContext, + authorizedUser: cerebralTest.getState('user'), caseDetail: cerebralTest.getState('caseDetail'), }); diff --git a/web-client/src/presenter/computeds/documentViewerHelper.test.ts b/web-client/src/presenter/computeds/documentViewerHelper.test.ts index e98a6e33610..336ffdd0cc3 100644 --- a/web-client/src/presenter/computeds/documentViewerHelper.test.ts +++ b/web-client/src/presenter/computeds/documentViewerHelper.test.ts @@ -30,18 +30,13 @@ describe('documentViewerHelper', () => { const getBaseState = user => { return { permissions: getUserPermissions(user), + user, viewerDocumentToDisplay: { docketEntryId: DOCKET_ENTRY_ID, }, }; }; - beforeAll(() => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(docketClerkUser); - }); - it('should return an empty object if the requested docketEntryId is not found in the docket record', () => { const result = runCompute(documentViewerHelper, { state: { diff --git a/web-client/src/presenter/computeds/documentViewerHelper.ts b/web-client/src/presenter/computeds/documentViewerHelper.ts index 70e97e134ef..a42c18cd835 100644 --- a/web-client/src/presenter/computeds/documentViewerHelper.ts +++ b/web-client/src/presenter/computeds/documentViewerHelper.ts @@ -20,11 +20,13 @@ export const documentViewerHelper = ( const permissions = get(state.permissions); const viewerDocumentToDisplay = get(state.viewerDocumentToDisplay); const caseDetail = get(state.caseDetail); + const user = get(state.user); const formattedCaseDetail = applicationContext .getUtilities() .getFormattedCaseDetail({ applicationContext, + authorizedUser: user, caseDetail, }); diff --git a/web-client/src/presenter/computeds/draftDocumentViewerHelper.test.ts b/web-client/src/presenter/computeds/draftDocumentViewerHelper.test.ts index 1fc07432e0c..e02c7a9530a 100644 --- a/web-client/src/presenter/computeds/draftDocumentViewerHelper.test.ts +++ b/web-client/src/presenter/computeds/draftDocumentViewerHelper.test.ts @@ -23,6 +23,7 @@ describe('draftDocumentViewerHelper', () => { const getBaseState = user => { return { permissions: getUserPermissions(user), + user, viewerDraftDocumentToDisplay: { docketEntryId: mockDocketEntryId, }, @@ -38,12 +39,6 @@ describe('draftDocumentViewerHelper', () => { isDraft: true, }; - beforeEach(() => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(docketClerkUser); - }); - it('should return an object with empty strings if viewerDraftDocumentToDisplay.eventCode is not defined', () => { const result = runCompute(draftDocumentViewerHelper, { state: { @@ -117,8 +112,6 @@ describe('draftDocumentViewerHelper', () => { describe('showAddDocketEntryButton', () => { it('should return true for user role of petitionsClerk', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(petitionsClerkUser), @@ -137,8 +130,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return true for user role of clerkOfCourt', () => { - applicationContext.getCurrentUser.mockReturnValue(clerkOfCourtUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(clerkOfCourtUser), @@ -157,8 +148,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return false for other internal user roles', () => { - applicationContext.getCurrentUser.mockReturnValue(judgeUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(judgeUser), @@ -172,8 +161,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return true for signed document', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -192,8 +179,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return false for unsigned document that requires signature', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -208,8 +193,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showApplySignatureButton true and showRemoveSignatureButton false for an internal user and an unsigned document', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -224,8 +207,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showApplySignatureButton false and showRemoveSignatureButton false for an external user', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(petitionerUser), @@ -240,8 +221,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showRemoveSignatureButton true and showApplySignatureButton false for an internal user and a signed document that is not a draft stamp order', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -262,8 +241,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showRemoveSignatureButton false for NOT document type and internal users', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -289,8 +266,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showRemoveSignatureButton false for NTD document type and internal users', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -316,8 +291,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showRemoveSignatureButton false for SDEC document type and internal users', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -343,8 +316,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showRemoveSignatureButton false for a draft stamp order', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -363,8 +334,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showEditButtonSigned true for an internal user, a document that is signed, and is not a draft stamp order', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -384,8 +353,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showEditButtonNotSigned true for an internal user and a document that is not signed', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -399,8 +366,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showEditButtonSigned false for an external user', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(petitionerUser), @@ -414,8 +379,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showEditButtonSigned false for a draft stamp order', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(petitionerUser), @@ -434,8 +397,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showEditButtonNotSigned true and showEditButtonSigned false for a Notice document', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), @@ -458,8 +419,6 @@ describe('draftDocumentViewerHelper', () => { }); it('should return showEditButtonNotSigned false and showEditButtonSigned false for a Stipulated Decision document', () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const result = runCompute(draftDocumentViewerHelper, { state: { ...getBaseState(docketClerkUser), diff --git a/web-client/src/presenter/computeds/draftDocumentViewerHelper.ts b/web-client/src/presenter/computeds/draftDocumentViewerHelper.ts index 873a20ab2a3..c7621f86af7 100644 --- a/web-client/src/presenter/computeds/draftDocumentViewerHelper.ts +++ b/web-client/src/presenter/computeds/draftDocumentViewerHelper.ts @@ -12,7 +12,7 @@ export const draftDocumentViewerHelper = ( NOTICE_EVENT_CODES, STIPULATED_DECISION_EVENT_CODE, } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const permissions = get(state.permissions); const caseDetail = get(state.caseDetail); @@ -20,6 +20,7 @@ export const draftDocumentViewerHelper = ( .getUtilities() .getFormattedCaseDetail({ applicationContext, + authorizedUser: user, caseDetail, }); diff --git a/web-client/src/presenter/computeds/messageModalHelper.ts b/web-client/src/presenter/computeds/messageModalHelper.ts index 28cc4be40eb..5e4b5d28288 100644 --- a/web-client/src/presenter/computeds/messageModalHelper.ts +++ b/web-client/src/presenter/computeds/messageModalHelper.ts @@ -20,6 +20,7 @@ export const messageModalHelper = ( const screenMetadata = get(state.screenMetadata); const attachments = get(state.modal.form.attachments); const draftAttachments = get(state.modal.form.draftAttachments); + const user = get(state.user); const currentAttachments = [...attachments, ...draftAttachments]; const computeIsAlreadyAttached = doc => @@ -28,9 +29,11 @@ export const messageModalHelper = ( ); const { correspondence, draftDocuments, formattedDocketEntries } = - applicationContext - .getUtilities() - .getFormattedCaseDetail({ applicationContext, caseDetail }); + applicationContext.getUtilities().getFormattedCaseDetail({ + applicationContext, + authorizedUser: user, + caseDetail, + }); const documents: (RawDocketEntry & { isAlreadyAttached: boolean; From 66ac013122b024a8ceb0cba7d1f701de75710e37 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 13:14:41 -0700 Subject: [PATCH 121/523] 10417: Remove getCurrentUser from shared --- .../src/business/utilities/uploadToS3.test.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/shared/src/business/utilities/uploadToS3.test.ts b/shared/src/business/utilities/uploadToS3.test.ts index 92ef82debfc..2ffce7a0347 100644 --- a/shared/src/business/utilities/uploadToS3.test.ts +++ b/shared/src/business/utilities/uploadToS3.test.ts @@ -1,5 +1,3 @@ -import { ROLES } from '../entities/EntityConstants'; -import { User } from '../entities/User'; import { applicationContext } from '../test/createTestApplicationContext'; import { testPdfDoc } from '../test/getFakeFile'; import { uploadToS3 } from './uploadToS3'; @@ -15,14 +13,6 @@ describe('uploadToS3', () => { }; it('fails and logs if the s3 upload fails', async () => { - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'bob', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), - ); - let mockPdfName = 'pdf name'; applicationContext.getStorageClient.mockReturnValue({ @@ -47,14 +37,6 @@ describe('uploadToS3', () => { }); it('should not log if the s3 upload completes', async () => { - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'bob', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), - ); - let mockPdfName = 'pdf name'; applicationContext.getStorageClient.mockReturnValue({ From 2b9311b86a001346dfc1b08b1d42f9d458f8f6ac Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 13:14:52 -0700 Subject: [PATCH 122/523] 10417: Remove getCurrentUser from web-api --- .../caseAdvancedSearchInteractor.test.ts | 144 +++++++++--------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/web-api/src/business/useCases/caseAdvancedSearchInteractor.test.ts b/web-api/src/business/useCases/caseAdvancedSearchInteractor.test.ts index 06f883c39bb..a156e16f313 100644 --- a/web-api/src/business/useCases/caseAdvancedSearchInteractor.test.ts +++ b/web-api/src/business/useCases/caseAdvancedSearchInteractor.test.ts @@ -1,38 +1,34 @@ -import { - MAX_SEARCH_RESULTS, - ROLES, -} from '../../../../shared/src/business/entities/EntityConstants'; +import { MAX_SEARCH_RESULTS } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { caseAdvancedSearchInteractor } from './caseAdvancedSearchInteractor'; +import { + mockIrsPractitionerUser, + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('caseAdvancedSearchInteractor', () => { - let mockUser; - - beforeEach(() => { - mockUser = { - role: ROLES.petitionsClerk, - }; - - applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - - applicationContext - .getPersistenceGateway() - .caseAdvancedSearch.mockResolvedValue([]); - }); - it('returns an unauthorized error on petitioner user role', async () => { - mockUser.role = ROLES.petitioner; - await expect( - caseAdvancedSearchInteractor(applicationContext, {} as any), + caseAdvancedSearchInteractor( + applicationContext, + { petitionerName: 'Janae Jacobs' }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('returns empty array if no search params are passed in', async () => { + applicationContext + .getPersistenceGateway() + .caseAdvancedSearch.mockResolvedValue([]); + const results = await caseAdvancedSearchInteractor( applicationContext, - {} as any, + { + petitionerName: 'Paul Billings', + }, + mockPetitionsClerkUser, ); expect(results).toEqual([]); @@ -52,9 +48,13 @@ describe('caseAdvancedSearchInteractor', () => { }, ]); - const results = await caseAdvancedSearchInteractor(applicationContext, { - petitionerName: 'test person', - } as any); + const results = await caseAdvancedSearchInteractor( + applicationContext, + { + petitionerName: 'test person', + }, + mockPetitionsClerkUser, + ); expect(results).toEqual([ { docketNumber: '101-20', petitioners: [] }, @@ -76,11 +76,15 @@ describe('caseAdvancedSearchInteractor', () => { }, ]); - const results = await caseAdvancedSearchInteractor(applicationContext, { - endDate: '07/29/1993', - petitionerName: 'test person', - startDate: '05/18/1985', - } as any); + const results = await caseAdvancedSearchInteractor( + applicationContext, + { + endDate: '07/29/1993', + petitionerName: 'test person', + startDate: '05/18/1985', + }, + mockPetitionsClerkUser, + ); expect(results).toEqual([ { docketNumber: '101-20', petitioners: [] }, @@ -89,11 +93,6 @@ describe('caseAdvancedSearchInteractor', () => { }); it('filters out sealed cases for non associated, non authorized users', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: 'b45a0633-acda-499e-8fab-8785baeafed7', - }); - applicationContext .getPersistenceGateway() .caseAdvancedSearch.mockResolvedValue([ @@ -105,19 +104,18 @@ describe('caseAdvancedSearchInteractor', () => { }, ]); - const results = await caseAdvancedSearchInteractor(applicationContext, { - petitionerName: 'test person', - } as any); + const results = await caseAdvancedSearchInteractor( + applicationContext, + { + petitionerName: 'test person', + }, + mockIrsPractitionerUser, + ); expect(results).toEqual([]); }); it('filters out sealed cases that do not have a sealedDate for non associated, non authorized users', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: 'b45a0633-acda-499e-8fab-8785baeafed7', - }); - applicationContext .getPersistenceGateway() .caseAdvancedSearch.mockResolvedValue([ @@ -129,19 +127,18 @@ describe('caseAdvancedSearchInteractor', () => { }, ]); - const results = await caseAdvancedSearchInteractor(applicationContext, { - petitionerName: 'test person', - } as any); + const results = await caseAdvancedSearchInteractor( + applicationContext, + { + petitionerName: 'test person', + }, + mockIrsPractitionerUser, + ); expect(results).toEqual([]); }); it('returns no more than MAX_SEARCH_RESULTS', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: 'b45a0633-acda-499e-8fab-8785baeafed7', - }); - const maxPlusOneResults = new Array(MAX_SEARCH_RESULTS + 1).fill({ docketNumber: '101-20', petitioners: [], @@ -152,19 +149,18 @@ describe('caseAdvancedSearchInteractor', () => { .getPersistenceGateway() .caseAdvancedSearch.mockResolvedValue(maxPlusOneResults); - const results = await caseAdvancedSearchInteractor(applicationContext, { - petitionerName: 'test person', - } as any); + const results = await caseAdvancedSearchInteractor( + applicationContext, + { + petitionerName: 'test person', + }, + mockIrsPractitionerUser, + ); expect(results.length).toBe(MAX_SEARCH_RESULTS); }); it('returns results if practitioner is associated', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', - }); - applicationContext .getPersistenceGateway() .caseAdvancedSearch.mockResolvedValue([ @@ -172,7 +168,7 @@ describe('caseAdvancedSearchInteractor', () => { docketNumber: '101-20', irsPractitioners: [ { - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + userId: mockIrsPractitionerUser.userId, }, ], petitioners: [], @@ -180,16 +176,20 @@ describe('caseAdvancedSearchInteractor', () => { }, ]); - const results = await caseAdvancedSearchInteractor(applicationContext, { - petitionerName: 'test person', - } as any); + const results = await caseAdvancedSearchInteractor( + applicationContext, + { + petitionerName: 'test person', + }, + mockIrsPractitionerUser, + ); expect(results).toEqual([ { docketNumber: '101-20', irsPractitioners: [ { - userId: 'e8577e31-d6d5-4c4a-adc6-520075f3dde5', + userId: mockIrsPractitionerUser.userId, }, ], petitioners: [], @@ -199,10 +199,6 @@ describe('caseAdvancedSearchInteractor', () => { }); it('returns results for petitionsclerk or internal user always', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - }); - applicationContext .getPersistenceGateway() .caseAdvancedSearch.mockResolvedValue([ @@ -213,9 +209,13 @@ describe('caseAdvancedSearchInteractor', () => { }, ]); - const results = await caseAdvancedSearchInteractor(applicationContext, { - petitionerName: 'test person', - } as any); + const results = await caseAdvancedSearchInteractor( + applicationContext, + { + petitionerName: 'test person', + }, + mockPetitionsClerkUser, + ); expect(results).toEqual([ { From 83e296c6a8aab2682ea00393a267a7c84094f9ba Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 13:16:32 -0700 Subject: [PATCH 123/523] 10417: Remove getCurrentUser from web-api --- .../useCases/addPetitionerToCaseInteractor.test.ts | 6 ------ .../business/useCases/addPetitionerToCaseInteractor.ts | 10 +--------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/web-api/src/business/useCases/addPetitionerToCaseInteractor.test.ts b/web-api/src/business/useCases/addPetitionerToCaseInteractor.test.ts index c2e121096e6..f97515d5715 100644 --- a/web-api/src/business/useCases/addPetitionerToCaseInteractor.test.ts +++ b/web-api/src/business/useCases/addPetitionerToCaseInteractor.test.ts @@ -2,7 +2,6 @@ import { CASE_STATUS_TYPES, CONTACT_TYPES, COUNTRY_TYPES, - ROLES, SERVICE_INDICATOR_TYPES, } from '../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; @@ -48,11 +47,6 @@ describe('addPetitionerToCaseInteractor', () => { }); it('should throw an unauthorized error when the user is not authorized to add petitioner to case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); - await expect( addPetitionerToCaseInteractor( applicationContext, diff --git a/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts b/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts index 9ec3fe176a7..7f8ad2d28e9 100644 --- a/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts +++ b/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts @@ -10,14 +10,6 @@ import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -/** - * used to add a petitioner to a case - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.contact the contact data to add to the case - * @param {string} providers.docketNumber the docket number of the case - * @returns {object} the case data - */ export const addPetitionerToCase = async ( applicationContext: ServerApplicationContext, { @@ -26,7 +18,7 @@ export const addPetitionerToCase = async ( docketNumber, }: { caseCaption: string; contact: any; docketNumber: string }, authorizedUser: UnknownAuthUser, -) => { +): Promise => { if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_PETITIONER_TO_CASE)) { throw new UnauthorizedError('Unauthorized for adding petitioner to case'); } From 8d9a379417bdcc7b0aca650ebac9c0bfd0928488 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 13:18:29 -0700 Subject: [PATCH 124/523] 10417: Remove getCurrentUser from shared --- shared/src/proxies/verifyPendingCaseForUserProxy.ts | 5 ++--- web-client/src/presenter/actions/getCaseAssociationAction.ts | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/src/proxies/verifyPendingCaseForUserProxy.ts b/shared/src/proxies/verifyPendingCaseForUserProxy.ts index bd42dd42bec..245a7a5b110 100644 --- a/shared/src/proxies/verifyPendingCaseForUserProxy.ts +++ b/shared/src/proxies/verifyPendingCaseForUserProxy.ts @@ -10,11 +10,10 @@ import { get } from './requests'; */ export const verifyPendingCaseForUserInteractor = ( applicationContext, - { docketNumber }, + { docketNumber, userId }: { docketNumber: string; userId: string }, ) => { - const user = applicationContext.getCurrentUser(); return get({ applicationContext, - endpoint: `/users/${user.userId}/case/${docketNumber}/pending`, + endpoint: `/users/${userId}/case/${docketNumber}/pending`, }); }; diff --git a/web-client/src/presenter/actions/getCaseAssociationAction.ts b/web-client/src/presenter/actions/getCaseAssociationAction.ts index 8b2a3c3066a..ee80eca7cc7 100644 --- a/web-client/src/presenter/actions/getCaseAssociationAction.ts +++ b/web-client/src/presenter/actions/getCaseAssociationAction.ts @@ -68,6 +68,7 @@ export const getCaseAssociationAction = async ({ .getUseCases() .verifyPendingCaseForUserInteractor(applicationContext, { docketNumber: caseDetail.docketNumber, + userId: user.userId, }); } From 1febe4a6ae4a738c72e3f7f64d2c80deb3103a89 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 13:18:50 -0700 Subject: [PATCH 125/523] 10417: Remove getCurrentUser from web-api --- .../src/business/useCases/createCaseFromPaperInteractor.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/web-api/src/business/useCases/createCaseFromPaperInteractor.test.ts b/web-api/src/business/useCases/createCaseFromPaperInteractor.test.ts index 9f6f07b6c8a..7278ba35957 100644 --- a/web-api/src/business/useCases/createCaseFromPaperInteractor.test.ts +++ b/web-api/src/business/useCases/createCaseFromPaperInteractor.test.ts @@ -63,8 +63,6 @@ describe('createCaseFromPaperInteractor', () => { name: 'john doe', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); - - applicationContext.getCurrentUser.mockReturnValue(mockPetitionsClerkUser); }); it('throws an error if the user is not valid or authorized', async () => { From cffa5fdaa25d141a28e5cdba172ee62ac8d42c86 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 13:23:07 -0700 Subject: [PATCH 126/523] 10417: Remove getCurrentUser from shared --- .../proxies/documents/submitCaseAssociationRequestProxy.ts | 5 +++-- .../FileDocument/submitCaseAssociationRequestAction.ts | 1 + .../submitRespondentCaseAssociationRequestAction.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/shared/src/proxies/documents/submitCaseAssociationRequestProxy.ts b/shared/src/proxies/documents/submitCaseAssociationRequestProxy.ts index 167dc7c3d20..9f9fc90c785 100644 --- a/shared/src/proxies/documents/submitCaseAssociationRequestProxy.ts +++ b/shared/src/proxies/documents/submitCaseAssociationRequestProxy.ts @@ -14,18 +14,19 @@ export const submitCaseAssociationRequestInteractor = ( { docketNumber, filers, + userId, }: { docketNumber: string; + userId: string; filers?: string[]; }, ) => { - const user = applicationContext.getCurrentUser(); return put({ applicationContext, body: { docketNumber, filers, }, - endpoint: `/users/${user.userId}/case/${docketNumber}`, + endpoint: `/users/${userId}/case/${docketNumber}`, }); }; diff --git a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts index 2556fd06a7f..d30549cd1b1 100644 --- a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts +++ b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts @@ -55,6 +55,7 @@ export const submitCaseAssociationRequestAction = async ({ .submitCaseAssociationRequestInteractor(applicationContext, { docketNumber, filers: documentMetadata.filers, + userId: user.userId, }); } else if (isDocumentWithPendingAssociation) { await applicationContext diff --git a/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.ts b/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.ts index d645796bdb6..b9b17cfb6e5 100644 --- a/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.ts +++ b/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.ts @@ -22,6 +22,7 @@ export const submitRespondentCaseAssociationRequestAction = async ({ .getUseCases() .submitCaseAssociationRequestInteractor(applicationContext, { docketNumber, + userId: user.userId, }); } }; From 794171ae23ab8cf9fa934ebece45fd807c325749 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 13:24:27 -0700 Subject: [PATCH 127/523] 10417: Remove getCurrentUser from web-api --- .../archiveDraftDocumentInteractor.test.ts | 71 ++++++++++++------- .../archiveDraftDocumentInteractor.ts | 10 +-- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/web-api/src/business/useCases/archiveDraftDocumentInteractor.test.ts b/web-api/src/business/useCases/archiveDraftDocumentInteractor.test.ts index ac940acb2cd..d8fbf3915a9 100644 --- a/web-api/src/business/useCases/archiveDraftDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/archiveDraftDocumentInteractor.test.ts @@ -4,14 +4,20 @@ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants' import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { archiveDraftDocumentInteractor } from './archiveDraftDocumentInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('archiveDraftDocumentInteractor', () => { let mockLock; + beforeAll(() => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => mockLock); }); + beforeEach(() => { mockLock = undefined; @@ -21,13 +27,15 @@ describe('archiveDraftDocumentInteractor', () => { }); it('returns an unauthorized error on non petitionsclerk users', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - archiveDraftDocumentInteractor(applicationContext, { - docketEntryId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', - docketNumber: '101-20', - }), + archiveDraftDocumentInteractor( + applicationContext, + { + docketEntryId: 'a54ba5a9-b37b-479d-9201-067ec6e335bb', + docketNumber: '101-20', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -36,15 +44,18 @@ describe('archiveDraftDocumentInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); - await archiveDraftDocumentInteractor(applicationContext, { - docketEntryId: 'abc81f4d-1e47-423a-8caf-6d2fdc3d3859', - docketNumber: '101-20', - }); + await archiveDraftDocumentInteractor( + applicationContext, + { + docketEntryId: 'abc81f4d-1e47-423a-8caf-6d2fdc3d3859', + docketNumber: '101-20', + }, + mockPetitionsClerkUser, + ); const { caseToUpdate } = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock .calls[0][0]; - expect( caseToUpdate.archivedDocketEntries.find( d => d.docketEntryId === 'abc81f4d-1e47-423a-8caf-6d2fdc3d3859', @@ -53,7 +64,6 @@ describe('archiveDraftDocumentInteractor', () => { archived: true, docketEntryId: 'abc81f4d-1e47-423a-8caf-6d2fdc3d3859', }); - expect( caseToUpdate.docketEntries.find( d => d.docketEntryId === 'abc81f4d-1e47-423a-8caf-6d2fdc3d3859', @@ -91,10 +101,14 @@ describe('archiveDraftDocumentInteractor', () => { ], }); - await archiveDraftDocumentInteractor(applicationContext, { - docketEntryId: '99981f4d-1e47-423a-8caf-6d2fdc3d3999', - docketNumber: '101-20', - }); + await archiveDraftDocumentInteractor( + applicationContext, + { + docketEntryId: '99981f4d-1e47-423a-8caf-6d2fdc3d3999', + docketNumber: '101-20', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteWorkItem, @@ -105,10 +119,14 @@ describe('archiveDraftDocumentInteractor', () => { mockLock = MOCK_LOCK; await expect( - archiveDraftDocumentInteractor(applicationContext, { - docketEntryId: 'abc81f4d-1e47-423a-8caf-6d2fdc3d3859', - docketNumber: '101-20', - }), + archiveDraftDocumentInteractor( + applicationContext, + { + docketEntryId: 'abc81f4d-1e47-423a-8caf-6d2fdc3d3859', + docketNumber: '101-20', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -117,10 +135,14 @@ describe('archiveDraftDocumentInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await await archiveDraftDocumentInteractor(applicationContext, { - docketEntryId: 'abc81f4d-1e47-423a-8caf-6d2fdc3d3859', - docketNumber: MOCK_CASE.docketNumber, - }); + await await archiveDraftDocumentInteractor( + applicationContext, + { + docketEntryId: 'abc81f4d-1e47-423a-8caf-6d2fdc3d3859', + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -129,7 +151,6 @@ describe('archiveDraftDocumentInteractor', () => { identifier: `case|${MOCK_CASE.docketNumber}`, ttl: 30, }); - expect( applicationContext.getPersistenceGateway().removeLock, ).toHaveBeenCalledWith({ diff --git a/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts b/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts index 47d1b156775..e41fb8405fc 100644 --- a/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts +++ b/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts @@ -8,14 +8,6 @@ import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -/** - * archiveDraftDocumentInteractor - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.docketNumber the docket number of the case on which a document will be archived - * @param {string} providers.docketEntryId the id of the docket entry which will be archived - * @returns {object} the updated case note returned from persistence - */ export const archiveDraftDocument = async ( applicationContext: ServerApplicationContext, { @@ -23,7 +15,7 @@ export const archiveDraftDocument = async ( docketNumber, }: { docketEntryId: string; docketNumber: string }, authorizedUser: UnknownAuthUser, -) => { +): Promise => { if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ARCHIVE_DOCUMENT)) { throw new UnauthorizedError('Unauthorized'); } From a78aef4a254c30743f45fe82ff13d219725d9f2f Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 13:26:40 -0700 Subject: [PATCH 128/523] 10417: Remove getCurrentUser from shared --- .../documents/submitPendingCaseAssociationRequestProxy.ts | 5 ++--- .../FileDocument/submitCaseAssociationRequestAction.ts | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/src/proxies/documents/submitPendingCaseAssociationRequestProxy.ts b/shared/src/proxies/documents/submitPendingCaseAssociationRequestProxy.ts index 14746b266eb..20727497a39 100644 --- a/shared/src/proxies/documents/submitPendingCaseAssociationRequestProxy.ts +++ b/shared/src/proxies/documents/submitPendingCaseAssociationRequestProxy.ts @@ -10,11 +10,10 @@ import { put } from '../requests'; */ export const submitPendingCaseAssociationRequestInteractor = ( applicationContext, - { docketNumber }, + { docketNumber, userId }: { docketNumber: string; userId: string }, ) => { - const user = applicationContext.getCurrentUser(); return put({ applicationContext, - endpoint: `/users/${user.userId}/case/${docketNumber}/pending`, + endpoint: `/users/${userId}/case/${docketNumber}/pending`, }); }; diff --git a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts index d30549cd1b1..6af62581c8b 100644 --- a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts +++ b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts @@ -62,6 +62,7 @@ export const submitCaseAssociationRequestAction = async ({ .getUseCases() .submitPendingCaseAssociationRequestInteractor(applicationContext, { docketNumber, + userId: user.userId, }); } From 8e800a0cb592435063d0f1f3cd2bbb58b2b846c1 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 5 Jul 2024 13:27:18 -0700 Subject: [PATCH 129/523] 10417: Remove getCurrentUser from web-api --- .../business/useCases/archiveDraftDocumentInteractor.test.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/web-api/src/business/useCases/archiveDraftDocumentInteractor.test.ts b/web-api/src/business/useCases/archiveDraftDocumentInteractor.test.ts index d8fbf3915a9..da39f5846e1 100644 --- a/web-api/src/business/useCases/archiveDraftDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/archiveDraftDocumentInteractor.test.ts @@ -20,10 +20,6 @@ describe('archiveDraftDocumentInteractor', () => { beforeEach(() => { mockLock = undefined; - - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - }); }); it('returns an unauthorized error on non petitionsclerk users', async () => { From aa4763306da97d87e5f45c78716074d18d656356 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 13:37:30 -0700 Subject: [PATCH 130/523] 10417: Remove getCurrentUserToken from applicationContext. We do not want to store any state in applicationContext. --- .../test/createTestApplicationContext.ts | 4 ---- shared/src/proxies/requests.ts | 18 +++++++++++++----- web-client/src/applicationContext.ts | 10 ---------- web-client/src/applicationContextPublic.ts | 1 - web-client/src/persistence/s3/getDocument.ts | 3 ++- .../persistence/s3/uploadDocumentFromClient.ts | 4 +++- .../actions/Login/setTokenAction.test.ts | 7 +++---- .../presenter/actions/Login/setTokenAction.ts | 4 ++-- .../src/presenter/actions/clearUserAction.ts | 3 ++- .../actions/startRefreshIntervalAction.ts | 3 ++- .../test/createClientTestApplicationContext.ts | 4 ---- 11 files changed, 27 insertions(+), 34 deletions(-) diff --git a/shared/src/business/test/createTestApplicationContext.ts b/shared/src/business/test/createTestApplicationContext.ts index 9817f20f007..cde29797ebe 100644 --- a/shared/src/business/test/createTestApplicationContext.ts +++ b/shared/src/business/test/createTestApplicationContext.ts @@ -635,9 +635,6 @@ export const createTestApplicationContext = ({ ); }), getCurrentUserPermissions: jest.fn(), - getCurrentUserToken: () => { - return ''; - }, getDispatchers: jest.fn().mockReturnValue({ sendBulkTemplatedEmail: jest.fn(), sendNotificationOfSealing: jest.fn(), @@ -699,7 +696,6 @@ export const createTestApplicationContext = ({ warn: jest.fn(), }, setCurrentUser: jest.fn(), - setCurrentUserToken: jest.fn(), setTimeout: jest.fn().mockImplementation(callback => callback()), }; return applicationContext; diff --git a/shared/src/proxies/requests.ts b/shared/src/proxies/requests.ts index 026422bec76..d2236b2549a 100644 --- a/shared/src/proxies/requests.ts +++ b/shared/src/proxies/requests.ts @@ -3,6 +3,14 @@ import moize from 'moize'; const MAX_RETRIES = 10; +let token: string = ''; +export const getCurrentUserToken = (): string => { + return token; +}; +export const setCurrentUserToken = (newToken: string) => { + token = newToken; +}; + /** * *head @@ -16,7 +24,7 @@ export const head = async ({ applicationContext, endpoint, params }) => { return await applicationContext .getHttpClient() .head(`${applicationContext.getBaseUrl()}${endpoint}`, { - headers: getDefaultHeaders(applicationContext.getCurrentUserToken()), + headers: getDefaultHeaders(getCurrentUserToken()), params, }) .then(response => response.data); @@ -61,7 +69,7 @@ export const getResponse = ({ applicationContext, endpoint, params }) => { return applicationContext .getHttpClient() .get(`${applicationContext.getBaseUrl()}${endpoint}`, { - headers: getDefaultHeaders(applicationContext.getCurrentUserToken()), + headers: getDefaultHeaders(getCurrentUserToken()), params, }); }; @@ -102,7 +110,7 @@ export const post = async ({ .getHttpClient() .post(`${applicationContext.getBaseUrl()}${endpoint}`, body, { headers: { - ...getDefaultHeaders(applicationContext.getCurrentUserToken()), + ...getDefaultHeaders(getCurrentUserToken()), ...headers, Asyncsyncid: asyncSyncId, }, @@ -179,7 +187,7 @@ export const put = async ({ .getHttpClient() .put(`${applicationContext.getBaseUrl()}${endpoint}`, body, { headers: { - ...getDefaultHeaders(applicationContext.getCurrentUserToken()), + ...getDefaultHeaders(getCurrentUserToken()), Asyncsyncid: asyncSyncId, }, }) @@ -230,7 +238,7 @@ export const remove = async ({ return await applicationContext .getHttpClient() .delete(`${applicationContext.getBaseUrl()}${endpoint}`, { - headers: getDefaultHeaders(applicationContext.getCurrentUserToken()), + headers: getDefaultHeaders(getCurrentUserToken()), params, ...options, }) diff --git a/web-client/src/applicationContext.ts b/web-client/src/applicationContext.ts index d6d4059d18e..bf9af77f5d3 100644 --- a/web-client/src/applicationContext.ts +++ b/web-client/src/applicationContext.ts @@ -380,14 +380,6 @@ const setCurrentUser = ( user = newUser; }; -let token; -const getCurrentUserToken = () => { - return token; -}; -const setCurrentUserToken = newToken => { - token = newToken; -}; - let forceRefreshCallback: () => {}; const allUseCases = { @@ -657,7 +649,6 @@ const applicationContext = { const currentUser = getCurrentUser(); return getUserPermissions(currentUser); }, - getCurrentUserToken, getEnvironment, getFileReaderInstance: () => new FileReader(), getForceRefreshCallback() { @@ -821,7 +812,6 @@ const applicationContext = { }, isPublicUser: () => false, setCurrentUser, - setCurrentUserToken, setForceRefreshCallback(callback) { forceRefreshCallback = callback; }, diff --git a/web-client/src/applicationContextPublic.ts b/web-client/src/applicationContextPublic.ts index 2ecf613c5f2..dca6e01c52c 100644 --- a/web-client/src/applicationContextPublic.ts +++ b/web-client/src/applicationContextPublic.ts @@ -170,7 +170,6 @@ const applicationContextPublic = { getCaseTitle: Case.getCaseTitle, getConstants: () => frozenConstants, getCurrentUser: () => ({}), - getCurrentUserToken: () => null, getEnvironment, getForceRefreshCallback() { return forceRefreshCallback; diff --git a/web-client/src/persistence/s3/getDocument.ts b/web-client/src/persistence/s3/getDocument.ts index ef000d374cd..a7ac6bacc7e 100644 --- a/web-client/src/persistence/s3/getDocument.ts +++ b/web-client/src/persistence/s3/getDocument.ts @@ -1,3 +1,4 @@ +import { getCurrentUserToken } from '@shared/proxies/requests'; import { getPdfFromUrl } from './getPdfFromUrl'; const getDownloadPolicy = async ({ @@ -17,7 +18,7 @@ const getDownloadPolicy = async ({ `${applicationContext.getBaseUrl()}/case-documents/${docketNumber}/${key}/download-policy-url`, { headers: { - Authorization: `Bearer ${applicationContext.getCurrentUserToken()}`, + Authorization: `Bearer ${getCurrentUserToken()}`, }, }, ); diff --git a/web-client/src/persistence/s3/uploadDocumentFromClient.ts b/web-client/src/persistence/s3/uploadDocumentFromClient.ts index 36f774bbdfe..ff4bb4f8d2b 100644 --- a/web-client/src/persistence/s3/uploadDocumentFromClient.ts +++ b/web-client/src/persistence/s3/uploadDocumentFromClient.ts @@ -1,9 +1,11 @@ +import { getCurrentUserToken } from '@shared/proxies/requests'; + const getUploadPolicy = async ({ applicationContext, key }) => { const response = await applicationContext .getHttpClient() .get(`${applicationContext.getBaseUrl()}/documents/${key}/upload-policy`, { headers: { - Authorization: `Bearer ${applicationContext.getCurrentUserToken()}`, + Authorization: `Bearer ${getCurrentUserToken()}`, }, }); return response.data; diff --git a/web-client/src/presenter/actions/Login/setTokenAction.test.ts b/web-client/src/presenter/actions/Login/setTokenAction.test.ts index 63c648dccb0..86ff8da3019 100644 --- a/web-client/src/presenter/actions/Login/setTokenAction.test.ts +++ b/web-client/src/presenter/actions/Login/setTokenAction.test.ts @@ -1,4 +1,5 @@ import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { getCurrentUserToken } from '@shared/proxies/requests'; import { presenter } from '../../presenter-mock'; import { runAction } from '@web-client/presenter/test.cerebral'; import { setTokenAction } from './setTokenAction'; @@ -24,7 +25,7 @@ describe('setTokenAction,', () => { expect(state.token).toEqual(mockToken); }); - it('should call applicationContext.setCurrentUserToken with props.token', async () => { + it('should setCurrentUserToken with props.token', async () => { await runAction(setTokenAction, { modules: { presenter, @@ -35,8 +36,6 @@ describe('setTokenAction,', () => { state: {}, }); - expect(applicationContext.setCurrentUserToken.mock.calls[0][0]).toEqual( - mockToken, - ); + expect(getCurrentUserToken()).toEqual(mockToken); }); }); diff --git a/web-client/src/presenter/actions/Login/setTokenAction.ts b/web-client/src/presenter/actions/Login/setTokenAction.ts index 476dfce4d52..69c23c7491c 100644 --- a/web-client/src/presenter/actions/Login/setTokenAction.ts +++ b/web-client/src/presenter/actions/Login/setTokenAction.ts @@ -1,11 +1,11 @@ +import { setCurrentUserToken } from '@shared/proxies/requests'; import { state } from '@web-client/presenter/app.cerebral'; export const setTokenAction = ({ - applicationContext, props, store, }: ActionProps<{ idToken: string }>): void => { store.set(state.token, props.idToken); - applicationContext.setCurrentUserToken(props.idToken); + setCurrentUserToken(props.idToken); }; diff --git a/web-client/src/presenter/actions/clearUserAction.ts b/web-client/src/presenter/actions/clearUserAction.ts index 852fe0bd23b..7d704da24fa 100644 --- a/web-client/src/presenter/actions/clearUserAction.ts +++ b/web-client/src/presenter/actions/clearUserAction.ts @@ -1,3 +1,4 @@ +import { setCurrentUserToken } from '@shared/proxies/requests'; import { state } from '@web-client/presenter/app.cerebral'; export const clearUserAction = async ({ @@ -20,5 +21,5 @@ export const clearUserAction = async ({ }); applicationContext.setCurrentUser(null); - applicationContext.setCurrentUserToken(null); + setCurrentUserToken(''); }; diff --git a/web-client/src/presenter/actions/startRefreshIntervalAction.ts b/web-client/src/presenter/actions/startRefreshIntervalAction.ts index b69ae2548ce..b516713c68b 100644 --- a/web-client/src/presenter/actions/startRefreshIntervalAction.ts +++ b/web-client/src/presenter/actions/startRefreshIntervalAction.ts @@ -1,3 +1,4 @@ +import { setCurrentUserToken } from '@shared/proxies/requests'; import { state } from '@web-client/presenter/app.cerebral'; export const startRefreshIntervalAction = ({ @@ -15,7 +16,7 @@ export const startRefreshIntervalAction = ({ .renewIdTokenInteractor(applicationContext); store.set(state.token, response.idToken); - applicationContext.setCurrentUserToken(response.idToken); + setCurrentUserToken(response.idToken); } }; diff --git a/web-client/src/test/createClientTestApplicationContext.ts b/web-client/src/test/createClientTestApplicationContext.ts index 25322865cf6..70f28f9606a 100644 --- a/web-client/src/test/createClientTestApplicationContext.ts +++ b/web-client/src/test/createClientTestApplicationContext.ts @@ -556,9 +556,6 @@ const createTestApplicationContext = () => { }); }), getCurrentUserPermissions: jest.fn(), - getCurrentUserToken: () => { - return ''; - }, getDispatchers: jest.fn().mockReturnValue({ sendBulkTemplatedEmail: jest.fn(), sendNotificationOfSealing: jest.fn(), @@ -610,7 +607,6 @@ const createTestApplicationContext = () => { isFeatureEnabled: jest.fn(), isPublicUser: jest.fn().mockImplementation(() => false), setCurrentUser: jest.fn(), - setCurrentUserToken: jest.fn(), }; return applicationContext; }; From 8a502445133b479ea55216b291549f666346ffa3 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 14:02:15 -0700 Subject: [PATCH 131/523] 10417: Remove getCurrentUserToken from applicationContext. We do not want to store any state in applicationContext. --- ...orCalendaredTrialSessionInteractor.test.ts | 97 +++++++++++-------- ...icesForCalendaredTrialSessionInteractor.ts | 16 +-- ...tNoticesForCalendaredTrialSessionLambda.ts | 31 ++++-- 3 files changed, 84 insertions(+), 60 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.ts index 99c13024e19..06ee3936104 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.ts @@ -1,26 +1,13 @@ import { MOCK_TRIAL_REGULAR } from '../../../../../shared/src/test/mockTrial'; -import { - PARTY_TYPES, - ROLES, - TRIAL_SESSION_PROCEEDING_TYPES, -} from '../../../../../shared/src/business/entities/EntityConstants'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { setNoticesForCalendaredTrialSessionInteractor } from './setNoticesForCalendaredTrialSessionInteractor'; describe('setNoticesForCalendaredTrialSessionInteractor', () => { - const unAuthorizedUser = new User({ - name: PARTY_TYPES.petitioner, - role: ROLES.petitioner, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - - const user = new User({ - name: PARTY_TYPES.petitioner, - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - const trialSessionId = '6805d1ab-18d0-43ec-bafb-654e83405416'; beforeEach(() => { @@ -37,7 +24,6 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { docketNumber: '103-20', }, ]); - applicationContext.getCurrentUser.mockReturnValue(user); applicationContext .getPersistenceGateway() .getTrialSessionById.mockResolvedValue({ @@ -73,13 +59,16 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { }); it('should return an unauthorized error if the user does not have the TRIAL_SESSIONS permission', async () => { - applicationContext.getCurrentUser.mockReturnValue(unAuthorizedUser); let error; try { - await setNoticesForCalendaredTrialSessionInteractor(applicationContext, { - trialSessionId, - }); + await setNoticesForCalendaredTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + mockPetitionerUser, + ); } catch (e) { error = e; } @@ -92,9 +81,13 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { .getPersistenceGateway() .isFileExists.mockResolvedValue(false); - await setNoticesForCalendaredTrialSessionInteractor(applicationContext, { - trialSessionId, - }); + await setNoticesForCalendaredTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDocument, @@ -109,9 +102,13 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionProcessingStatus.mockResolvedValueOnce('processing'); - await setNoticesForCalendaredTrialSessionInteractor(applicationContext, { - trialSessionId, - }); + await setNoticesForCalendaredTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getMessageGateway().sendSetTrialSessionCalendarEvent, ).not.toHaveBeenCalled(); @@ -123,9 +120,13 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionProcessingStatus.mockResolvedValueOnce('complete'); - await setNoticesForCalendaredTrialSessionInteractor(applicationContext, { - trialSessionId, - }); + await setNoticesForCalendaredTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getMessageGateway().sendSetTrialSessionCalendarEvent, ).not.toHaveBeenCalled(); @@ -135,9 +136,13 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { }); it('should set trialSessionStatus to processing if this is the first trial session calendering event', async () => { - await setNoticesForCalendaredTrialSessionInteractor(applicationContext, { - trialSessionId, - }); + await setNoticesForCalendaredTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -156,9 +161,13 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { unfinishedCases: 0, }); - await setNoticesForCalendaredTrialSessionInteractor(applicationContext, { - trialSessionId, - }); + await setNoticesForCalendaredTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -175,9 +184,13 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { .getPersistenceGateway() .getCalendaredCasesForTrialSession.mockResolvedValue([]); - await setNoticesForCalendaredTrialSessionInteractor(applicationContext, { - trialSessionId, - }); + await setNoticesForCalendaredTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + mockPetitionsClerkUser, + ); const result = applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -189,7 +202,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { hasPaper: false, trialNoticePdfsKeys: [], }, - userId: user.userId, + userId: mockPetitionsClerkUser.userId, }); }); }); diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts index a5fe020750b..e5953bbc923 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts @@ -6,18 +6,18 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -export const setNoticesForCalendaredTrialSession = async ( +const setNoticesForCalendaredTrialSession = async ( applicationContext: ServerApplicationContext, { clientConnectionId, trialSessionId, }: { trialSessionId: string; clientConnectionId: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } @@ -40,7 +40,7 @@ export const setNoticesForCalendaredTrialSession = async ( trialNoticePdfsKeys, trialSessionId, }, - userId: user.userId, + userId: authorizedUser.userId, }); return; @@ -53,7 +53,7 @@ export const setNoticesForCalendaredTrialSession = async ( action: 'notice_generation_start', totalCases: calendaredCases.length, }, - userId: user.userId, + userId: authorizedUser.userId, }); const trialSession = await applicationContext @@ -114,7 +114,7 @@ export const setNoticesForCalendaredTrialSession = async ( docketNumber: calendaredCase.docketNumber, jobId, trialSession, - userId: user.userId, + userId: authorizedUser.userId, }, }); } @@ -160,7 +160,7 @@ export const setNoticesForCalendaredTrialSession = async ( trialNoticePdfsKeys, trialSessionId: trialSessionEntity.trialSessionId, }, - userId: user.userId, + userId: authorizedUser.userId, }); if (trialNoticePdfsKeys.length) { diff --git a/web-api/src/lambdas/trialSessions/setNoticesForCalendaredTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/setNoticesForCalendaredTrialSessionLambda.ts index 5e6056cdfa4..141d4f29952 100644 --- a/web-api/src/lambdas/trialSessions/setNoticesForCalendaredTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/setNoticesForCalendaredTrialSessionLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { setNoticesForCalendaredTrialSessionInteractor } from '@web-api/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor'; /** * used for generating / setting notices of trial on cases set for the given trial session @@ -6,14 +8,23 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const setNoticesForCalendaredTrialSessionLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { trialSessionId } = event.pathParameters || event.path || {}; +export const setNoticesForCalendaredTrialSessionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { trialSessionId } = event.pathParameters || event.path || {}; - return await applicationContext - .getUseCases() - .setNoticesForCalendaredTrialSessionInteractor(applicationContext, { - ...JSON.parse(event.body), - trialSessionId, - }); - }); + return await setNoticesForCalendaredTrialSessionInteractor( + applicationContext, + { + ...JSON.parse(event.body), + trialSessionId, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From dd69e0b3efe2dd81371805de9435baf82fc39a83 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 14:44:01 -0700 Subject: [PATCH 132/523] 10417: Remove getCurrentUser from web-api --- .../src/business/useCaseHelper/acquireLock.ts | 22 +++++++++++++--- ...aredTrialSessionInteractor.locking.test.ts | 26 +++++++++---------- ...icesForCalendaredTrialSessionInteractor.ts | 25 +++++++++--------- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/web-api/src/business/useCaseHelper/acquireLock.ts b/web-api/src/business/useCaseHelper/acquireLock.ts index d4e3ec26343..394a1fef98a 100644 --- a/web-api/src/business/useCaseHelper/acquireLock.ts +++ b/web-api/src/business/useCaseHelper/acquireLock.ts @@ -5,13 +5,15 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const checkLock = async ({ applicationContext, + authorizedUser, identifier, onLockError, options = {}, }: { + authorizedUser: UnknownAuthUser; applicationContext: ServerApplicationContext; identifier: string; - onLockError?: Error | Function; + onLockError?: TOnLockError; options?: any; }): Promise => { const featureFlags = await applicationContext @@ -43,7 +45,7 @@ export const checkLock = async ({ if (onLockError instanceof Error) { throw onLockError; } else if (typeof onLockError === 'function') { - await onLockError(applicationContext, options); + await onLockError(applicationContext, options, authorizedUser); } throw new ServiceUnavailableError( 'One of the items you are trying to update is being updated by someone else', @@ -52,6 +54,7 @@ export const checkLock = async ({ export const acquireLock = async ({ applicationContext, + authorizedUser, identifiers = [], onLockError, options = {}, @@ -61,11 +64,12 @@ export const acquireLock = async ({ }: { applicationContext: ServerApplicationContext; identifiers?: string[]; - onLockError?: Error | Function; + onLockError?: TOnLockError; options?: any; retries?: number; ttl?: number; waitTime?: number; + authorizedUser: UnknownAuthUser; }): Promise => { if (!identifiers) { return; @@ -81,6 +85,7 @@ export const acquireLock = async ({ identifiers.map(entityIdentifier => checkLock({ applicationContext, + authorizedUser, identifier: entityIdentifier, onLockError, options, @@ -140,7 +145,7 @@ export function withLocking( ) => | Promise<{ identifiers: string[]; ttl?: number }> | { identifiers: string[]; ttl?: number }, - onLockError?: Error | Function, + onLockError?: TOnLockError, ): ( applicationContext: any, options: InteractorInput, @@ -155,6 +160,7 @@ export function withLocking( await acquireLock({ applicationContext, + authorizedUser, identifiers, onLockError, options, @@ -180,3 +186,11 @@ export function withLocking( return results!; }; } + +export type TOnLockError = + | Error + | (( + applicationContext: any, + originalRequest: any, + authorizedUser: UnknownAuthUser, + ) => void); diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts index 3b084603677..b25d44a54ec 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts @@ -9,7 +9,7 @@ import { handleLockError, setNoticesForCalendaredTrialSessionInteractor, } from './setNoticesForCalendaredTrialSessionInteractor'; -import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('determineEntitiesToLock', () => { const trialSessionId = '6805d1ab-18d0-43ec-bafb-654e83405416'; @@ -53,20 +53,17 @@ describe('determineEntitiesToLock', () => { }); describe('handleLockError', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - }); - - it('should determine who the user is based on applicationContext', async () => { - await handleLockError(applicationContext, { foo: 'bar' }); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it('should send a notification to the user with "retry_async_request" and the originalRequest', async () => { const mockOriginalRequest = { foo: 'bar', }; - await handleLockError(applicationContext, mockOriginalRequest); + + await handleLockError( + applicationContext, + mockOriginalRequest, + mockDocketClerkUser, + ); + expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -97,7 +94,6 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => mockLock); - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); applicationContext .getPersistenceGateway() @@ -127,6 +123,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { setNoticesForCalendaredTrialSessionInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ), ).rejects.toThrow(ServiceUnavailableError); @@ -140,6 +137,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { setNoticesForCalendaredTrialSessionInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ), ).rejects.toThrow(ServiceUnavailableError); @@ -152,7 +150,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { originalRequest: mockRequest, requestToRetry: 'set_notices_for_calendared_trial_session', }, - userId: docketClerkUser.userId, + userId: mockDocketClerkUser.userId, }); expect( @@ -170,6 +168,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ); expect( @@ -185,6 +184,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ); const expectedIdentifiers = mockCases.map( diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts index e5953bbc923..13b7413f6ef 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts @@ -214,19 +214,20 @@ export const determineEntitiesToLock = async ( export const handleLockError = async ( applicationContext: ServerApplicationContext, originalRequest: any, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - clientConnectionId: originalRequest.clientConnectionId, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'set_notices_for_calendared_trial_session', - }, - userId: user.userId, - }); + if (authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + clientConnectionId: originalRequest.clientConnectionId, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'set_notices_for_calendared_trial_session', + }, + userId: authorizedUser.userId, + }); + } }; export const setNoticesForCalendaredTrialSessionInteractor = withLocking( From ea6dc6af055080f81a10596165c1ec3dc76fde10 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 14:47:04 -0700 Subject: [PATCH 133/523] 10417: docs --- web-api/src/genericHandler.ts | 2 +- web-api/src/middleware/apiGatewayHelper.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web-api/src/genericHandler.ts b/web-api/src/genericHandler.ts index d3fcfad9881..a1ed33853b5 100644 --- a/web-api/src/genericHandler.ts +++ b/web-api/src/genericHandler.ts @@ -71,7 +71,7 @@ export const genericHandler = ( } = {}, ) => { return handle(awsEvent, async () => { - const deprecatedUser = getUserFromAuthHeader(awsEvent); // TODO: zach remove getting user here. Should be passed in. + const deprecatedUser = getUserFromAuthHeader(awsEvent); // TODO 10417: remove getting user here. Should be passed in. const clientConnectionId = getConnectionIdFromEvent(awsEvent); const applicationContext = createApplicationContext( deprecatedUser, diff --git a/web-api/src/middleware/apiGatewayHelper.ts b/web-api/src/middleware/apiGatewayHelper.ts index 02dc2bdade6..1f4d518ff39 100644 --- a/web-api/src/middleware/apiGatewayHelper.ts +++ b/web-api/src/middleware/apiGatewayHelper.ts @@ -174,7 +174,7 @@ export const getUserFromAuthHeader = (event): UnknownAuthUser => { if (!token) return undefined; const decoded = jwt.decode(token); if (decoded) { - decoded.token = token; // TODO zach: Understand if the token is needed for the auth user. Ideally not. + decoded.token = token; // TODO 10417: Understand if the token is needed for the auth user. Ideally not. return { email: decoded.email, name: decoded.name || decoded['custom:name'], // custom:name only exists locally. This is a workaround for cognito-local. From 2bb1e1d4a7124ba8c927f267dc1b31cdccd88a04 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 5 Jul 2024 15:45:46 -0700 Subject: [PATCH 134/523] 10417: Update data security filter to pass in authorizedUser --- web-api/src/genericHandler.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/web-api/src/genericHandler.ts b/web-api/src/genericHandler.ts index a1ed33853b5..05707e547af 100644 --- a/web-api/src/genericHandler.ts +++ b/web-api/src/genericHandler.ts @@ -9,7 +9,16 @@ import { handle, } from './middleware/apiGatewayHelper'; -export const dataSecurityFilter = (data, { applicationContext }) => { +export const dataSecurityFilter = ( + data, + { + applicationContext, + authorizedUser, + }: { + applicationContext: ServerApplicationContext; + authorizedUser: UnknownAuthUser; + }, +) => { let returnData = data; if (data && Array.isArray(data) && data.length && data[0].entityName) { const entityConstructor = applicationContext.getEntityByName( @@ -20,6 +29,7 @@ export const dataSecurityFilter = (data, { applicationContext }) => { result => new entityConstructor(result, { applicationContext, + authorizedUser, filtered: true, }), ); @@ -31,6 +41,7 @@ export const dataSecurityFilter = (data, { applicationContext }) => { if (entityConstructor) { returnData = new entityConstructor(data, { applicationContext, + authorizedUser, filtered: true, }); } @@ -99,6 +110,7 @@ export const genericHandler = ( const returnResults = dataSecurityFilter(results, { applicationContext, + authorizedUser: user, }); if (options.logResults !== false) { From d0bf6c7113544f3efa754ba4a26fc1eb39dd66c7 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 8 Jul 2024 11:19:18 -0700 Subject: [PATCH 135/523] 10417: Update genericHandler tests --- .../test/createTestApplicationContext.ts | 3 + web-api/src/genericHandler.test.ts | 136 +++++++++--------- 2 files changed, 75 insertions(+), 64 deletions(-) diff --git a/shared/src/business/test/createTestApplicationContext.ts b/shared/src/business/test/createTestApplicationContext.ts index cde29797ebe..ee3c82c3a09 100644 --- a/shared/src/business/test/createTestApplicationContext.ts +++ b/shared/src/business/test/createTestApplicationContext.ts @@ -672,6 +672,9 @@ export const createTestApplicationContext = ({ getPdfJs: jest.fn().mockReturnValue(mockGetPdfJsReturnValue), getPdfLib: jest.fn().mockResolvedValue(pdfLib), getPersistenceGateway: mockGetPersistenceGateway, + getPersistencePrivateKeys: jest + .fn() + .mockReturnValue(['pk', 'sk', 'gsi1pk']), getPublicSiteUrl, getPug: jest.fn().mockReturnValue(pug), getReduceImageBlob: jest.fn().mockReturnValue(mockGetReduceImageBlobValue), diff --git a/web-api/src/genericHandler.test.ts b/web-api/src/genericHandler.test.ts index 0d295a8b23e..e7adb5ddbe6 100644 --- a/web-api/src/genericHandler.test.ts +++ b/web-api/src/genericHandler.test.ts @@ -1,9 +1,16 @@ -import { applicationContext } from '../../shared/src/business/test/createTestApplicationContext'; import { checkMaintenanceMode, dataSecurityFilter, genericHandler, } from './genericHandler'; +import { + mockAdcUser, + mockDocketClerkUser, + mockIrsPractitionerUser, + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; +import { applicationContext as mockApplicationContext } from '../../shared/src/business/test/createTestApplicationContext'; const token = 'eyJraWQiOiJ2U2pTa3FZVkJjVkJOWk5qZ1gzWFNzcERZSjU4QmQ3OGYrSzlDSXhtck44PSIsImFsZyI6IlJTMjU2In0.eyJhdF9oYXNoIjoic2dhcEEyWk1XcGxudnFaRHhGWUVzUSIsInN1YiI6ImE0NmFmZTYwLWFkM2EtNDdhZS1iZDQ5LTQzZDZkNjJhYTQ2OSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfN3VSa0YwQXhuIiwiY29nbml0bzp1c2VybmFtZSI6ImE0NmFmZTYwLWFkM2EtNDdhZS1iZDQ5LTQzZDZkNjJhYTQ2OSIsImF1ZCI6IjZ0dTZqMXN0djV1Z2N1dDdkcXNxZHVybjhxIiwiZXZlbnRfaWQiOiIzMGIwYjJiMi0zMDY0LTExZTktOTk0Yi03NTIwMGE2ZTQ3YTMiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTU1MDE1NDI0OCwibmFtZSI6IlRlc3QgUGV0aXRpb25lciIsImV4cCI6MTU1MDE1Nzg0OCwiY3VzdG9tOnJvbGUiOiJwZXRpdGlvbmVyIiwiaWF0IjoxNTUwMTU0MjQ4LCJlbWFpbCI6InBldGl0aW9uZXIxQGV4YW1wbGUuY29tIn0.KBEzAj84SV6Pulu9SEjGqbIPtL_iAeC-Tcc3fvphZ_nLHuIgN7LRv8pM-ClMM3Sua5YVQ7h70N1wRV0UZADxHiEDN5pYshcsjhZdnT9sWN9Nu5QT4l9e1zFsgu1S_p9M29i0__si674VT16hlXHCywrrqrofaJYZgMVXjvfEKYDmUo4XPCGN0GVFtt9sepxjAwd5rRIF9Ned3XGBQ2xrQd5qWlIMsvnhdlIL9FqvC47_ZsPh16IyREp7FDAEI5LxIkJOFE2Ryoe74cg_9nIaqP3rQsRrRMk7E_mQ9yGV4_2j4PEfoehm3wHbrGvhNFdDBDMosS3OfbUY411swAAh3Q'; @@ -14,13 +21,14 @@ const MOCK_EVENT = { }, }; -const MOCK_USER = { - name: 'Test User', - userId: '15adf875-8c3c-4e94-91e9-a4c1bff51291', -}; - let logged = []; +jest.mock('./applicationContext', () => ({ + createApplicationContext: () => { + return mockApplicationContext; + }, +})); + // Suppress console output in test runner (RAE SAID THIS WOULD BE COOL) console.error = () => null; console.info = () => null; @@ -45,10 +53,10 @@ describe('genericHandler', () => { beforeEach(() => { logged = []; - applicationContext.logger.debug.mockImplementation(label => { + mockApplicationContext.logger.debug.mockImplementation(label => { logged.push(label); }); - applicationContext.getEntityByName.mockImplementation(() => MockEntity); + mockApplicationContext.getEntityByName.mockImplementation(() => MockEntity); }); it('returns an error if the callback throws', async () => { @@ -56,23 +64,23 @@ describe('genericHandler', () => { return Promise.reject(new Error('Test Error')); }; - const response = await genericHandler(MOCK_EVENT, callback, { - applicationContext, - }); + const response = await genericHandler( + MOCK_EVENT, + callback, + mockDocketClerkUser, + ); expect(response.statusCode).toEqual('400'); expect(JSON.parse(response.body)).toEqual('Test Error'); - expect(applicationContext.logger.error).toHaveBeenCalled(); + expect(mockApplicationContext.logger.error).toHaveBeenCalled(); }); it('defaults the options param to an empty object if not provided', async () => { const callback = () => null; - await genericHandler({ ...MOCK_EVENT }, callback, { - applicationContext, - }); + await genericHandler({ ...MOCK_EVENT }, callback, mockDocketClerkUser); - expect(applicationContext.logger.error).not.toHaveBeenCalled(); + expect(mockApplicationContext.logger.error).not.toHaveBeenCalled(); }); it('does not call application.logger.error if the skipLogging flag is present on the error', async () => { @@ -82,36 +90,21 @@ describe('genericHandler', () => { throw error; }; - const response = await genericHandler({ ...MOCK_EVENT }, callback, { - applicationContext, - }); + const response = await genericHandler( + { ...MOCK_EVENT }, + callback, + mockPetitionsClerkUser, + ); expect(response.statusCode).toEqual('400'); expect(JSON.parse(response.body)).toEqual('Test Error'); - expect(applicationContext.logger.error).not.toHaveBeenCalled(); - }); - - it('can take a user override in the options param', async () => { - let setUser; - const callback = ({ user }) => { - setUser = user; - }; - - await genericHandler(MOCK_EVENT, callback, { - applicationContext, - user: MOCK_USER, - }); - - expect(setUser).toEqual(MOCK_USER); + expect(mockApplicationContext.logger.error).not.toHaveBeenCalled(); }); it('should log `request` and `results` by default', async () => { const callback = () => null; - await genericHandler(MOCK_EVENT, callback, { - applicationContext, - user: MOCK_USER, - }); + await genericHandler(MOCK_EVENT, callback, mockPetitionerUser); expect(logged).toContain('Request:'); expect(logged).toContain('Results:'); @@ -120,10 +113,8 @@ describe('genericHandler', () => { it('should not log `results` when disabled in options', async () => { const callback = () => null; - await genericHandler(MOCK_EVENT, callback, { - applicationContext, + await genericHandler(MOCK_EVENT, callback, mockAdcUser, { logResults: false, - user: MOCK_USER, }); expect(logged).toContain('Request:'); @@ -135,10 +126,11 @@ describe('genericHandler', () => { return Promise.resolve('some data'); }; - const result = await genericHandler(MOCK_EVENT, callback, { - applicationContext, - user: MOCK_USER, - }); + const result = await genericHandler( + MOCK_EVENT, + callback, + mockIrsPractitionerUser, + ); expect(JSON.parse(result.body)).toEqual('some data'); }); @@ -152,10 +144,11 @@ describe('genericHandler', () => { }); }; - const result = await genericHandler(MOCK_EVENT, callback, { - applicationContext, - user: MOCK_USER, - }); + const result = await genericHandler( + MOCK_EVENT, + callback, + mockIrsPractitionerUser, + ); expect(JSON.parse(result.body)).toEqual({ public: 'public data' }); }); @@ -166,7 +159,10 @@ describe('genericHandler', () => { private: 'private', public: 'public', }; - const result = dataSecurityFilter(data, { applicationContext }); + const result = dataSecurityFilter(data, { + applicationContext: mockApplicationContext, + authorizedUser: mockDocketClerkUser, + }); expect(result).toEqual(data); }); @@ -176,21 +172,27 @@ describe('genericHandler', () => { private: 'private', public: 'public', }; - const result = dataSecurityFilter(data, { applicationContext }); + const result = dataSecurityFilter(data, { + applicationContext: mockApplicationContext, + authorizedUser: mockIrsPractitionerUser, + }); expect(result).toEqual({ public: 'public', }); }); it('returns data without passing through entity constructor if entityName is not present in getEntityConstructors', () => { - applicationContext.getEntityByName.mockImplementation(() => null); + mockApplicationContext.getEntityByName.mockImplementation(() => null); const data = { entityName: 'MockEntity2', private: 'private', public: 'public', }; - const result = dataSecurityFilter(data, { applicationContext }); + const result = dataSecurityFilter(data, { + applicationContext: mockApplicationContext, + authorizedUser: mockAdcUser, + }); expect(result).toEqual({ entityName: 'MockEntity2', @@ -213,13 +215,16 @@ describe('genericHandler', () => { }, ]; - const result = dataSecurityFilter(data, { applicationContext }); + const result = dataSecurityFilter(data, { + applicationContext: mockApplicationContext, + authorizedUser: undefined, + }); expect(result).toEqual([{ public: 'public' }, { public: 'public' }]); }); it('returns array data without passing through entity constructor if entityName is present on array element but entity cannot be retrieved by name', () => { - applicationContext.getEntityByName.mockImplementation(() => null); + mockApplicationContext.getEntityByName.mockImplementation(() => null); const data = [ { entityName: 'MockEntity2', @@ -233,7 +238,10 @@ describe('genericHandler', () => { }, ]; - const result = dataSecurityFilter(data, { applicationContext }); + const result = dataSecurityFilter(data, { + applicationContext: mockApplicationContext, + authorizedUser: mockPetitionsClerkUser, + }); expect(result).toEqual([ { @@ -252,32 +260,32 @@ describe('genericHandler', () => { describe('checkMaintenanceMode', () => { it('should throw an error if maintenance mode is true', async () => { - applicationContext + mockApplicationContext .getPersistenceGateway() .getMaintenanceMode.mockReturnValue({ current: true }); await expect( - checkMaintenanceMode({ applicationContext }), + checkMaintenanceMode({ applicationContext: mockApplicationContext }), ).rejects.toThrow('Maintenance mode is enabled'); }); it('should not throw an error if maintenance mode is false', async () => { - applicationContext + mockApplicationContext .getPersistenceGateway() .getMaintenanceMode.mockReturnValue({ current: false }); - await expect(checkMaintenanceMode({ applicationContext })).resolves.toBe( - false, - ); + await expect( + checkMaintenanceMode({ applicationContext: mockApplicationContext }), + ).resolves.toBe(false); }); it('should NOT throw an error if maintenance mode is undefined', async () => { - applicationContext + mockApplicationContext .getPersistenceGateway() .getMaintenanceMode.mockReturnValue(undefined); await expect( - checkMaintenanceMode({ applicationContext }), + checkMaintenanceMode({ applicationContext: mockApplicationContext }), ).resolves.not.toThrow(); }); }); From 8b81c81378714cb1e8c852dc2ad6bbd7467bb7b9 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 8 Jul 2024 13:53:32 -0700 Subject: [PATCH 136/523] 10417: Refactored formattedWorkQueue to use authorizedUser --- shared/src/test/mockUsers.ts | 1 + ...formattedWorkQueue.filterWorkItems.test.ts | 17 +++--- ...dWorkQueue.getWorkItemDocumentLink.test.ts | 58 ++++++++++++------- .../computeds/formattedWorkQueue.test.ts | 7 +-- .../presenter/computeds/formattedWorkQueue.ts | 34 +++++++++-- 5 files changed, 78 insertions(+), 39 deletions(-) diff --git a/shared/src/test/mockUsers.ts b/shared/src/test/mockUsers.ts index 90490462bed..f6d46929add 100644 --- a/shared/src/test/mockUsers.ts +++ b/shared/src/test/mockUsers.ts @@ -135,6 +135,7 @@ export const trialClerkUser: RawUser = { }; export const caseServicesSupervisorUser = { + email: 'caseservicessupervisor@example.com', name: 'Test Case Services Supervisor', role: ROLES.caseServicesSupervisor, section: CASE_SERVICES_SUPERVISOR_SECTION, diff --git a/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts b/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts index bb4fb2e8962..6a082b8cff7 100644 --- a/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts +++ b/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts @@ -1,5 +1,6 @@ import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { filterWorkItems } from './formattedWorkQueue'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; const { DOCKET_SECTION, @@ -201,10 +202,10 @@ describe('filterWorkItems', () => { // PETITIONS CLERK it('Returns section work items for a Petitions Clerk in Section Document QC Inbox', () => { - applicationContext.getCurrentUser.mockReturnValueOnce(petitionsClerk1); - const filtered = filterWorkItems({ applicationContext, + authorizedUser: mockPetitionsClerkUser, + section: PETITIONS_SECTION, workItems: workQueueInbox, ...SECTION_DOCUMENT_QC_INBOX, } as any); @@ -229,9 +230,9 @@ describe('filterWorkItems', () => { }); it('Returns sent work items for a Petitions Clerk in Section Document QC Outbox', () => { - applicationContext.getCurrentUser.mockReturnValueOnce(petitionsClerk1); const filtered = filterWorkItems({ applicationContext, + authorizedUser: petitionsClerk1, workItems: workQueueOutbox, ...SECTION_DOCUMENT_QC_OUTBOX, } as any); @@ -261,9 +262,9 @@ describe('filterWorkItems', () => { // DOCKET CLERK it('Returns section work items for a Docket Clerk in Section Document QC Inbox', () => { - applicationContext.getCurrentUser.mockReturnValueOnce(docketClerk1); const filtered = filterWorkItems({ applicationContext, + authorizedUser: docketClerk1, workItems: workQueueInbox, ...SECTION_DOCUMENT_QC_INBOX, } as any); @@ -288,9 +289,9 @@ describe('filterWorkItems', () => { }); it('Returns docket section work items for an ADC in Document QC Inbox', () => { - applicationContext.getCurrentUser.mockReturnValueOnce(adc); const filtered = filterWorkItems({ applicationContext, + authorizedUser: adc, workItems: workQueueInbox, ...SECTION_DOCUMENT_QC_INBOX, } as any); @@ -302,9 +303,9 @@ describe('filterWorkItems', () => { }); it('Returns docket section work items for a Docket Clerk in My Document QC In Progress', () => { - applicationContext.getCurrentUser.mockReturnValueOnce(docketClerk1); const filtered = filterWorkItems({ applicationContext, + authorizedUser: docketClerk1, workItems: workQueueInProgress, ...MY_DOCUMENT_QC_IN_PROGRESS, } as any); @@ -313,9 +314,9 @@ describe('filterWorkItems', () => { }); it('Returns docket section work items for a Docket Clerk in Section Document QC In Progress', () => { - applicationContext.getCurrentUser.mockReturnValueOnce(docketClerk1); const filtered = filterWorkItems({ applicationContext, + authorizedUser: docketClerk1, workItems: workQueueInProgress, ...SECTION_DOCUMENT_QC_IN_PROGRESS, } as any); @@ -327,9 +328,9 @@ describe('filterWorkItems', () => { }); it('should getWorkQueueFilters with the section argument', () => { - applicationContext.getCurrentUser.mockReturnValueOnce(docketClerk1); filterWorkItems({ applicationContext, + authorizedUser: docketClerk1, section: DOCKET_SECTION, workItems: workQueueInProgress, ...SECTION_DOCUMENT_QC_IN_PROGRESS, diff --git a/web-client/src/presenter/computeds/formattedWorkQueue.getWorkItemDocumentLink.test.ts b/web-client/src/presenter/computeds/formattedWorkQueue.getWorkItemDocumentLink.test.ts index df412e40c2c..efd61de9b14 100644 --- a/web-client/src/presenter/computeds/formattedWorkQueue.getWorkItemDocumentLink.test.ts +++ b/web-client/src/presenter/computeds/formattedWorkQueue.getWorkItemDocumentLink.test.ts @@ -16,16 +16,10 @@ describe('getWorkItemDocumentLink', () => { STATUS_TYPES, } = applicationContext.getConstants(); - let globalUser; - - applicationContext.getCurrentUser = () => { - return globalUser; - }; - const getBaseState = user => { - globalUser = user; return { permissions: getUserPermissions(user), + user, }; }; @@ -65,10 +59,12 @@ describe('getWorkItemDocumentLink', () => { const documentViewLink = `/case-detail/${baseWorkItem.docketNumber}/document-view?docketEntryId=6db35185-2445-4952-9449-5479a5cadab0`; it('should return editLink as petition qc page if document is petition, case is not in progress, and user is petitionsclerk viewing a QC box', () => { - const { permissions } = getBaseState(petitionsClerkUser); + const { permissions, user: authorizedUser } = + getBaseState(petitionsClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -92,10 +88,11 @@ describe('getWorkItemDocumentLink', () => { }); it('should return /edit-court-issued if document is court-issued and not served and user is docketclerk', () => { - const { permissions } = getBaseState(docketClerkUser); + const { permissions, user: authorizedUser } = getBaseState(docketClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -119,10 +116,12 @@ describe('getWorkItemDocumentLink', () => { }); it('should return editLink as default document detail page if document is court-issued and not served and user is petitionsclerk viewing a QC box', () => { - const { permissions } = getBaseState(petitionsClerkUser); + const { permissions, user: authorizedUser } = + getBaseState(petitionsClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -145,10 +144,11 @@ describe('getWorkItemDocumentLink', () => { }); it('should return /complete if work item is in progress and user is docketclerk', () => { - const { permissions } = getBaseState(docketClerkUser); + const { permissions, user: authorizedUser } = getBaseState(docketClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -177,10 +177,11 @@ describe('getWorkItemDocumentLink', () => { }); it('should return /complete when the eventCode MISC and the isPaper is false', () => { - const { permissions } = getBaseState(docketClerkUser); + const { permissions, user: authorizedUser } = getBaseState(docketClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -202,10 +203,11 @@ describe('getWorkItemDocumentLink', () => { }); it('should return case detail link if document is processed and user is docketclerk', () => { - const { permissions } = getBaseState(docketClerkUser); + const { permissions, user: authorizedUser } = getBaseState(docketClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -237,10 +239,11 @@ describe('getWorkItemDocumentLink', () => { }); it('should return docket entry edit link if document is in progress and user is docketclerk', () => { - const { permissions } = getBaseState(docketClerkUser); + const { permissions, user: authorizedUser } = getBaseState(docketClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -272,10 +275,11 @@ describe('getWorkItemDocumentLink', () => { it('should return default document view link when the document has been processed, is unservable, and the user is docketClerk', () => { const { UNSERVABLE_EVENT_CODES } = applicationContext.getConstants(); - const { permissions } = getBaseState(docketClerkUser); + const { permissions, user: authorizedUser } = getBaseState(docketClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -304,10 +308,12 @@ describe('getWorkItemDocumentLink', () => { }); it('should return default document view link if document is in progress and user is petitionsClerk', () => { - const { permissions } = getBaseState(petitionsClerkUser); + const { permissions, user: authorizedUser } = + getBaseState(petitionsClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -333,10 +339,11 @@ describe('getWorkItemDocumentLink', () => { }); it("should return /edit if document is an external doc that has not been qc'd and user is docketclerk", () => { - const { permissions } = getBaseState(docketClerkUser); + const { permissions, user: authorizedUser } = getBaseState(docketClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -362,10 +369,11 @@ describe('getWorkItemDocumentLink', () => { }); it('should return editLink as /edit if the box is my inbox and user is docketClerk', () => { - const { permissions } = getBaseState(docketClerkUser); + const { permissions, user: authorizedUser } = getBaseState(docketClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -388,10 +396,12 @@ describe('getWorkItemDocumentLink', () => { }); it('should return editLink as /review if the box is my inProgress and user is petitionsClerk', () => { - const { permissions } = getBaseState(petitionsClerkUser); + const { permissions, user: authorizedUser } = + getBaseState(petitionsClerkUser); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -418,10 +428,13 @@ describe('getWorkItemDocumentLink', () => { }); it('should return editLink as /review if the box is my inProgress and user is caseServicesSupervisor', () => { - const { permissions } = getBaseState(caseServicesSupervisorUser); + const { permissions, user: authorizedUser } = getBaseState( + caseServicesSupervisorUser, + ); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, @@ -448,10 +461,13 @@ describe('getWorkItemDocumentLink', () => { }); it('should return editLink as petition qc page if document is petition, case is not in progress, and user is caseServicesSupervisor viewing a QC box', () => { - const { permissions } = getBaseState(caseServicesSupervisorUser); + const { permissions, user: authorizedUser } = getBaseState( + caseServicesSupervisorUser, + ); const result = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem: { ...baseWorkItem, diff --git a/web-client/src/presenter/computeds/formattedWorkQueue.test.ts b/web-client/src/presenter/computeds/formattedWorkQueue.test.ts index 839513aac31..63798539202 100644 --- a/web-client/src/presenter/computeds/formattedWorkQueue.test.ts +++ b/web-client/src/presenter/computeds/formattedWorkQueue.test.ts @@ -18,18 +18,13 @@ describe('formattedWorkQueue', () => { TRIAL_SESSION_SCOPE_TYPES, } = applicationContext.getConstants(); - let globalUser; let screenMetadata = {}; - applicationContext.getCurrentUser = () => { - return globalUser; - }; - const getBaseState = user => { - globalUser = user; return { permissions: getUserPermissions(user), screenMetadata, + user, users: [docketClerkUser, validUser], }; }; diff --git a/web-client/src/presenter/computeds/formattedWorkQueue.ts b/web-client/src/presenter/computeds/formattedWorkQueue.ts index 8fd5fcf8eec..f8a5817ccd5 100644 --- a/web-client/src/presenter/computeds/formattedWorkQueue.ts +++ b/web-client/src/presenter/computeds/formattedWorkQueue.ts @@ -2,6 +2,7 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; import { DocketEntry } from '../../../../shared/src/business/entities/DocketEntry'; import { Get } from 'cerebral'; import { RawWorkItem } from '@shared/business/entities/WorkItem'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { capitalize, cloneDeep, map, memoize, orderBy } from 'lodash'; import { state } from '@web-client/presenter/app.cerebral'; @@ -249,9 +250,16 @@ const getDocketEntryEditLink = ({ export const getWorkItemDocumentLink = ({ applicationContext, + authorizedUser, permissions, workItem, workQueueToDisplay, +}: { + applicationContext: any; + permissions: any; + workItem: any; + workQueueToDisplay: any; + authorizedUser: UnknownAuthUser; }) => { const result = cloneDeep(workItem); @@ -284,8 +292,7 @@ export const getWorkItemDocumentLink = ({ if (showDocumentEditLink) { if ( permissions.DOCKET_ENTRY && - (applicationContext.getCurrentUser().role !== - USER_ROLES.caseServicesSupervisor || + (authorizedUser?.role !== USER_ROLES.caseServicesSupervisor || !formattedDocketEntry.isPetition) ) { const editLinkExtension = getDocketEntryEditLink({ @@ -317,16 +324,23 @@ export const getWorkItemDocumentLink = ({ export const filterWorkItems = ({ applicationContext, assignmentFilterValue, + authorizedUser, section, workItems, workQueueToDisplay, +}: { + applicationContext: ClientApplicationContext; + assignmentFilterValue: any; + section: any; + workItems: any; + workQueueToDisplay: any; + authorizedUser: UnknownAuthUser; }) => { - const user = applicationContext.getCurrentUser(); const { box, queue } = workQueueToDisplay; const filters = applicationContext .getUtilities() - .getWorkQueueFilters({ section, user }); + .getWorkQueueFilters({ section, user: authorizedUser }); const composedFilter = filters[queue][box]; let assignmentFilter = workItem => { @@ -358,10 +372,18 @@ export const filterWorkItems = ({ const memoizedFormatItemWithLink = memoize( ({ applicationContext, + authorizedUser, isSelected, permissions, workItem, workQueueToDisplay, + }: { + applicationContext: any; + isSelected: any; + permissions: any; + workItem: any; + workQueueToDisplay: any; + authorizedUser: UnknownAuthUser; }) => { const result = formatWorkItem({ applicationContext, @@ -370,6 +392,7 @@ const memoizedFormatItemWithLink = memoize( }); const editLink = getWorkItemDocumentLink({ applicationContext, + authorizedUser, permissions, workItem, workQueueToDisplay, @@ -393,6 +416,7 @@ export const formattedWorkQueue = ( let { assignmentFilterValue } = get(state.screenMetadata); let { STATUS_TYPES } = applicationContext.getConstants(); const users = get(state.users); + const authorizedUser = get(state.user); if (assignmentFilterValue && assignmentFilterValue.userId !== 'UA') { assignmentFilterValue = users.find( @@ -403,12 +427,14 @@ export const formattedWorkQueue = ( let workQueue = filterWorkItems({ applicationContext, assignmentFilterValue, + authorizedUser, section, workItems, workQueueToDisplay, }).map(workItem => { return memoizedFormatItemWithLink({ applicationContext, + authorizedUser, isSelected: selectedWorkItemIds.includes(workItem.workItemId), permissions, workItem, From 86b5aa0be997fa1f782d833affd0b5f0b3b6eb41 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 8 Jul 2024 14:21:41 -0700 Subject: [PATCH 137/523] 10417: update imports --- web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts | 2 +- .../lambdas/documents/generatePrintableFilingReceiptLambda.ts | 2 +- web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts | 2 +- web-api/src/lambdas/documents/getUploadPolicyLambda.ts | 2 +- web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts | 2 +- web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts b/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts index bba071d44ef..0d2558d13c4 100644 --- a/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts +++ b/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts @@ -1,6 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -import { getDownloadPolicyUrlInteractor } from '@shared/business/useCases/getDownloadPolicyUrlInteractor'; +import { getDownloadPolicyUrlInteractor } from '@web-api/business/useCases/document/getDownloadPolicyUrlInteractor'; /** * used for getting the download policy which is needed for users to download files directly from S3 via the UI diff --git a/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts b/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts index ce55e7e7624..1d99e408427 100644 --- a/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts +++ b/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts @@ -1,5 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { generatePrintableFilingReceiptInteractor } from '@shared/business/useCases/generatePrintableFilingReceiptInteractor'; +import { generatePrintableFilingReceiptInteractor } from '@web-api/business/useCases/docketEntry/generatePrintableFilingReceiptInteractor'; import { genericHandler } from '../../genericHandler'; /** diff --git a/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts index 41ef405473f..e5da4dcc95c 100644 --- a/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts @@ -1,6 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -import { getDownloadPolicyUrlInteractor } from '@shared/business/useCases/getDownloadPolicyUrlInteractor'; +import { getDownloadPolicyUrlInteractor } from '@web-api/business/useCases/document/getDownloadPolicyUrlInteractor'; /** * TODO: clone of downloadPolicyUrlLambda? diff --git a/web-api/src/lambdas/documents/getUploadPolicyLambda.ts b/web-api/src/lambdas/documents/getUploadPolicyLambda.ts index 1ba60acb3f0..9865f8b78d5 100644 --- a/web-api/src/lambdas/documents/getUploadPolicyLambda.ts +++ b/web-api/src/lambdas/documents/getUploadPolicyLambda.ts @@ -1,6 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -import { getUploadPolicyInteractor } from '@shared/business/useCases/getUploadPolicyInteractor'; +import { getUploadPolicyInteractor } from '@web-api/business/useCases/document/getUploadPolicyInteractor'; /** * used for getting the upload policy which is needed for users to upload directly to S3 via the UI diff --git a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts index 626aac8eedd..14296395b2c 100644 --- a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts @@ -1,6 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -import { getDownloadPolicyUrlInteractor } from '@shared/business/useCases/getDownloadPolicyUrlInteractor'; +import { getDownloadPolicyUrlInteractor } from '@web-api/business/useCases/document/getDownloadPolicyUrlInteractor'; import { marshallDocumentDownloadUrl } from './marshallers/marshallDocumentDownloadUrl'; import { v1ApiWrapper } from './v1ApiWrapper'; diff --git a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts index 61aefccad12..7cef537b032 100644 --- a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts @@ -1,6 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -import { getDownloadPolicyUrlInteractor } from '@shared/business/useCases/getDownloadPolicyUrlInteractor'; +import { getDownloadPolicyUrlInteractor } from '@web-api/business/useCases/document/getDownloadPolicyUrlInteractor'; import { marshallDocumentDownloadUrl } from './marshallers/marshallDocumentDownloadUrl'; import { v2ApiWrapper } from './v2ApiWrapper'; From bf82072baaa7f3c0ad6ff66289aa219c0901bdde Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 8 Jul 2024 14:47:01 -0700 Subject: [PATCH 138/523] 10417: remove comment --- web-api/src/middleware/apiGatewayHelper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-api/src/middleware/apiGatewayHelper.ts b/web-api/src/middleware/apiGatewayHelper.ts index 1f4d518ff39..2846a856f12 100644 --- a/web-api/src/middleware/apiGatewayHelper.ts +++ b/web-api/src/middleware/apiGatewayHelper.ts @@ -174,7 +174,7 @@ export const getUserFromAuthHeader = (event): UnknownAuthUser => { if (!token) return undefined; const decoded = jwt.decode(token); if (decoded) { - decoded.token = token; // TODO 10417: Understand if the token is needed for the auth user. Ideally not. + decoded.token = token; return { email: decoded.email, name: decoded.name || decoded['custom:name'], // custom:name only exists locally. This is a workaround for cognito-local. From fbe56edc40198cc37be226b8d049bb376b360b78 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 8 Jul 2024 14:54:11 -0700 Subject: [PATCH 139/523] 10417: migrate away from applicationContext.getCurrentUser --- .../useCases/addCoversheetInteractor.test.ts | 157 +++++++++++------- .../useCases/addCoversheetInteractor.ts | 6 +- .../completeDocketEntryQCInteractor.ts | 10 +- .../updateDocketEntryMetaInteractor.ts | 24 +-- .../serveExternallyFiledDocumentInteractor.ts | 10 +- .../completeDocketEntryQCInteractor.ts | 10 +- .../serveCaseToIrsInteractor.ts | 45 +++-- .../lambdas/documents/addCoversheetLambda.ts | 13 +- 8 files changed, 172 insertions(+), 103 deletions(-) diff --git a/web-api/src/business/useCases/addCoversheetInteractor.test.ts b/web-api/src/business/useCases/addCoversheetInteractor.test.ts index 4f7913630e2..3fda5159c69 100644 --- a/web-api/src/business/useCases/addCoversheetInteractor.test.ts +++ b/web-api/src/business/useCases/addCoversheetInteractor.test.ts @@ -80,10 +80,14 @@ describe('addCoversheetInteractor', () => { }); it('adds a cover page to a pdf document', async () => { - await addCoversheetInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - } as any); + await addCoversheetInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getDocumentGenerators().coverSheet, @@ -94,11 +98,15 @@ describe('addCoversheetInteractor', () => { }); it('replaces the cover page on a document', async () => { - await addCoversheetInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - replaceCoversheet: true, - } as any); + await addCoversheetInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + replaceCoversheet: true, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getDocumentGenerators().coverSheet, @@ -109,10 +117,14 @@ describe('addCoversheetInteractor', () => { }); it("updates the docket entry's page numbers", async () => { - await addCoversheetInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - } as any); + await addCoversheetInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateDocketEntry, @@ -124,10 +136,14 @@ describe('addCoversheetInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(optionalTestingCaseData); - await addCoversheetInteractor(applicationContext, { - docketEntryId: 'b6b81f4d-1e47-423a-8caf-6d2fdc3d3858', - docketNumber: MOCK_CASE.docketNumber, - } as any); + await addCoversheetInteractor( + applicationContext, + { + docketEntryId: 'b6b81f4d-1e47-423a-8caf-6d2fdc3d3858', + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda, @@ -141,6 +157,7 @@ describe('addCoversheetInteractor', () => { docketEntryId: mockDocketEntryId, docketNumber: MOCK_CASE.docketNumber, } as any, + mockDocketClerkUser, ); expect(updatedDocketEntryEntity).toMatchObject({ @@ -150,10 +167,14 @@ describe('addCoversheetInteractor', () => { }); it('should call getCaseByDocketNumber to retrieve case entity if it is not passed in', async () => { - await addCoversheetInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - } as any); + await addCoversheetInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber.mock @@ -162,13 +183,17 @@ describe('addCoversheetInteractor', () => { }); it('should not call getCaseByDocketNumber if case entity is passed in', async () => { - await addCoversheetInteractor(applicationContext, { - caseEntity: new Case(testingCaseData, { - authorizedUser: mockDocketClerkUser, - }), - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - } as any); + await addCoversheetInteractor( + applicationContext, + { + caseEntity: new Case(testingCaseData, { + authorizedUser: mockDocketClerkUser, + }), + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -206,10 +231,14 @@ describe('addCoversheetInteractor', () => { docketNumber: '103-20', }); - await addCoversheetInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - } as any); + await addCoversheetInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateDocketEntry, @@ -243,10 +272,14 @@ describe('addCoversheetInteractor', () => { pdfData: 'gg', }); - await addCoversheetInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - } as any); + await addCoversheetInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateDocketEntry, @@ -297,17 +330,21 @@ describe('addCoversheetInteractor', () => { docketNumber: mockConsolidatedCaseNonSubjectCase, }); - await addCoversheetInteractor(applicationContext, { - caseEntity: new Case( - { - ...testingCaseData, - eventCode: SIMULTANEOUS_DOCUMENT_EVENT_CODES[0], - }, - { authorizedUser: mockDocketClerkUser }, - ), - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - } as any); + await addCoversheetInteractor( + applicationContext, + { + caseEntity: new Case( + { + ...testingCaseData, + eventCode: SIMULTANEOUS_DOCUMENT_EVENT_CODES[0], + }, + { authorizedUser: mockDocketClerkUser }, + ), + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockDocketClerkUser, + ); const calls = applicationContext .getPersistenceGateway() @@ -354,17 +391,21 @@ describe('addCoversheetInteractor', () => { docketNumber: mockConsolidatedCaseNonSubjectCase, }); - await addCoversheetInteractor(applicationContext, { - caseEntity: new Case( - { - ...testingCaseData, - documentTitle: 'Super Duper Simultaneous but not really', - }, - { authorizedUser: mockDocketClerkUser }, - ), - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - } as any); + await addCoversheetInteractor( + applicationContext, + { + caseEntity: new Case( + { + ...testingCaseData, + documentTitle: 'Super Duper Simultaneous but not really', + }, + { authorizedUser: mockDocketClerkUser }, + ), + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockDocketClerkUser, + ); const calls = applicationContext .getPersistenceGateway() diff --git a/web-api/src/business/useCases/addCoversheetInteractor.ts b/web-api/src/business/useCases/addCoversheetInteractor.ts index 2a5ec681e09..58b86533038 100644 --- a/web-api/src/business/useCases/addCoversheetInteractor.ts +++ b/web-api/src/business/useCases/addCoversheetInteractor.ts @@ -1,6 +1,7 @@ import { Case } from '../../../../shared/src/business/entities/cases/Case'; import { SIMULTANEOUS_DOCUMENT_EVENT_CODES } from '../../../../shared/src/business/entities/EntityConstants'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { addCoverToPdf } from './addCoverToPdf'; /** @@ -31,6 +32,7 @@ export const addCoversheetInteractor = async ( replaceCoversheet?: boolean; useInitialData?: boolean; }, + authorizedUser: UnknownAuthUser, ) => { if (!caseEntity) { const caseRecord = await applicationContext @@ -41,7 +43,7 @@ export const addCoversheetInteractor = async ( }); caseEntity = new Case(caseRecord, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); } @@ -94,7 +96,7 @@ export const addCoversheetInteractor = async ( docketNumber: caseDocketNumber, }); consolidatedCaseEntity = new Case(caseRecord, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); } diff --git a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts index 456f469c582..8ad1140fec9 100644 --- a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts @@ -340,12 +340,14 @@ const completeDocketEntryQC = async ( }); if (isNewCoverSheetNeeded) { - await applicationContext - .getUseCases() - .addCoversheetInteractor(applicationContext, { + await applicationContext.getUseCases().addCoversheetInteractor( + applicationContext, + { docketEntryId, docketNumber: caseEntity.docketNumber, - }); + }, + authorizedUser, + ); } return { diff --git a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts index 2dfa4e94c1f..48e453fdfac 100644 --- a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts @@ -29,9 +29,9 @@ export const updateDocketEntryMeta = async ( docketNumber, }: { docketEntryMeta: any; docketNumber: string }, ) => { - const user = applicationContext.getCurrentUser(); + const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(user, ROLE_PERMISSIONS.EDIT_DOCKET_ENTRY)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.EDIT_DOCKET_ENTRY)) { throw new UnauthorizedError('Unauthorized to update docket entry'); } @@ -46,7 +46,7 @@ export const updateDocketEntryMeta = async ( throw new NotFoundError(`Case ${docketNumber} was not found.`); } - let caseEntity = new Case(caseToUpdate, { authorizedUser: user }); + let caseEntity = new Case(caseToUpdate, { authorizedUser }); const originalDocketEntry: RawDocketEntry = caseEntity.getDocketEntryById({ docketEntryId: docketEntryMeta.docketEntryId, @@ -147,7 +147,7 @@ export const updateDocketEntryMeta = async ( ...originalDocketEntry, ...editableFields, }, - { authorizedUser: user, petitioners: caseEntity.petitioners }, + { authorizedUser, petitioners: caseEntity.petitioners }, ).validate(); caseEntity.updateDocketEntry(docketEntryEntity); @@ -166,11 +166,15 @@ export const updateDocketEntryMeta = async ( const updatedDocketEntry = await applicationContext .getUseCases() - .addCoversheetInteractor(applicationContext, { - docketEntryId: originalDocketEntry.docketEntryId, - docketNumber: caseEntity.docketNumber, - filingDateUpdated, - }); + .addCoversheetInteractor( + applicationContext, + { + docketEntryId: originalDocketEntry.docketEntryId, + docketNumber: caseEntity.docketNumber, + filingDateUpdated, + }, + authorizedUser, + ); caseEntity.updateDocketEntry(updatedDocketEntry); } else if (shouldRemoveExistingCoverSheet) { @@ -192,7 +196,7 @@ export const updateDocketEntryMeta = async ( caseToUpdate: caseEntity, }); - return new Case(result, { authorizedUser: user }).validate().toRawObject(); + return new Case(result, { authorizedUser }).validate().toRawObject(); }; export const shouldGenerateCoversheetForDocketEntry = ({ diff --git a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts index f8222c16422..7d63cce32aa 100644 --- a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts +++ b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts @@ -154,13 +154,15 @@ export const serveExternallyFiledDocument = async ( const updatedSubjectDocketEntry = updatedSubjectCaseEntity!.getDocketEntryById({ docketEntryId }); - await applicationContext - .getUseCases() - .addCoversheetInteractor(applicationContext, { + await applicationContext.getUseCases().addCoversheetInteractor( + applicationContext, + { caseEntity: updatedSubjectCaseEntity, docketEntryId: updatedSubjectDocketEntry.docketEntryId, docketNumber: updatedSubjectCaseEntity!.docketNumber, - }); + }, + authorizedUser, + ); paperServiceResult = await applicationContext .getUseCaseHelpers() diff --git a/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.ts b/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.ts index fbf6f6ef1c3..bc6c31a4ebe 100644 --- a/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.ts +++ b/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.ts @@ -340,12 +340,14 @@ const completeDocketEntryQC = async ( }); if (isNewCoverSheetNeeded) { - await applicationContext - .getUseCases() - .addCoversheetInteractor(applicationContext, { + await applicationContext.getUseCases().addCoversheetInteractor( + applicationContext, + { docketEntryId, docketNumber: caseEntity.docketNumber, - }); + }, + authorizedUser, + ); } return { diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts index d620acb1ee5..bdb908b20bf 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts @@ -1,4 +1,5 @@ /* eslint-disable complexity */ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; import { @@ -415,20 +416,29 @@ const shouldIncludeClinicLetter = ( const createCoversheetsForServedEntries = async ({ applicationContext, + authorizedUser, caseEntity, +}: { + applicationContext: ServerApplicationContext; + caseEntity: Case; + authorizedUser: AuthUser; }) => { return await Promise.all( caseEntity.docketEntries.map(async doc => { if (doc.isFileAttached && !doc.isDraft) { const updatedDocketEntry = await applicationContext .getUseCases() - .addCoversheetInteractor(applicationContext, { - caseEntity, - docketEntryId: doc.docketEntryId, - docketNumber: caseEntity.docketNumber, - replaceCoversheet: !caseEntity.isPaper, - useInitialData: !caseEntity.isPaper, - }); + .addCoversheetInteractor( + applicationContext, + { + caseEntity, + docketEntryId: doc.docketEntryId, + docketNumber: caseEntity.docketNumber, + replaceCoversheet: !caseEntity.isPaper, + useInitialData: !caseEntity.isPaper, + }, + authorizedUser, + ); caseEntity.updateDocketEntry(updatedDocketEntry); } @@ -473,9 +483,9 @@ export const serveCaseToIrs = async ( docketNumber, }: { clientConnectionId: string; docketNumber: string }, ): Promise => { - const user = applicationContext.getCurrentUser(); + const authorizedUser = applicationContext.getCurrentUser(); try { - if (!isAuthorized(user, ROLE_PERMISSIONS.SERVE_PETITION)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.SERVE_PETITION)) { throw new UnauthorizedError('Unauthorized'); } const caseToBatch = await applicationContext @@ -485,7 +495,7 @@ export const serveCaseToIrs = async ( docketNumber, }); - let caseEntity = new Case(caseToBatch, { authorizedUser: user }); + let caseEntity = new Case(caseToBatch, { authorizedUser }); caseEntity.markAsSentToIRS(); @@ -504,12 +514,12 @@ export const serveCaseToIrs = async ( addDocketEntryForPaymentStatus({ applicationContext, caseEntity, - user, + user: authorizedUser, }); caseEntity - .updateCaseCaptionDocketRecord({ authorizedUser: user }) - .updateDocketNumberRecord({ authorizedUser: user }) + .updateCaseCaptionDocketRecord({ authorizedUser }) + .updateDocketNumberRecord({ authorizedUser }) .validate(); const generatedDocuments: Promise[] = []; @@ -623,18 +633,19 @@ export const serveCaseToIrs = async ( await createPetitionWorkItems({ applicationContext, caseEntity, - user, + user: authorizedUser, }); await createCoversheetsForServedEntries({ applicationContext, + authorizedUser, caseEntity, }); const urlToReturn = await generateNoticeOfReceipt({ applicationContext, caseEntity, - userServingPetition: user, + userServingPetition: authorizedUser, }); await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ @@ -649,7 +660,7 @@ export const serveCaseToIrs = async ( action: 'serve_to_irs_complete', pdfUrl: urlToReturn, }, - userId: user.userId, + userId: authorizedUser.userId, }); } catch (err) { applicationContext.logger.error('Error serving case to IRS', { @@ -662,7 +673,7 @@ export const serveCaseToIrs = async ( message: { action: 'serve_to_irs_error', }, - userId: user.userId, + userId: authorizedUser.userId, }); } }; diff --git a/web-api/src/lambdas/documents/addCoversheetLambda.ts b/web-api/src/lambdas/documents/addCoversheetLambda.ts index 082a7ce9c0b..a98d28313de 100644 --- a/web-api/src/lambdas/documents/addCoversheetLambda.ts +++ b/web-api/src/lambdas/documents/addCoversheetLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { addCoversheetInteractor } from '@web-api/business/useCases/addCoversheetInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +8,16 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const addCoversheetLambda = event => +export const addCoversheetLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler( event, async ({ applicationContext }) => { - await applicationContext - .getUseCases() - .addCoversheetInteractor(applicationContext, event.pathParameters); + await addCoversheetInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); }, + authorizedUser, { logResults: false }, ); From 0f3eceffad154775234acaa616ef696131f1f9d3 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 8 Jul 2024 17:05:10 -0700 Subject: [PATCH 140/523] 10417: Locally make user get custom:name in their idToken so that cognito-local can work. --- ...createCsvCustomCaseReportFileInteractor.ts | 30 ++++++++------ .../batchDownloadTrialSessionInteractor.ts | 2 +- web-api/src/gateways/user/createUserLocal.ts | 41 +++++++++++++++++++ web-api/src/gateways/user/signUpLocal.ts | 39 ++++++++++++++++++ web-api/src/getUserGateway.ts | 7 +++- 5 files changed, 103 insertions(+), 16 deletions(-) create mode 100644 web-api/src/gateways/user/createUserLocal.ts create mode 100644 web-api/src/gateways/user/signUpLocal.ts diff --git a/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.ts b/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.ts index 92f6a4471b8..98a7d53ffab 100644 --- a/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.ts +++ b/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.ts @@ -71,19 +71,23 @@ export const createCsvCustomCaseReportFileInteractor = async ( const iterationData: GetCustomCaseReportResponse = await applicationContext .getUseCases() - .getCustomCaseReportInteractor(applicationContext, { - caseStatuses, - caseTypes, - endDate, - filingMethod, - highPriority, - judges, - pageSize, - preferredTrialCities, - procedureType, - searchAfter, - startDate, - }); + .getCustomCaseReportInteractor( + applicationContext, + { + caseStatuses, + caseTypes, + endDate, + filingMethod, + highPriority, + judges, + pageSize, + preferredTrialCities, + procedureType, + searchAfter, + startDate, + }, + authorizedUser, + ); cases.push(...iterationData.foundCases); searchAfter = iterationData.lastCaseId; diff --git a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts index 4bbe3216b0f..444dabe516c 100644 --- a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts @@ -178,7 +178,7 @@ const batchDownloadTrialSessionInteractorHelper = async ( filesCompleted: 0, totalFiles: documentsToZip.length, }, - userId: user.userId, + userId: authorizedUser.userId, }); const trialDate = formatDateString( diff --git a/web-api/src/gateways/user/createUserLocal.ts b/web-api/src/gateways/user/createUserLocal.ts new file mode 100644 index 00000000000..9e91213a78e --- /dev/null +++ b/web-api/src/gateways/user/createUserLocal.ts @@ -0,0 +1,41 @@ +import { Role } from '@shared/business/entities/EntityConstants'; +import { ServerApplicationContext } from '@web-api/applicationContext'; +import { createUser } from '@web-api/gateways/user/createUser'; + +export async function createUserLocal( + applicationContext: ServerApplicationContext, + { + email, + name, + poolId, + role, + sendWelcomeEmail, + temporaryPassword, + userId, + }: { + email: string; + role: Role; + name: string; + userId: string; + poolId?: string; + temporaryPassword?: string; + sendWelcomeEmail: boolean; + }, +): Promise { + await createUser(applicationContext, { + email, + name, + poolId, + role, + sendWelcomeEmail, + temporaryPassword, + userId, + }); + + // Locally we need to store the user name in custom:name because of cognito-local + await applicationContext.getCognito().adminUpdateUserAttributes({ + UserAttributes: [{ Name: 'custom:name', Value: name }], + UserPoolId: poolId ?? applicationContext.environment.userPoolId, + Username: email.toLowerCase(), + }); +} diff --git a/web-api/src/gateways/user/signUpLocal.ts b/web-api/src/gateways/user/signUpLocal.ts new file mode 100644 index 00000000000..41944c8e608 --- /dev/null +++ b/web-api/src/gateways/user/signUpLocal.ts @@ -0,0 +1,39 @@ +import { Role } from '@shared/business/entities/EntityConstants'; +import { ServerApplicationContext } from '@web-api/applicationContext'; +import { signUp } from '@web-api/gateways/user/signUp'; + +export async function signUpLocal( + applicationContext: ServerApplicationContext, + { + email, + name, + password, + role, + }: { + password: string; + email: string; + name: string; + role: Role; + }, +): Promise<{ userId: string }> { + const userId = await signUp(applicationContext, { + email, + name, + password, + role, + }); + + // Locally we must set the custom:name attribute for cognito-local + await applicationContext.getCognito().adminUpdateUserAttributes({ + UserAttributes: [ + { + Name: 'custom:name', + Value: name, + }, + ], + UserPoolId: applicationContext.environment.userPoolId, + Username: email.toLowerCase(), + }); + + return userId; +} diff --git a/web-api/src/getUserGateway.ts b/web-api/src/getUserGateway.ts index be10e62d245..0f4e50f9433 100644 --- a/web-api/src/getUserGateway.ts +++ b/web-api/src/getUserGateway.ts @@ -1,13 +1,16 @@ import { changePassword } from '@web-api/gateways/user/changePassword'; import { confirmSignUp } from '@web-api/gateways/user/confirmSignUp'; import { createUser } from '@web-api/gateways/user/createUser'; +import { createUserLocal } from '@web-api/gateways/user/createUserLocal'; import { disableUser } from '@web-api/gateways/user/disableUser'; +import { environment } from '@web-api/environment'; import { forgotPassword } from '@web-api/gateways/user/forgotPassword'; import { getUserByEmail } from '@web-api/gateways/user/getUserByEmail'; import { initiateAuth } from '@web-api/gateways/user/initiateAuth'; import { renewIdToken } from '@web-api/gateways/user/renewIdToken'; import { resendTemporaryPassword } from '@web-api/business/useCaseHelper/auth/resendTemporaryPassword'; import { signUp } from '@web-api/gateways/user/signUp'; +import { signUpLocal } from '@web-api/gateways/user/signUpLocal'; import { updateUser } from '@web-api/gateways/user/updateUser'; /* @@ -18,13 +21,13 @@ We need to lowercase the email address as we currently have a case SENSITIVE Use export const getUserGateway = () => ({ changePassword, confirmSignUp, - createUser, + createUser: environment.stage === 'local' ? createUserLocal : createUser, disableUser, forgotPassword, getUserByEmail, initiateAuth, renewIdToken, resendTemporaryPassword, - signUp, + signUp: environment.stage === 'local' ? signUpLocal : signUp, updateUser, }); From 7f2fe73a79e82bf94a63e529977cd9d5dac6ae8d Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 10 Jul 2024 15:59:28 -0700 Subject: [PATCH 141/523] 10417: migrate away from applicationContext.getCurrentUser --- shared/src/test/mockAuthUsers.ts | 7 + .../generateNoticeOfDocketChangePdf.test.ts | 16 +- .../generateNoticeOfDocketChangePdf.ts | 7 +- .../completeDocketEntryQCInteractor.test.ts | 373 ++++++---- .../completeDocketEntryQCInteractor.ts | 5 +- ...tryQCInteractor.needsNewCoversheet.test.ts | 80 --- .../completeDocketEntryQCInteractor.test.ts | 644 ------------------ .../completeDocketEntryQCInteractor.ts | 393 ----------- .../documents/completeDocketEntryQCLambda.ts | 20 +- 9 files changed, 257 insertions(+), 1288 deletions(-) delete mode 100644 web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.needsNewCoversheet.test.ts delete mode 100644 web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.test.ts delete mode 100644 web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.ts diff --git a/shared/src/test/mockAuthUsers.ts b/shared/src/test/mockAuthUsers.ts index 3627155f268..8941aa1894d 100644 --- a/shared/src/test/mockAuthUsers.ts +++ b/shared/src/test/mockAuthUsers.ts @@ -84,3 +84,10 @@ export const mockChambersUser: AuthUser = { role: ROLES.chambers, userId: 'e28c2f91-6925-48ac-8441-22b522b0c044', }; + +export const mockCaseServicesSupervisorUser: AuthUser = { + email: 'mockCaseServicesSupervisorUser@example.com', + name: 'Candy Case', + role: ROLES.caseServicesSupervisor, + userId: '97451b05-ae9c-46d5-9074-1ac6ef12cfc6', +}; diff --git a/web-api/src/business/useCaseHelper/noticeOfDocketChange/generateNoticeOfDocketChangePdf.test.ts b/web-api/src/business/useCaseHelper/noticeOfDocketChange/generateNoticeOfDocketChangePdf.test.ts index 5f6a7ce7ce4..f6abf5a878c 100644 --- a/web-api/src/business/useCaseHelper/noticeOfDocketChange/generateNoticeOfDocketChangePdf.test.ts +++ b/web-api/src/business/useCaseHelper/noticeOfDocketChange/generateNoticeOfDocketChangePdf.test.ts @@ -1,21 +1,18 @@ import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { - docketClerkUser, - irsSuperuserUser, -} from '../../../../../shared/src/test/mockUsers'; import { generateNoticeOfDocketChangePdf } from './generateNoticeOfDocketChangePdf'; +import { + mockDocketClerkUser, + mockIrsSuperuser, +} from '@shared/test/mockAuthUsers'; describe('generateNoticeOfDocketChangePdf', () => { - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - }); + beforeEach(() => {}); it('should throw an error when the user does not have permission to generate a notice of docket change', async () => { - applicationContext.getCurrentUser.mockReturnValue(irsSuperuserUser); // IRS Superuser does not have this permission - await expect( generateNoticeOfDocketChangePdf({ applicationContext, + authorizedUser: mockIrsSuperuser, docketChangeInfo: { caseCaptionExtension: 'Bert & Ernie, Petitioners v. Commissioner of Internal Revenue, Respondent', @@ -36,6 +33,7 @@ describe('generateNoticeOfDocketChangePdf', () => { const result = await generateNoticeOfDocketChangePdf({ applicationContext, + authorizedUser: mockDocketClerkUser, docketChangeInfo: { caseCaptionExtension: 'Bert & Ernie, Petitioners v. Commissioner of Internal Revenue, Respondent', diff --git a/web-api/src/business/useCaseHelper/noticeOfDocketChange/generateNoticeOfDocketChangePdf.ts b/web-api/src/business/useCaseHelper/noticeOfDocketChange/generateNoticeOfDocketChangePdf.ts index 61d42509ee0..7075722baa3 100644 --- a/web-api/src/business/useCaseHelper/noticeOfDocketChange/generateNoticeOfDocketChangePdf.ts +++ b/web-api/src/business/useCaseHelper/noticeOfDocketChange/generateNoticeOfDocketChangePdf.ts @@ -4,9 +4,11 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const generateNoticeOfDocketChangePdf = async ({ applicationContext, + authorizedUser, docketChangeInfo, }: { applicationContext: ServerApplicationContext; @@ -20,10 +22,9 @@ export const generateNoticeOfDocketChangePdf = async ({ filingParties: { after: string | undefined; before: string | undefined }; filingsAndProceedings: { after: string; before: string }; }; + authorizedUser: UnknownAuthUser; }): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.UPLOAD_DOCUMENT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPLOAD_DOCUMENT)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.test.ts b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.test.ts index c6709dedb54..f561a1ee72b 100644 --- a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.test.ts @@ -13,6 +13,11 @@ import { docketClerkUser, } from '../../../../../shared/src/test/mockUsers'; import { completeDocketEntryQCInteractor } from './completeDocketEntryQCInteractor'; +import { + mockCaseServicesSupervisorUser, + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('completeDocketEntryQCInteractor', () => { let caseRecord; @@ -72,8 +77,6 @@ describe('completeDocketEntryQCInteractor', () => { ], }; - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); @@ -104,26 +107,32 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should throw an error if not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - leadDocketNumber: caseRecord.docketNumber, + completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + leadDocketNumber: caseRecord.docketNumber, + }, }, - }), + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('adds documents and workitems', async () => { await expect( - completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - leadDocketNumber: caseRecord.docketNumber, + completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + leadDocketNumber: caseRecord.docketNumber, + }, }, - }), + mockDocketClerkUser, + ), ).resolves.not.toThrow(); expect( @@ -144,9 +153,13 @@ describe('completeDocketEntryQCInteractor', () => { }); it('serves the document for electronic-only parties if a notice of docket change is generated', async () => { - const result = await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: caseRecord.docketEntries[0], - }); + const result = await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: caseRecord.docketEntries[0], + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -163,15 +176,19 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should generate a notice of docket change with a new coversheet when additional info fields are added and addToCoversheet is true', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: '123', - additionalInfo2: 'abc', - certificateOfService: false, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + addToCoversheet: true, + additionalInfo: '123', + additionalInfo2: 'abc', + certificateOfService: false, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -186,15 +203,19 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should generate a notice of docket change with the name and title of the clerk of the court', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: '123', - additionalInfo2: 'abc', - certificateOfService: false, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + addToCoversheet: true, + additionalInfo: '123', + additionalInfo2: 'abc', + certificateOfService: false, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfDocketChange.mock @@ -206,15 +227,19 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should save the notice of docket change on the case', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: '123', - additionalInfo2: 'abc', - certificateOfService: false, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + addToCoversheet: true, + additionalInfo: '123', + additionalInfo2: 'abc', + certificateOfService: false, + }, }, - }); + mockDocketClerkUser, + ); const updatedCaseDocketEntries = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -231,13 +256,17 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should generate a notice of docket change without a new coversheet when the certificate of service date has been updated', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - certificateOfService: true, - certificateOfServiceDate: '2019-08-06T07:53:09.001Z', + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + certificateOfService: true, + certificateOfServiceDate: '2019-08-06T07:53:09.001Z', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -252,12 +281,16 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should generate a notice of docket change without a new coversheet when attachments has been updated', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - attachments: true, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + attachments: true, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -273,15 +306,19 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should generate a notice of docket change with a new coversheet when additional info fields are removed and addToCoversheet is true', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: undefined, - additionalInfo2: undefined, - certificateOfService: false, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + addToCoversheet: true, + additionalInfo: undefined, + additionalInfo2: undefined, + certificateOfService: false, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -296,16 +333,20 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should generate a notice of docket change with a new coversheet when documentTitle has changed and addToCoversheeet is false', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: false, - additionalInfo: undefined, - additionalInfo2: undefined, - certificateOfService: false, - documentTitle: 'Something Different', + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + addToCoversheet: false, + additionalInfo: undefined, + additionalInfo2: undefined, + certificateOfService: false, + documentTitle: 'Something Different', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -320,12 +361,16 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should not generate a new coversheet when the documentTitle has not changed and addToCoversheet is false', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: false, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + addToCoversheet: false, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -336,15 +381,19 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should generate a new coversheet when additionalInfo is changed and addToCoversheet is true', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: 'additional info', - additionalInfo2: 'additional info 221', - certificateOfService: false, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + addToCoversheet: true, + additionalInfo: 'additional info', + additionalInfo2: 'additional info 221', + certificateOfService: false, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -359,15 +408,19 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should generate a new coversheet when additionalInfo is NOT changed and addToCoversheet is true', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: 'additional info', - additionalInfo2: 'additional info', - certificateOfService: false, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + addToCoversheet: true, + additionalInfo: 'additional info', + additionalInfo2: 'additional info', + certificateOfService: false, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -403,13 +456,17 @@ describe('completeDocketEntryQCInteractor', () => { return mockNumberOfPages; }); - const result = await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - documentTitle: 'Something Else', - documentType: 'Memorandum in Support', + const result = await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + documentTitle: 'Something Else', + documentType: 'Memorandum in Support', + }, }, - }); + mockDocketClerkUser, + ); const noticeOfDocketChange = result.caseDetail.docketEntries.find( docketEntry => docketEntry.eventCode === 'NODC', @@ -454,13 +511,17 @@ describe('completeDocketEntryQCInteractor', () => { ], }); - const result = await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - documentTitle: 'Notice of Change of Address', - documentType: 'Notice of Change of Address', + const result = await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + documentTitle: 'Notice of Change of Address', + documentType: 'Notice of Change of Address', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -477,13 +538,17 @@ describe('completeDocketEntryQCInteractor', () => { }); it('does not generate a document for paper service if the document is a Notice of Change of Address and the case has no paper service parties', async () => { - const result = await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - documentTitle: 'Notice of Change of Address', - documentType: 'Notice of Change of Address', + const result = await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + documentTitle: 'Notice of Change of Address', + documentType: 'Notice of Change of Address', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -500,25 +565,29 @@ describe('completeDocketEntryQCInteractor', () => { }); it('should update only allowed editable fields on a docket entry document', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - documentTitle: 'My Edited Document', - documentType: 'Notice of Change of Address', - eventCode: 'NCA', - filedBy: 'Resp.', - filers: [mockPrimaryId], - freeText: 'Some text about this document', - hasOtherFilingParty: true, - isPaper: true, - otherFilingParty: 'Bert Brooks', - scenario: 'Nonstandard H', - secondaryDocument: { + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + documentTitle: 'My Edited Document', documentType: 'Notice of Change of Address', - eventCode: 'A', + eventCode: 'NCA', + filedBy: 'Resp.', + filers: [mockPrimaryId], + freeText: 'Some text about this document', + hasOtherFilingParty: true, + isPaper: true, + otherFilingParty: 'Bert Brooks', + scenario: 'Nonstandard H', + secondaryDocument: { + documentType: 'Notice of Change of Address', + eventCode: 'A', + }, }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -548,6 +617,7 @@ describe('completeDocketEntryQCInteractor', () => { pending: true, }, }, + mockDocketClerkUser, ); expect( @@ -569,6 +639,7 @@ describe('completeDocketEntryQCInteractor', () => { receivedAt: '2021-01-01', // date only }, }, + mockDocketClerkUser, ); expect(caseDetail.docketEntries[0].receivedAt).toEqual( @@ -577,20 +648,20 @@ describe('completeDocketEntryQCInteractor', () => { }); it('sets the assigned users section from the selected section when it is defined and the user is a case services user', async () => { - applicationContext.getCurrentUser.mockReturnValue( - caseServicesSupervisorUser, - ); - await applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(caseServicesSupervisorUser); - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - selectedSection: DOCKET_SECTION, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + selectedSection: DOCKET_SECTION, + }, }, - }); + mockCaseServicesSupervisorUser, + ); const assignedWorkItem = applicationContext.getPersistenceGateway() @@ -601,20 +672,20 @@ describe('completeDocketEntryQCInteractor', () => { }); it('sets the section as Case Services when selected section is NOT defined and the user is a case services user', async () => { - applicationContext.getCurrentUser.mockReturnValue( - caseServicesSupervisorUser, - ); - await applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(caseServicesSupervisorUser); - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - selectedSection: undefined, + await completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + selectedSection: undefined, + }, }, - }); + mockCaseServicesSupervisorUser, + ); const assignedWorkItem = applicationContext.getPersistenceGateway() @@ -625,19 +696,19 @@ describe('completeDocketEntryQCInteractor', () => { }); it('throws the expected error if the lock is already acquired by another process', async () => { - applicationContext.getCurrentUser.mockReturnValue( - caseServicesSupervisorUser, - ); - mockLock = MOCK_ACTIVE_LOCK; await expect(() => - completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - selectedSection: undefined, + completeDocketEntryQCInteractor( + applicationContext, + { + entryMetadata: { + ...caseRecord.docketEntries[0], + selectedSection: undefined, + }, }, - }), + mockCaseServicesSupervisorUser, + ), ).rejects.toThrow('The document is currently being updated'); }); }); diff --git a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts index 8ad1140fec9..54062ba920c 100644 --- a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts @@ -17,6 +17,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; import { addServedStampToDocument } from '@web-api/business/useCases/courtIssuedDocument/addServedStampToDocument'; import { aggregatePartiesForService } from '@shared/business/utilities/aggregatePartiesForService'; @@ -29,9 +30,8 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; const completeDocketEntryQC = async ( applicationContext: ServerApplicationContext, { entryMetadata }: { entryMetadata: any }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - const { PDFDocument } = await applicationContext.getPdfLib(); if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY)) { @@ -265,6 +265,7 @@ const completeDocketEntryQC = async ( } else if (needsNoticeOfDocketChange) { const noticeDocketEntryId = await generateNoticeOfDocketChangePdf({ applicationContext, + authorizedUser, docketChangeInfo, }); diff --git a/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.needsNewCoversheet.test.ts b/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.needsNewCoversheet.test.ts deleted file mode 100644 index f656e387889..00000000000 --- a/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.needsNewCoversheet.test.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; -import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { needsNewCoversheet } from './completeDocketEntryQCInteractor'; - -describe('completeDocketEntryQCInteractor needsNewCoversheet', () => { - let currentDocketEntry; - let updatedDocketEntry; - beforeEach(() => { - currentDocketEntry = new DocketEntry( - { - certificateOfService: false, - documentTitle: 'fake title', - filedBy: 'petitioner.high', - receivedAt: '2019-08-25T05:00:00.000Z', - }, - { applicationContext }, - ); - - updatedDocketEntry = new DocketEntry( - { - certificateOfService: false, - documentTitle: 'fake title', - filedBy: 'petitioner.high', - receivedAt: '2019-08-25T05:00:00.000Z', - }, - { applicationContext }, - ); - }); - it('should return true when receivedAt is updated', () => { - updatedDocketEntry.receivedAt = '2020-08-26T05:00:00.000Z'; - const result = needsNewCoversheet({ - applicationContext, - currentDocketEntry, - updatedDocketEntry, - }); - expect(result).toEqual(true); - }); - - it('should return false when receivedAt format is different but the date is the same', () => { - currentDocketEntry.receivedAt = '2019-08-25'; - updatedDocketEntry.receivedAt = '2019-08-25T05:00:00.000Z'; - const result = needsNewCoversheet({ - applicationContext, - currentDocketEntry, - updatedDocketEntry, - }); - - expect(result).toEqual(false); - }); - - it('should return true when certificateOfService is updated', () => { - updatedDocketEntry.certificateOfService = true; - const result = needsNewCoversheet({ - applicationContext, - currentDocketEntry, - updatedDocketEntry, - }); - expect(result).toEqual(true); - }); - - it('should return false when filedBy is updated', () => { - updatedDocketEntry.filedBy = 'petitioner.smith'; - const result = needsNewCoversheet({ - applicationContext, - currentDocketEntry, - updatedDocketEntry, - }); - expect(result).toEqual(false); - }); - - it('should return true when documentTitle is updated', () => { - updatedDocketEntry.documentTitle = 'fake title 2'; - const result = needsNewCoversheet({ - applicationContext, - currentDocketEntry, - updatedDocketEntry, - }); - expect(result).toEqual(true); - }); -}); diff --git a/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.test.ts b/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.test.ts deleted file mode 100644 index 8bbd20f389a..00000000000 --- a/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.test.ts +++ /dev/null @@ -1,644 +0,0 @@ -import { - CASE_SERVICES_SUPERVISOR_SECTION, - DOCKET_SECTION, - DOCUMENT_PROCESSING_STATUS_OPTIONS, - SERVICE_INDICATOR_TYPES, - SYSTEM_GENERATED_DOCUMENT_TYPES, -} from '../../../../../shared/src/business/entities/EntityConstants'; -import { MOCK_ACTIVE_LOCK } from '../../../../../shared/src/test/mockLock'; -import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; -import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { - caseServicesSupervisorUser, - docketClerkUser, -} from '../../../../../shared/src/test/mockUsers'; -import { completeDocketEntryQCInteractor } from './completeDocketEntryQCInteractor'; - -describe('completeDocketEntryQCInteractor', () => { - let caseRecord; - - const mockPrimaryId = MOCK_CASE.petitioners[0].contactId; - const mockDocketEntryId = MOCK_CASE.docketEntries[0].docketEntryId; - let mockLock; - - beforeAll(() => { - applicationContext - .getPersistenceGateway() - .getLock.mockImplementation(() => mockLock); - - applicationContext - .getPersistenceGateway() - .getConfigurationItemValue.mockImplementation(() => ({ - name: 'bob', - title: 'clerk of court', - })); - }); - - beforeEach(() => { - mockLock = undefined; - const workItem = { - docketEntry: { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - documentType: 'Answer', - eventCode: 'A', - }, - docketNumber: '45678-18', - section: DOCKET_SECTION, - sentBy: 'Test User', - sentByUserId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - updatedAt: applicationContext.getUtilities().createISODateString(), - workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - - caseRecord = { - ...MOCK_CASE, - docketEntries: [ - { - ...MOCK_CASE.docketEntries[0], - addToCoversheet: false, - additionalInfo: 'additional info', - additionalInfo2: 'additional info 2', - certificateOfService: true, - certificateOfServiceDate: '2019-08-25T05:00:00.000Z', - documentTitle: 'Answer', - documentType: 'Answer', - eventCode: 'A', - isOnDocketRecord: true, - receivedAt: '2019-08-25T05:00:00.000Z', - servedAt: '2019-08-25T05:00:00.000Z', - servedParties: [{ name: 'Bernard Lowe' }], - workItem, - }, - ], - }; - - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - - applicationContext - .getPersistenceGateway() - .getUserById.mockReturnValue(docketClerkUser); - - applicationContext - .getPersistenceGateway() - .getCaseByDocketNumber.mockReturnValue(caseRecord); - - applicationContext.getChromiumBrowser().newPage.mockReturnValue({ - addStyleTag: () => {}, - pdf: () => { - return 'Hello World'; - }, - setContent: () => {}, - }); - - applicationContext - .getPersistenceGateway() - .getDownloadPolicyUrl.mockReturnValue({ - url: 'www.example.com', - }); - - applicationContext - .getUseCaseHelpers() - .serveDocumentAndGetPaperServicePdf.mockReturnValue({ - pdfUrl: 'www.example.com', - }); - }); - - it('should throw an error if not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - - await expect( - completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - leadDocketNumber: caseRecord.docketNumber, - }, - }), - ).rejects.toThrow('Unauthorized'); - }); - - it('adds documents and workitems', async () => { - await expect( - completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - leadDocketNumber: caseRecord.docketNumber, - }, - }), - ).resolves.not.toThrow(); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway() - .saveWorkItemForDocketClerkFilingExternalDocument, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway() - .saveWorkItemForDocketClerkFilingExternalDocument.mock.calls[0][0] - .workItem, - ).toMatchObject({ leadDocketNumber: caseRecord.docketNumber }); - expect( - applicationContext.getPersistenceGateway().updateCase, - ).toHaveBeenCalled(); - }); - - it('serves the document for electronic-only parties if a notice of docket change is generated', async () => { - const result = await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: caseRecord.docketEntries[0], - }); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway() - .saveWorkItemForDocketClerkFilingExternalDocument, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase, - ).toHaveBeenCalled(); - expect(result.paperServicePdfUrl).toBeUndefined(); - expect(result.paperServiceParties.length).toEqual(0); - }); - - it('should generate a notice of docket change with a new coversheet when additional info fields are added and addToCoversheet is true', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: '123', - additionalInfo2: 'abc', - certificateOfService: false, - }, - }); - - expect( - applicationContext.getUseCases().addCoversheetInteractor, - ).toHaveBeenCalled(); - expect( - applicationContext.getDocumentGenerators().noticeOfDocketChange.mock - .calls[0][0].data.filingsAndProceedings, - ).toEqual({ - after: 'Answer 123 abc', - before: 'Answer additional info (C/S 08/25/19) additional info 2', - }); - }); - - it('should generate a notice of docket change with the name and title of the clerk of the court', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: '123', - additionalInfo2: 'abc', - certificateOfService: false, - }, - }); - - expect( - applicationContext.getDocumentGenerators().noticeOfDocketChange.mock - .calls[0][0].data, - ).toMatchObject({ - nameOfClerk: 'bob', - titleOfClerk: 'clerk of court', - }); - }); - - it('should save the notice of docket change on the case', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: '123', - additionalInfo2: 'abc', - certificateOfService: false, - }, - }); - - const updatedCaseDocketEntries = - applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock - .calls[0][0].caseToUpdate.docketEntries; - const noticeOfDocketChangeDocketEntry = updatedCaseDocketEntries.find( - d => - d.eventCode === - SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfDocketChange.eventCode, - ); - - expect(noticeOfDocketChangeDocketEntry.documentTitle).toEqual( - 'Notice of Docket Change for Docket Entry No. 1', - ); - }); - - it('should generate a notice of docket change without a new coversheet when the certificate of service date has been updated', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - certificateOfService: true, - certificateOfServiceDate: '2019-08-06T07:53:09.001Z', - }, - }); - - expect( - applicationContext.getUseCases().addCoversheetInteractor, - ).not.toHaveBeenCalled(); - expect( - applicationContext.getDocumentGenerators().noticeOfDocketChange.mock - .calls[0][0].data.filingsAndProceedings, - ).toEqual({ - after: 'Answer additional info (C/S 08/06/19) additional info 2', - before: 'Answer additional info (C/S 08/25/19) additional info 2', - }); - }); - - it('should generate a notice of docket change without a new coversheet when attachments has been updated', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - attachments: true, - }, - }); - - expect( - applicationContext.getUseCases().addCoversheetInteractor, - ).not.toHaveBeenCalled(); - expect( - applicationContext.getDocumentGenerators().noticeOfDocketChange.mock - .calls[0][0].data.filingsAndProceedings, - ).toEqual({ - after: - 'Answer additional info (C/S 08/25/19) (Attachment(s)) additional info 2', - before: 'Answer additional info (C/S 08/25/19) additional info 2', - }); - }); - - it('should generate a notice of docket change with a new coversheet when additional info fields are removed and addToCoversheet is true', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: undefined, - additionalInfo2: undefined, - certificateOfService: false, - }, - }); - - expect( - applicationContext.getUseCases().addCoversheetInteractor, - ).toHaveBeenCalled(); - expect( - applicationContext.getDocumentGenerators().noticeOfDocketChange.mock - .calls[0][0].data.filingsAndProceedings, - ).toEqual({ - after: 'Answer', - before: 'Answer additional info (C/S 08/25/19) additional info 2', - }); - }); - - it('should generate a notice of docket change with a new coversheet when documentTitle has changed and addToCoversheeet is false', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: false, - additionalInfo: undefined, - additionalInfo2: undefined, - certificateOfService: false, - documentTitle: 'Something Different', - }, - }); - - expect( - applicationContext.getUseCases().addCoversheetInteractor, - ).toHaveBeenCalled(); - expect( - applicationContext.getDocumentGenerators().noticeOfDocketChange.mock - .calls[0][0].data.filingsAndProceedings, - ).toEqual({ - after: 'Something Different', - before: 'Answer additional info (C/S 08/25/19) additional info 2', - }); - }); - - it('should not generate a new coversheet when the documentTitle has not changed and addToCoversheet is false', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: false, - }, - }); - - expect( - applicationContext.getUseCases().addCoversheetInteractor, - ).not.toHaveBeenCalled(); - expect( - applicationContext.getDocumentGenerators().noticeOfDocketChange, - ).not.toHaveBeenCalled(); - }); - - it('should generate a new coversheet when additionalInfo is changed and addToCoversheet is true', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: 'additional info', - additionalInfo2: 'additional info 221', - certificateOfService: false, - }, - }); - - expect( - applicationContext.getUseCases().addCoversheetInteractor, - ).toHaveBeenCalled(); - expect( - applicationContext.getDocumentGenerators().noticeOfDocketChange.mock - .calls[0][0].data.filingsAndProceedings, - ).toEqual({ - after: 'Answer additional info additional info 221', - before: 'Answer additional info (C/S 08/25/19) additional info 2', - }); - }); - - it('should generate a new coversheet when additionalInfo is NOT changed and addToCoversheet is true', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - addToCoversheet: true, - additionalInfo: 'additional info', - additionalInfo2: 'additional info', - certificateOfService: false, - }, - }); - - expect( - applicationContext.getUseCases().addCoversheetInteractor, - ).toHaveBeenCalled(); - expect( - applicationContext.getDocumentGenerators().noticeOfDocketChange.mock - .calls[0][0].data.filingsAndProceedings, - ).toEqual({ - after: 'Answer additional info additional info', - before: 'Answer additional info (C/S 08/25/19) additional info 2', - }); - }); - - it('serves the document for parties with paper service if a notice of docket change is generated', async () => { - applicationContext - .getPersistenceGateway() - .getCaseByDocketNumber.mockReturnValue({ - ...caseRecord, - isPaper: true, - mailingDate: '2019-03-01T21:40:46.415Z', - petitioners: [ - { - ...caseRecord.petitioners[0], - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, - }, - ], - }); - - const mockNumberOfPages = 999; - applicationContext - .getUseCaseHelpers() - .countPagesInDocument.mockImplementation(() => { - return mockNumberOfPages; - }); - - const result = await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - documentTitle: 'Something Else', - documentType: 'Memorandum in Support', - }, - }); - - const noticeOfDocketChange = result.caseDetail.docketEntries.find( - docketEntry => docketEntry.eventCode === 'NODC', - ); - - expect( - applicationContext.getUseCaseHelpers().countPagesInDocument, - ).toHaveBeenCalled(); - - expect(noticeOfDocketChange).toMatchObject({ - isFileAttached: true, - numberOfPages: 999, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, - }); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway() - .saveWorkItemForDocketClerkFilingExternalDocument, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase, - ).toHaveBeenCalled(); - expect(result.paperServicePdfUrl).toEqual('www.example.com'); - expect(result.paperServiceParties.length).toEqual(1); - }); - - it('generates a document for paper service if the document is a Notice of Change of Address and the case has paper service parties', async () => { - applicationContext - .getPersistenceGateway() - .getCaseByDocketNumber.mockReturnValue({ - ...caseRecord, - isPaper: true, - mailingDate: '2019-03-01T21:40:46.415Z', - petitioners: [ - { - ...caseRecord.petitioners[0], - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, - }, - ], - }); - - const result = await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - documentTitle: 'Notice of Change of Address', - documentType: 'Notice of Change of Address', - }, - }); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway() - .saveWorkItemForDocketClerkFilingExternalDocument, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase, - ).toHaveBeenCalled(); - expect(result.paperServicePdfUrl).toEqual('www.example.com'); - expect(result.paperServiceParties.length).toEqual(1); - }); - - it('does not generate a document for paper service if the document is a Notice of Change of Address and the case has no paper service parties', async () => { - const result = await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - documentTitle: 'Notice of Change of Address', - documentType: 'Notice of Change of Address', - }, - }); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway() - .saveWorkItemForDocketClerkFilingExternalDocument, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase, - ).toHaveBeenCalled(); - expect(result.paperServicePdfUrl).toEqual(undefined); - expect(result.paperServiceParties.length).toEqual(0); - }); - - it('should update only allowed editable fields on a docket entry document', async () => { - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - documentTitle: 'My Edited Document', - documentType: 'Notice of Change of Address', - eventCode: 'NCA', - filedBy: 'Resp.', - filers: [mockPrimaryId], - freeText: 'Some text about this document', - hasOtherFilingParty: true, - isPaper: true, - otherFilingParty: 'Bert Brooks', - scenario: 'Nonstandard H', - secondaryDocument: { - documentType: 'Notice of Change of Address', - eventCode: 'A', - }, - }, - }); - - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[0], - ).toMatchObject({ - documentTitle: 'My Edited Document', - documentType: 'Notice of Change of Address', - eventCode: 'NCA', - freeText: 'Some text about this document', - hasOtherFilingParty: true, - otherFilingParty: 'Bert Brooks', - secondaryDocument: { - documentType: 'Notice of Change of Address', - eventCode: 'A', - }, - }); - }); - - it('updates automaticBlocked on a case and all associated case trial sort mappings if pending is true', async () => { - expect(caseRecord.automaticBlocked).toBeFalsy(); - - const { caseDetail } = await completeDocketEntryQCInteractor( - applicationContext, - { - entryMetadata: { - ...caseRecord.docketEntries[0], - pending: true, - }, - }, - ); - - expect( - applicationContext.getUseCaseHelpers().updateCaseAutomaticBlock, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway() - .deleteCaseTrialSortMappingRecords, - ).toHaveBeenCalled(); - expect(caseDetail.automaticBlocked).toBeTruthy(); - }); - - it('normalizes receivedAt dates to ISO string format', async () => { - const { caseDetail } = await completeDocketEntryQCInteractor( - applicationContext, - { - entryMetadata: { - ...caseRecord.docketEntries[0], - receivedAt: '2021-01-01', // date only - }, - }, - ); - - expect(caseDetail.docketEntries[0].receivedAt).toEqual( - '2021-01-01T05:00:00.000Z', - ); - }); - - it('sets the assigned users section from the selected section when it is defined and the user is a case services user', async () => { - applicationContext.getCurrentUser.mockReturnValue( - caseServicesSupervisorUser, - ); - - await applicationContext - .getPersistenceGateway() - .getUserById.mockReturnValue(caseServicesSupervisorUser); - - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - selectedSection: DOCKET_SECTION, - }, - }); - - const assignedWorkItem = - applicationContext.getPersistenceGateway() - .saveWorkItemForDocketClerkFilingExternalDocument.mock.calls[0][0] - .workItem; - - expect(assignedWorkItem.section).toEqual(DOCKET_SECTION); - }); - - it('sets the section as Case Services when selected section is NOT defined and the user is a case services user', async () => { - applicationContext.getCurrentUser.mockReturnValue( - caseServicesSupervisorUser, - ); - - await applicationContext - .getPersistenceGateway() - .getUserById.mockReturnValue(caseServicesSupervisorUser); - - await completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - selectedSection: undefined, - }, - }); - - const assignedWorkItem = - applicationContext.getPersistenceGateway() - .saveWorkItemForDocketClerkFilingExternalDocument.mock.calls[0][0] - .workItem; - - expect(assignedWorkItem.section).toEqual(CASE_SERVICES_SUPERVISOR_SECTION); - }); - - it('throws the expected error if the lock is already acquired by another process', async () => { - applicationContext.getCurrentUser.mockReturnValue( - caseServicesSupervisorUser, - ); - - mockLock = MOCK_ACTIVE_LOCK; - - await expect(() => - completeDocketEntryQCInteractor(applicationContext, { - entryMetadata: { - ...caseRecord.docketEntries[0], - selectedSection: undefined, - }, - }), - ).rejects.toThrow('The document is currently being updated'); - }); -}); diff --git a/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.ts b/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.ts deleted file mode 100644 index bc6c31a4ebe..00000000000 --- a/web-api/src/business/useCases/editDocketEntry/completeDocketEntryQCInteractor.ts +++ /dev/null @@ -1,393 +0,0 @@ -import { - CONTACT_CHANGE_DOCUMENT_TYPES, - DOCUMENT_PROCESSING_STATUS_OPTIONS, - DOCUMENT_RELATIONSHIPS, - SYSTEM_GENERATED_DOCUMENT_TYPES, -} from '../../../../../shared/src/business/entities/EntityConstants'; -import { Case } from '../../../../../shared/src/business/entities/cases/Case'; -import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; -import { - FORMATS, - dateStringsCompared, - formatDateString, -} from '../../../../../shared/src/business/utilities/DateHandler'; -import { InvalidRequest, UnauthorizedError } from '@web-api/errors/errors'; -import { - ROLE_PERMISSIONS, - isAuthorized, -} from '../../../../../shared/src/authorization/authorizationClientService'; -import { ServerApplicationContext } from '@web-api/applicationContext'; -import { User } from '@shared/business/entities/User'; -import { addServedStampToDocument } from '@web-api/business/useCases/courtIssuedDocument/addServedStampToDocument'; -import { aggregatePartiesForService } from '@shared/business/utilities/aggregatePartiesForService'; -import { generateNoticeOfDocketChangePdf } from '@web-api/business/useCaseHelper/noticeOfDocketChange/generateNoticeOfDocketChangePdf'; -import { getCaseCaptionMeta } from '@shared/business/utilities/getCaseCaptionMeta'; -import { getDocumentTitleForNoticeOfChange } from '@shared/business/utilities/getDocumentTitleForNoticeOfChange'; -import { replaceBracketed } from '@shared/business/utilities/replaceBracketed'; -import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; - -const completeDocketEntryQC = async ( - applicationContext: ServerApplicationContext, - { entryMetadata }: { entryMetadata: any }, -) => { - const authorizedUser = applicationContext.getCurrentUser(); - - const { PDFDocument } = await applicationContext.getPdfLib(); - - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY)) { - throw new UnauthorizedError('Unauthorized'); - } - - const { - docketEntryId, - docketNumber, - leadDocketNumber, - overridePaperServiceAddress, - selectedSection, - } = entryMetadata; - - const user = await applicationContext - .getPersistenceGateway() - .getUserById({ applicationContext, userId: authorizedUser.userId }); - - const caseToUpdate = await applicationContext - .getPersistenceGateway() - .getCaseByDocketNumber({ - applicationContext, - docketNumber, - }); - - let caseEntity = new Case(caseToUpdate, { applicationContext }); - const { index: docketRecordIndexUpdated } = caseEntity.docketEntries.find( - record => record.docketEntryId === docketEntryId, - ); - - const currentDocketEntry = caseEntity.getDocketEntryById({ - docketEntryId, - }); - - if (currentDocketEntry.workItem.isCompleted()) { - throw new InvalidRequest('The work item was already completed'); - } - - const editableFields = { - addToCoversheet: entryMetadata.addToCoversheet, - additionalInfo: entryMetadata.additionalInfo, - additionalInfo2: entryMetadata.additionalInfo2, - attachments: entryMetadata.attachments, - certificateOfService: entryMetadata.certificateOfService, - certificateOfServiceDate: entryMetadata.certificateOfServiceDate, - documentTitle: entryMetadata.documentTitle, - documentType: entryMetadata.documentType, - eventCode: entryMetadata.eventCode, - filedBy: entryMetadata.filedBy, - filers: entryMetadata.filers, - freeText: entryMetadata.freeText, - freeText2: entryMetadata.freeText2, - hasOtherFilingParty: entryMetadata.hasOtherFilingParty, - isFileAttached: true, - lodged: entryMetadata.lodged, - mailingDate: entryMetadata.mailingDate, - objections: entryMetadata.objections, - ordinalValue: entryMetadata.ordinalValue, - otherFilingParty: entryMetadata.otherFilingParty, - otherIteration: entryMetadata.otherIteration, - partyIrsPractitioner: entryMetadata.partyIrsPractitioner, - pending: entryMetadata.pending, - receivedAt: entryMetadata.receivedAt, - scenario: entryMetadata.scenario, - secondaryDocument: entryMetadata.secondaryDocument, - serviceDate: entryMetadata.serviceDate, - }; - - const updatedDocketEntry = new DocketEntry( - { - ...currentDocketEntry, - ...editableFields, - documentTitle: editableFields.documentTitle, - editState: '{}', - relationship: DOCUMENT_RELATIONSHIPS.PRIMARY, - workItem: { - ...currentDocketEntry.workItem, - leadDocketNumber, - trialDate: caseEntity.trialDate, - trialLocation: caseEntity.trialLocation, - }, - }, - { applicationContext, petitioners: caseToUpdate.petitioners }, - ).validate(); - updatedDocketEntry.setQCed(user); - - let updatedDocumentTitle = getDocumentTitleForNoticeOfChange({ - applicationContext, - docketEntry: updatedDocketEntry, - }); - - let currentDocumentTitle = getDocumentTitleForNoticeOfChange({ - applicationContext, - docketEntry: currentDocketEntry, - }); - - const isNewCoverSheetNeeded = needsNewCoversheet({ - applicationContext, - currentDocketEntry, - updatedDocketEntry, - }); - - const needsNoticeOfDocketChange = - updatedDocketEntry.filedBy !== currentDocketEntry.filedBy || - updatedDocumentTitle !== currentDocumentTitle; - - const { caseCaptionExtension, caseTitle } = getCaseCaptionMeta(caseEntity); - - const { name, title } = await applicationContext - .getPersistenceGateway() - .getConfigurationItemValue({ - applicationContext, - configurationItemKey: - applicationContext.getConstants().CLERK_OF_THE_COURT_CONFIGURATION, - }); - - const docketChangeInfo = { - caseCaptionExtension, - caseTitle, - docketEntryIndex: docketRecordIndexUpdated, - docketNumber: `${caseToUpdate.docketNumber}${ - caseToUpdate.docketNumberSuffix || '' - }`, - filingParties: { - after: updatedDocketEntry.filedBy, - before: currentDocketEntry.filedBy, - }, - filingsAndProceedings: { - after: updatedDocumentTitle, - before: currentDocumentTitle, - }, - nameOfClerk: name, - titleOfClerk: title, - }; - - caseEntity.updateDocketEntry(updatedDocketEntry); - - caseEntity = await applicationContext - .getUseCaseHelpers() - .updateCaseAutomaticBlock({ applicationContext, caseEntity }); - - const workItemToUpdate = updatedDocketEntry.workItem; - - Object.assign(workItemToUpdate, { - docketEntry: { - ...updatedDocketEntry.toRawObject(), - createdAt: updatedDocketEntry.createdAt, - }, - }); - - workItemToUpdate.setAsCompleted({ - message: 'completed', - user, - }); - - const userIsCaseServices = User.isCaseServicesUser({ - section: user.section || '', - }); - - let sectionToAssignTo = - userIsCaseServices && selectedSection ? selectedSection : user.section; - - workItemToUpdate.assignToUser({ - assigneeId: user.userId, - assigneeName: user.name, - section: sectionToAssignTo, - sentBy: user.name, - sentBySection: user.section, - sentByUserId: user.userId, - }); - - await applicationContext - .getPersistenceGateway() - .saveWorkItemForDocketClerkFilingExternalDocument({ - applicationContext, - workItem: workItemToUpdate.validate().toRawObject(), - }); - - let servedParties = aggregatePartiesForService(caseEntity); - let paperServicePdfUrl; - let paperServiceDocumentTitle; - - if ( - overridePaperServiceAddress || - CONTACT_CHANGE_DOCUMENT_TYPES.includes(updatedDocketEntry.documentType) - ) { - if (servedParties.paper.length > 0) { - const pdfData = await applicationContext - .getPersistenceGateway() - .getDocument({ - applicationContext, - key: updatedDocketEntry.docketEntryId, - }); - - const noticeDoc = await PDFDocument.load(pdfData); - - let newPdfDoc = await PDFDocument.create(); - - await applicationContext - .getUseCaseHelpers() - .appendPaperServiceAddressPageToPdf({ - applicationContext, - caseEntity, - newPdfDoc, - noticeDoc, - servedParties, - }); - - const paperServicePdfData = await newPdfDoc.save(); - - const paperServicePdfId = applicationContext.getUniqueId(); - - await applicationContext.getPersistenceGateway().saveDocumentFromLambda({ - applicationContext, - document: paperServicePdfData, - key: paperServicePdfId, - useTempBucket: true, - }); - - const { url } = await applicationContext - .getPersistenceGateway() - .getDownloadPolicyUrl({ - applicationContext, - key: paperServicePdfId, - useTempBucket: true, - }); - - paperServicePdfUrl = url; - paperServiceDocumentTitle = updatedDocketEntry.documentTitle; - } - } else if (needsNoticeOfDocketChange) { - const noticeDocketEntryId = await generateNoticeOfDocketChangePdf({ - applicationContext, - docketChangeInfo, - }); - - let noticeUpdatedDocketEntry = new DocketEntry( - { - ...SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfDocketChange, - docketEntryId: noticeDocketEntryId, - documentTitle: replaceBracketed( - SYSTEM_GENERATED_DOCUMENT_TYPES.noticeOfDocketChange.documentTitle, - docketChangeInfo.docketEntryIndex, - ), - isFileAttached: true, - isOnDocketRecord: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, - }, - { applicationContext, petitioners: caseToUpdate.petitioners }, - ); - - noticeUpdatedDocketEntry.setFiledBy(user); - - noticeUpdatedDocketEntry.numberOfPages = await applicationContext - .getUseCaseHelpers() - .countPagesInDocument({ - applicationContext, - docketEntryId: noticeUpdatedDocketEntry.docketEntryId, - }); - - noticeUpdatedDocketEntry.setAsServed(servedParties.all); - - caseEntity.addDocketEntry(noticeUpdatedDocketEntry); - - const serviceStampDate = formatDateString( - noticeUpdatedDocketEntry.servedAt!, - FORMATS.MMDDYY, - ); - - const pdfData = await applicationContext - .getPersistenceGateway() - .getDocument({ - applicationContext, - key: noticeUpdatedDocketEntry.docketEntryId, - }); - - const newPdfData = await addServedStampToDocument({ - applicationContext, - pdfData, - serviceStampText: `Served ${serviceStampDate}`, - }); - - await applicationContext.getPersistenceGateway().saveDocumentFromLambda({ - applicationContext, - document: newPdfData, - key: noticeUpdatedDocketEntry.docketEntryId, - }); - - const paperServiceResult = await applicationContext - .getUseCaseHelpers() - .serveDocumentAndGetPaperServicePdf({ - applicationContext, - caseEntities: [caseEntity], - docketEntryId: noticeUpdatedDocketEntry.docketEntryId, - }); - - if (servedParties.paper.length > 0) { - paperServicePdfUrl = paperServiceResult && paperServiceResult.pdfUrl; - paperServiceDocumentTitle = noticeUpdatedDocketEntry.documentTitle; - } - } - - await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ - applicationContext, - caseToUpdate: caseEntity, - }); - - if (isNewCoverSheetNeeded) { - await applicationContext.getUseCases().addCoversheetInteractor( - applicationContext, - { - docketEntryId, - docketNumber: caseEntity.docketNumber, - }, - authorizedUser, - ); - } - - return { - caseDetail: caseEntity.toRawObject(), - paperServiceDocumentTitle, - paperServiceParties: servedParties.paper, - paperServicePdfUrl, - }; -}; - -export const completeDocketEntryQCInteractor = withLocking( - completeDocketEntryQC, - (_applicationContext: ServerApplicationContext, { entryMetadata }) => ({ - identifiers: [`docket-entry|${entryMetadata.docketEntryId}`], - }), - new InvalidRequest('The document is currently being updated'), -); - -export const needsNewCoversheet = ({ - applicationContext, - currentDocketEntry, - updatedDocketEntry, -}) => { - const receivedAtUpdated = - dateStringsCompared( - currentDocketEntry.receivedAt, - updatedDocketEntry.receivedAt, - ) !== 0; - const certificateOfServiceUpdated = - currentDocketEntry.certificateOfService !== - updatedDocketEntry.certificateOfService; - const documentTitleUpdated = - applicationContext.getUtilities().getDocumentTitleWithAdditionalInfo({ - docketEntry: currentDocketEntry, - }) !== - applicationContext.getUtilities().getDocumentTitleWithAdditionalInfo({ - docketEntry: updatedDocketEntry, - }); - - return ( - receivedAtUpdated || certificateOfServiceUpdated || documentTitleUpdated - ); -}; diff --git a/web-api/src/lambdas/documents/completeDocketEntryQCLambda.ts b/web-api/src/lambdas/documents/completeDocketEntryQCLambda.ts index 04070f14fad..1ccc39332f4 100644 --- a/web-api/src/lambdas/documents/completeDocketEntryQCLambda.ts +++ b/web-api/src/lambdas/documents/completeDocketEntryQCLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { completeDocketEntryQCInteractor } from '@web-api/business/useCases/docketEntry/completeDocketEntryQCInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const completeDocketEntryQCLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .completeDocketEntryQCInteractor( +export const completeDocketEntryQCLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await completeDocketEntryQCInteractor( applicationContext, JSON.parse(event.body), + authorizedUser, ); - }); + }, + authorizedUser, + ); From f30126399fc99603b435e72460d1fe71a1d7f92c Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 10 Jul 2024 16:03:26 -0700 Subject: [PATCH 142/523] 10417: migrate away from applicationContext.getCurrentUser --- .../addConsolidatedCaseInteractor.test.ts | 144 +++++++++++------- .../addConsolidatedCaseInteractor.ts | 10 +- .../cases/addConsolidatedCaseLambda.ts | 29 ++-- 3 files changed, 118 insertions(+), 65 deletions(-) diff --git a/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.test.ts b/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.test.ts index 11b0d335217..0679b9e788e 100644 --- a/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.test.ts +++ b/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.test.ts @@ -1,9 +1,12 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { addConsolidatedCaseInteractor } from './addConsolidatedCaseInteractor'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; let mockCases; let mockLock; @@ -59,9 +62,6 @@ describe('addConsolidatedCaseInteractor', () => { }, }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockImplementation(({ docketNumber }) => { @@ -80,15 +80,15 @@ describe('addConsolidatedCaseInteractor', () => { }); it('Should return an Unauthorized error if the user does not have the CONSOLIDATE_CASES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - }); - await expect( - addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '519-19', - docketNumberToConsolidateWith: '319-19', - }), + addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '519-19', + docketNumberToConsolidateWith: '319-19', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for case consolidation'); }); @@ -96,10 +96,14 @@ describe('addConsolidatedCaseInteractor', () => { mockLock = MOCK_LOCK; await expect( - addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '519-19', - docketNumberToConsolidateWith: '319-19', - }), + addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '519-19', + docketNumberToConsolidateWith: '319-19', + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -108,10 +112,14 @@ describe('addConsolidatedCaseInteractor', () => { }); it('should acquire and remove the lock on the cases', async () => { - await addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '519-19', - docketNumberToConsolidateWith: '319-19', - }); + await addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '519-19', + docketNumberToConsolidateWith: '319-19', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -126,10 +134,14 @@ describe('addConsolidatedCaseInteractor', () => { }); it('Should try to get the case by its docketNumber', async () => { - await addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '519-19', - docketNumberToConsolidateWith: '319-19', - }); + await addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '519-19', + docketNumberToConsolidateWith: '319-19', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -138,27 +150,39 @@ describe('addConsolidatedCaseInteractor', () => { it('Should return a Not Found error if the case to update can not be found', async () => { await expect( - addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '111-11', - docketNumberToConsolidateWith: '319-19', - }), + addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '111-11', + docketNumberToConsolidateWith: '319-19', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Case 111-11 was not found.'); }); it('Should return a Not Found error if the case to consolidate with cannot be found', async () => { await expect( - addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '519-19', - docketNumberToConsolidateWith: '111-11', - }), + addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '519-19', + docketNumberToConsolidateWith: '111-11', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Case to consolidate with (111-11) was not found.'); }); it('Should update the case to consolidate with if it does not already have the leadDocketNumber', async () => { - await addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '519-19', - docketNumberToConsolidateWith: '320-19', - }); + await addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '519-19', + docketNumberToConsolidateWith: '320-19', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls.length, @@ -166,10 +190,14 @@ describe('addConsolidatedCaseInteractor', () => { }); it('Should NOT update the case to consolidate with if it already has the leadDocketNumber and is the lead case', async () => { - await addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '519-19', - docketNumberToConsolidateWith: '319-19', - }); + await addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '519-19', + docketNumberToConsolidateWith: '319-19', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls.length, @@ -177,10 +205,14 @@ describe('addConsolidatedCaseInteractor', () => { }); it('Should update both cases with the leadDocketNumber if neither have one', async () => { - await addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '519-19', - docketNumberToConsolidateWith: '319-19', - }); + await addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '519-19', + docketNumberToConsolidateWith: '319-19', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -192,10 +224,14 @@ describe('addConsolidatedCaseInteractor', () => { }); it('Should update all leadDocketNumber fields if the new case has the lower docket number', async () => { - await addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '219-19', - docketNumberToConsolidateWith: '319-19', - }); + await addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '219-19', + docketNumberToConsolidateWith: '319-19', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls.length, @@ -207,10 +243,14 @@ describe('addConsolidatedCaseInteractor', () => { }); it('Should combine all cases when both the case and case to consolidate with are in separate consolidated sets', async () => { - await addConsolidatedCaseInteractor(applicationContext, { - docketNumber: '119-19', - docketNumberToConsolidateWith: '419-19', - }); + await addConsolidatedCaseInteractor( + applicationContext, + { + docketNumber: '119-19', + docketNumberToConsolidateWith: '419-19', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls.length, diff --git a/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts b/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts index 7d18b45f680..6eb2b01d4b3 100644 --- a/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts +++ b/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts @@ -5,6 +5,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -22,10 +23,9 @@ export const addConsolidatedCase = async ( docketNumber, docketNumberToConsolidateWith, }: { docketNumber: string; docketNumberToConsolidateWith: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CONSOLIDATE_CASES)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CONSOLIDATE_CASES)) { throw new UnauthorizedError('Unauthorized for case consolidation'); } @@ -86,7 +86,9 @@ export const addConsolidatedCase = async ( const updateCasePromises: Promise[] = []; casesToUpdate.forEach(caseInCasesToUpdate => { - const caseEntity = new Case(caseInCasesToUpdate, { authorizedUser: user }); + const caseEntity = new Case(caseInCasesToUpdate, { + authorizedUser, + }); caseEntity.setLeadCase(newLeadCase.docketNumber); updateCasePromises.push( diff --git a/web-api/src/lambdas/cases/addConsolidatedCaseLambda.ts b/web-api/src/lambdas/cases/addConsolidatedCaseLambda.ts index a6ff64e6dcf..93682974095 100644 --- a/web-api/src/lambdas/cases/addConsolidatedCaseLambda.ts +++ b/web-api/src/lambdas/cases/addConsolidatedCaseLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { addConsolidatedCaseInteractor } from '@web-api/business/useCases/caseConsolidation/addConsolidatedCaseInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const addConsolidatedCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - await applicationContext - .getUseCases() - .addConsolidatedCaseInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const addConsolidatedCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + await addConsolidatedCaseInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 013a34f3b990274c4f93bb9964388a3c4655a1f1 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 08:20:39 -0700 Subject: [PATCH 143/523] 10417: migrate away from applicationContext.getCurrentUser --- ...NoticeOfChangeToInPersonProceeding.test.ts | 28 ++++++++++++------- .../setNoticeOfChangeToInPersonProceeding.ts | 16 +++-------- .../updateTrialSessionInteractor.ts | 23 ++++++++------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts index dcc56b8945f..88e7ed374f9 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.test.ts @@ -32,11 +32,15 @@ describe('setNoticeOfChangeToInPersonProceeding', () => { }); it('should make a call to generate the NOIP pdf', async () => { - await setNoticeOfChangeToInPersonProceeding(applicationContext, { - caseEntity: mockOpenCase, - newPdfDoc: getFakeFile, - newTrialSessionEntity: mockInPersonCalendaredTrialSession, - }); + await setNoticeOfChangeToInPersonProceeding( + applicationContext, + { + caseEntity: mockOpenCase, + newPdfDoc: getFakeFile, + newTrialSessionEntity: mockInPersonCalendaredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -61,11 +65,15 @@ describe('setNoticeOfChangeToInPersonProceeding', () => { }); it('should make a call to create and serve the NOIP docket entry on the case', async () => { - await setNoticeOfChangeToInPersonProceeding(applicationContext, { - caseEntity: mockOpenCase, - newPdfDoc: getFakeFile, - newTrialSessionEntity: mockInPersonCalendaredTrialSession, - }); + await setNoticeOfChangeToInPersonProceeding( + applicationContext, + { + caseEntity: mockOpenCase, + newPdfDoc: getFakeFile, + newTrialSessionEntity: mockInPersonCalendaredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().createAndServeNoticeDocketEntry diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.ts index ca7c6e53dc1..6846e1e6ebd 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToInPersonProceeding.ts @@ -1,17 +1,8 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '@shared/business/entities/cases/Case'; import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServerApplicationContext } from '@web-api/applicationContext'; -/** - * setNoticeOfChangeToInPersonProceeding - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.caseEntity the case data - * @param {object} providers.newPdfDoc the new PDF contents to be appended - * @param {object} providers.newTrialSessionEntity the new trial session data - * @param {object} providers.userId the user ID - */ export const setNoticeOfChangeToInPersonProceeding = async ( applicationContext: ServerApplicationContext, { @@ -19,7 +10,8 @@ export const setNoticeOfChangeToInPersonProceeding = async ( newPdfDoc, newTrialSessionEntity, }: { caseEntity: Case; newPdfDoc: any; newTrialSessionEntity: any }, -) => { + authorizedUser: AuthUser, +): Promise => { const trialSessionInformation = { address1: newTrialSessionEntity.address1, address2: newTrialSessionEntity.address2, @@ -57,6 +49,6 @@ export const setNoticeOfChangeToInPersonProceeding = async ( newPdfDoc, noticePdf, }, - applicationContext.getCurrentUser(), + authorizedUser, ); }; diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index 94b082ac170..f2353a05bbc 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -148,13 +148,13 @@ export const updateTrialSession = async ( await updateCasesAndSetNoticeOfChange({ applicationContext, + authorizedUser: user, currentTrialSession, paperServicePdfsCombined, shouldIssueNoticeOfChangeOfTrialJudge, shouldSetNoticeOfChangeToInPersonProceeding, shouldSetNoticeOfChangeToRemoteProceeding, updatedTrialSessionEntity, - user, }); hasPaper = !!paperServicePdfsCombined.getPageCount(); @@ -210,19 +210,19 @@ export const updateTrialSession = async ( const updateCasesAndSetNoticeOfChange = async ({ applicationContext, + authorizedUser, currentTrialSession, paperServicePdfsCombined, shouldIssueNoticeOfChangeOfTrialJudge, shouldSetNoticeOfChangeToInPersonProceeding, shouldSetNoticeOfChangeToRemoteProceeding, updatedTrialSessionEntity, - user, }: { applicationContext: ServerApplicationContext; currentTrialSession: RawTrialSession; paperServicePdfsCombined: any; updatedTrialSessionEntity: TrialSession; - user: any; + authorizedUser: any; shouldSetNoticeOfChangeToRemoteProceeding: boolean; shouldSetNoticeOfChangeToInPersonProceeding: boolean; shouldIssueNoticeOfChangeOfTrialJudge: boolean; @@ -237,7 +237,7 @@ const updateCasesAndSetNoticeOfChange = async ({ applicationContext, docketNumber: c.docketNumber, }); - return new Case(aCase, { authorizedUser: user }); + return new Case(aCase, { authorizedUser }); }), ); const casesThatShouldReceiveNotices = calendaredCaseEntities @@ -261,12 +261,15 @@ const updateCasesAndSetNoticeOfChange = async ({ if (shouldSetNoticeOfChangeToInPersonProceeding) { await applicationContext .getUseCaseHelpers() - .setNoticeOfChangeToInPersonProceeding(applicationContext, { - caseEntity, - newPdfDoc: paperServicePdfsCombined, - newTrialSessionEntity: updatedTrialSessionEntity, - user: applicationContext.getCurrentUser(), - }); + .setNoticeOfChangeToInPersonProceeding( + applicationContext, + { + caseEntity, + newPdfDoc: paperServicePdfsCombined, + newTrialSessionEntity: updatedTrialSessionEntity, + }, + authorizedUser, + ); } if (shouldIssueNoticeOfChangeOfTrialJudge) { From 7eab0372dfb67486196afa84820413a055427cb6 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 08:26:29 -0700 Subject: [PATCH 144/523] 10417: migrate away from applicationContext.getCurrentUser --- .../updateCounselOnCaseInteractor.test.ts | 205 +++++++++++------- .../updateCounselOnCaseInteractor.ts | 14 +- .../cases/updateCounselOnCaseLambda.ts | 29 ++- 3 files changed, 148 insertions(+), 100 deletions(-) diff --git a/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.test.ts b/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.test.ts index 2c097416eb1..69aeeb0daf0 100644 --- a/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.test.ts +++ b/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.test.ts @@ -12,6 +12,10 @@ import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { PrivatePractitioner } from '../../../../../shared/src/business/entities/PrivatePractitioner'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { updateCounselOnCaseInteractor } from './updateCounselOnCaseInteractor'; describe('updateCounselOnCaseInteractor', () => { @@ -75,11 +79,6 @@ describe('updateCounselOnCaseInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Saul Goodman', - role: ROLES.docketClerk, - userId: '001', - }); applicationContext .getPersistenceGateway() .getUserById.mockImplementation(({ userId }) => { @@ -133,16 +132,18 @@ describe('updateCounselOnCaseInteractor', () => { }); it('returns an unauthorized error for a petitioner user', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], + updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], + }, + userId: '9d914ca2-7876-43a7-acfa-ccb645717e11', }, - userId: '9d914ca2-7876-43a7-acfa-ccb645717e11', - }), + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -150,15 +151,19 @@ describe('updateCounselOnCaseInteractor', () => { mockLock = MOCK_LOCK; await expect( - updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - name: 'Saul Goodman', - representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + name: 'Saul Goodman', + representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + }, + userId: '9d914ca2-7876-43a7-acfa-ccb645717e11', }, - userId: '9d914ca2-7876-43a7-acfa-ccb645717e11', - }), + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -167,15 +172,19 @@ describe('updateCounselOnCaseInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - name: 'Saul Goodman', - representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + await updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + name: 'Saul Goodman', + representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + }, + userId: '9d914ca2-7876-43a7-acfa-ccb645717e11', }, - userId: '9d914ca2-7876-43a7-acfa-ccb645717e11', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -194,15 +203,19 @@ describe('updateCounselOnCaseInteractor', () => { }); it('updates a practitioner with the given userId on the associated case', async () => { - await updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - name: 'Saul Goodman', - representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + await updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + name: 'Saul Goodman', + representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + }, + userId: '9d914ca2-7876-43a7-acfa-ccb645717e11', }, - userId: '9d914ca2-7876-43a7-acfa-ccb645717e11', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -210,15 +223,19 @@ describe('updateCounselOnCaseInteractor', () => { }); it('updates an irsPractitioner with the given userId on the associated case', async () => { - await updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - name: 'Saul Goodman', - representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + await updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + name: 'Saul Goodman', + representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + }, + userId: '76c86b6b-6aad-4128-8fa2-53c5735cc0af', }, - userId: '76c86b6b-6aad-4128-8fa2-53c5735cc0af', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -226,16 +243,20 @@ describe('updateCounselOnCaseInteractor', () => { }); it('updates only editable practitioner fields on the case', async () => { - await updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - email: 'not.editable@example.com', - name: 'Saul Goodman', - representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + await updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + email: 'not.editable@example.com', + name: 'Saul Goodman', + representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + }, + userId: '76c86b6b-6aad-4128-8fa2-53c5735cc0af', }, - userId: '76c86b6b-6aad-4128-8fa2-53c5735cc0af', - }); + mockDocketClerkUser, + ); const updatedPractitioner = applicationContext .getPersistenceGateway() @@ -250,16 +271,20 @@ describe('updateCounselOnCaseInteractor', () => { }); it('updates the service indicator on the contacts when they are being represented', async () => { - const results = await updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - email: 'not.editable@example.com', - name: 'Saul Goodman', - representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + const results = await updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + email: 'not.editable@example.com', + name: 'Saul Goodman', + representing: ['9d914ca2-7876-43a7-acfa-ccb645717e11'], + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + }, + userId: 'e23e2d08-561b-4930-a2e0-1f342a481268', }, - userId: 'e23e2d08-561b-4930-a2e0-1f342a481268', - }); + mockDocketClerkUser, + ); expect(results.petitioners[0].serviceIndicator).toBe( SERVICE_INDICATOR_TYPES.SI_NONE, @@ -270,16 +295,20 @@ describe('updateCounselOnCaseInteractor', () => { }); it('reverts the service indicator on the contacts when they are no longer being represented', async () => { - const results = await updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - email: 'not.editable@example.com', - name: 'Saul Goodman', - representing: ['b7315e1b-b804-4e09-84c5-e0f3b4f229c5'], - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + const results = await updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + email: 'not.editable@example.com', + name: 'Saul Goodman', + representing: ['b7315e1b-b804-4e09-84c5-e0f3b4f229c5'], + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, + }, + userId: 'e23e2d08-561b-4930-a2e0-1f342a481268', }, - userId: 'e23e2d08-561b-4930-a2e0-1f342a481268', - }); + mockDocketClerkUser, + ); expect(results.petitioners[0].serviceIndicator).toBe( SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, @@ -297,13 +326,17 @@ describe('updateCounselOnCaseInteractor', () => { privatePractitioners: [mockPrivatePractitioners[1]], })); - const results = await updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - representing: ['9905d1ab-18d0-43ec-bafb-654e83405416'], + const results = await updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + representing: ['9905d1ab-18d0-43ec-bafb-654e83405416'], + }, + userId: 'e23e2d08-561b-4930-a2e0-1f342a481268', }, - userId: 'e23e2d08-561b-4930-a2e0-1f342a481268', - }); + mockDocketClerkUser, + ); expect(results.petitioners[0].serviceIndicator).toBe( MOCK_CASE.petitioners[0].serviceIndicator, @@ -312,13 +345,17 @@ describe('updateCounselOnCaseInteractor', () => { it('throws an error if the userId is not a privatePractitioner or irsPractitioner role', async () => { await expect( - updateCounselOnCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userData: { - email: 'petitioner@example.com', + updateCounselOnCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userData: { + email: 'petitioner@example.com', + }, + userId: 'aa335271-9a0f-4ad5-bcf1-3b89bd8b5dd6', }, - userId: 'aa335271-9a0f-4ad5-bcf1-3b89bd8b5dd6', - }), + mockDocketClerkUser, + ), ).rejects.toThrow('User is not a practitioner'); }); }); diff --git a/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts b/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts index 6bb247f80ca..d50abee29fb 100644 --- a/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts +++ b/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts @@ -9,6 +9,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -28,15 +29,16 @@ const updateCounselOnCase = async ( userData, userId, }: { docketNumber: string; userData: any; userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - const editableFields = { representing: userData.representing, serviceIndicator: userData.serviceIndicator, }; - if (!isAuthorized(user, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) + ) { throw new UnauthorizedError('Unauthorized'); } @@ -54,7 +56,7 @@ const updateCounselOnCase = async ( userId, }); - const caseEntity = new Case(caseToUpdate, { authorizedUser: user }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); if (userToUpdate.role === ROLES.privatePractitioner) { caseEntity.updatePrivatePractitioner({ @@ -90,9 +92,7 @@ const updateCounselOnCase = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const updateCounselOnCaseInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/updateCounselOnCaseLambda.ts b/web-api/src/lambdas/cases/updateCounselOnCaseLambda.ts index 9fa05049ea0..387384bfb5b 100644 --- a/web-api/src/lambdas/cases/updateCounselOnCaseLambda.ts +++ b/web-api/src/lambdas/cases/updateCounselOnCaseLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateCounselOnCaseInteractor } from '@web-api/business/useCases/caseAssociation/updateCounselOnCaseInteractor'; /** * used for updating a privatePractitioner or irsPractitioner on a case @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateCounselOnCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCounselOnCaseInteractor(applicationContext, { - ...event.pathParameters, - userData: JSON.parse(event.body), - }); - }); +export const updateCounselOnCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await updateCounselOnCaseInteractor( + applicationContext, + { + ...event.pathParameters, + userData: JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 97c4bed6cf2df74e8d18e0e6fd4327ee8b6655f0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 08:29:29 -0700 Subject: [PATCH 145/523] 10417: migrate away from applicationContext.getCurrentUser --- .../caseNote/saveCaseNoteInteractor.test.ts | 59 +++++++++++-------- .../caseNote/saveCaseNoteInteractor.ts | 9 +-- .../lambdas/caseNote/saveCaseNoteLambda.ts | 32 ++++++---- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.test.ts b/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.test.ts index fd982ea2a47..eea1f25a8ac 100644 --- a/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.test.ts +++ b/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.test.ts @@ -1,9 +1,8 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockJudgeUser, mockPetitionerUser } from '@shared/test/mockAuthUsers'; import { saveCaseNoteInteractor } from './saveCaseNoteInteractor'; describe('saveCaseNoteInteractor', () => { @@ -16,12 +15,6 @@ describe('saveCaseNoteInteractor', () => { beforeEach(() => { mockLock = undefined; - const mockJudge = new User({ - name: 'Judge Colvin', - role: ROLES.judge, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - applicationContext.getCurrentUser.mockReturnValue(mockJudge); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockResolvedValue(MOCK_CASE); @@ -30,21 +23,27 @@ describe('saveCaseNoteInteractor', () => { .updateCase.mockImplementation(({ caseToUpdate }) => caseToUpdate); }); it('throws an error if the user is not valid or authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - saveCaseNoteInteractor(applicationContext, { - caseNote: 'testing', - docketNumber: MOCK_CASE.docketNumber, - }), + saveCaseNoteInteractor( + applicationContext, + { + caseNote: 'testing', + docketNumber: MOCK_CASE.docketNumber, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('saves a case note', async () => { - const result = await saveCaseNoteInteractor(applicationContext, { - caseNote: 'This is my case note', - docketNumber: MOCK_CASE.docketNumber, - }); + const result = await saveCaseNoteInteractor( + applicationContext, + { + caseNote: 'This is my case note', + docketNumber: MOCK_CASE.docketNumber, + }, + mockJudgeUser, + ); expect(result).toBeDefined(); expect( @@ -60,10 +59,14 @@ describe('saveCaseNoteInteractor', () => { mockLock = MOCK_LOCK; await expect( - saveCaseNoteInteractor(applicationContext, { - caseNote: 'This is my case note', - docketNumber: MOCK_CASE.docketNumber, - }), + saveCaseNoteInteractor( + applicationContext, + { + caseNote: 'This is my case note', + docketNumber: MOCK_CASE.docketNumber, + }, + mockJudgeUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -72,10 +75,14 @@ describe('saveCaseNoteInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await saveCaseNoteInteractor(applicationContext, { - caseNote: 'This is my case note', - docketNumber: MOCK_CASE.docketNumber, - }); + await saveCaseNoteInteractor( + applicationContext, + { + caseNote: 'This is my case note', + docketNumber: MOCK_CASE.docketNumber, + }, + mockJudgeUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts b/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts index 26d6dde1f65..de06ff22b06 100644 --- a/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts +++ b/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -19,9 +20,9 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const saveCaseNote = async ( applicationContext: ServerApplicationContext, { caseNote, docketNumber }: { caseNote: string; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_NOTES)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_NOTES)) { throw new UnauthorizedError('Unauthorized'); } @@ -35,7 +36,7 @@ export const saveCaseNote = async ( const caseToUpdate = new Case( { ...caseRecord, caseNote }, { - authorizedUser: user, + authorizedUser, }, ) .validate() @@ -48,7 +49,7 @@ export const saveCaseNote = async ( caseToUpdate, }); - return new Case(result, { authorizedUser: user }).validate().toRawObject(); + return new Case(result, { authorizedUser }).validate().toRawObject(); }; export const saveCaseNoteInteractor = withLocking( diff --git a/web-api/src/lambdas/caseNote/saveCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/saveCaseNoteLambda.ts index 9362e4dba10..e4c180083b2 100644 --- a/web-api/src/lambdas/caseNote/saveCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/saveCaseNoteLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { saveCaseNoteInteractor } from '@web-api/business/useCases/caseNote/saveCaseNoteInteractor'; /** * used for saving a case note @@ -6,16 +8,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const saveCaseNoteLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const lambdaArguments = { - ...event.pathParameters, - ...JSON.parse(event.body), - }; +export const saveCaseNoteLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + const lambdaArguments = { + ...event.pathParameters, + ...JSON.parse(event.body), + }; - return await applicationContext - .getUseCases() - .saveCaseNoteInteractor(applicationContext, { - ...lambdaArguments, - }); - }); + return await saveCaseNoteInteractor( + applicationContext, + { + ...lambdaArguments, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From a7f051e372a44f36cff71f6ee89b45e71b3f9c6d Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 08:40:41 -0700 Subject: [PATCH 146/523] 10417: migrate away from applicationContext.getCurrentUser --- ...itCaseAssociationRequestInteractor.test.ts | 98 ++++++++----------- .../submitCaseAssociationRequestInteractor.ts | 4 +- ...rivatePractitionerCaseAssociationLambda.ts | 29 ++++-- 3 files changed, 63 insertions(+), 68 deletions(-) diff --git a/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.test.ts b/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.test.ts index 8a43360f2da..87135f1a9f1 100644 --- a/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.test.ts +++ b/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.test.ts @@ -5,17 +5,19 @@ import { import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getContactPrimary } from '../../../../../shared/src/business/entities/cases/Case'; +import { + mockAdcUser, + mockIrsPractitionerUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { submitCaseAssociationRequestInteractor } from './submitCaseAssociationRequestInteractor'; describe('submitCaseAssociationRequest', () => { const mockContactId = getContactPrimary(MOCK_CASE).contactId; - let mockCurrentUser; let mockGetUserById; beforeAll(() => { - applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser); - applicationContext .getPersistenceGateway() .getUserById.mockImplementation(() => mockGetUserById); @@ -26,27 +28,19 @@ describe('submitCaseAssociationRequest', () => { }); it('should throw an error when not authorized', async () => { - mockCurrentUser = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.adc, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - await expect( - submitCaseAssociationRequestInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - filers: [], - }), + submitCaseAssociationRequestInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + filers: [], + }, + mockAdcUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should not add mapping if already there', async () => { - mockCurrentUser = { - barNumber: 'BN1234', - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.privatePractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; mockGetUserById = { barNumber: 'BN1234', contact: { @@ -59,18 +53,22 @@ describe('submitCaseAssociationRequest', () => { postalCode: '61234', state: 'IL', }, - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', + name: mockPrivatePractitionerUser.name, role: ROLES.privatePractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + userId: mockPrivatePractitionerUser.userId, }; applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(true); - await submitCaseAssociationRequestInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - filers: [], - }); + await submitCaseAssociationRequestInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + filers: [], + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations, @@ -78,30 +76,18 @@ describe('submitCaseAssociationRequest', () => { }); it('should add mapping for a practitioner', async () => { - mockCurrentUser = { - barNumber: 'BN1234', - contact: { - address1: '234 Main St', - address2: 'Apartment 4', - address3: 'Under the stairs', - city: 'Chicago', - countryType: COUNTRY_TYPES.DOMESTIC, - phone: '+1 (555) 555-5555', - postalCode: '61234', - state: 'IL', - }, - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.privatePractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(false); - await submitCaseAssociationRequestInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - filers: [mockContactId], - }); + await submitCaseAssociationRequestInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + filers: [mockContactId], + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getUseCaseHelpers().associatePrivatePractitionerToCase, @@ -109,12 +95,6 @@ describe('submitCaseAssociationRequest', () => { }); it('should add mapping for an irsPractitioner', async () => { - mockCurrentUser = { - barNumber: 'BN1234', - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.irsPractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; mockGetUserById = { barNumber: 'BN1234', contact: { @@ -127,18 +107,22 @@ describe('submitCaseAssociationRequest', () => { postalCode: '61234', state: 'IL', }, - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', + name: mockIrsPractitionerUser.name, role: ROLES.irsPractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + userId: mockIrsPractitionerUser, }; applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(false); - await submitCaseAssociationRequestInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - filers: ['c54ba5a9-b37b-479d-9201-067ec6e335bb'], - }); + await submitCaseAssociationRequestInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + filers: ['c54ba5a9-b37b-479d-9201-067ec6e335bb'], + }, + mockIrsPractitionerUser, + ); expect( applicationContext.getUseCaseHelpers().associateIrsPractitionerToCase, diff --git a/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts b/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts index 721e54ee872..874b2cbf4fd 100644 --- a/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts +++ b/web-api/src/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -25,9 +26,8 @@ const submitCaseAssociationRequest = async ( docketNumber: string; filers: string[]; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if ( !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSOCIATE_SELF_WITH_CASE) ) { diff --git a/web-api/src/lambdas/cases/privatePractitionerCaseAssociationLambda.ts b/web-api/src/lambdas/cases/privatePractitionerCaseAssociationLambda.ts index ec4be8fdf4f..f0ab069df86 100644 --- a/web-api/src/lambdas/cases/privatePractitionerCaseAssociationLambda.ts +++ b/web-api/src/lambdas/cases/privatePractitionerCaseAssociationLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { submitCaseAssociationRequestInteractor } from '@web-api/business/useCases/caseAssociationRequest/submitCaseAssociationRequestInteractor'; /** * lambda which is used for associating a user to a case @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const privatePractitionerCaseAssociationLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .submitCaseAssociationRequestInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const privatePractitionerCaseAssociationLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await submitCaseAssociationRequestInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 85039b71909ec914b6b8ad4f6212b7e3e1648591 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 11:34:26 -0700 Subject: [PATCH 147/523] 10417: remove unused interactor --- .../fileCourtIssuedOrderInteractor.test.ts | 509 ------------------ .../fileCourtIssuedOrderInteractor.ts | 150 ------ 2 files changed, 659 deletions(-) delete mode 100644 web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.test.ts delete mode 100644 web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.ts diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.test.ts b/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.test.ts deleted file mode 100644 index 6e7201ae9b0..00000000000 --- a/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.test.ts +++ /dev/null @@ -1,509 +0,0 @@ -import { - CASE_STATUS_TYPES, - CASE_TYPES_MAP, - CONTACT_TYPES, - COUNTRY_TYPES, - PARTY_TYPES, - PETITIONS_SECTION, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; -import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; -import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { fileCourtIssuedOrderInteractor } from './fileCourtIssuedOrderInteractor'; - -describe('fileCourtIssuedOrderInteractor', () => { - const mockUserId = applicationContext.getUniqueId(); - const caseRecord = { - caseCaption: 'Caption', - caseType: CASE_TYPES_MAP.whistleblower, - createdAt: '', - docketEntries: [ - { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - docketNumber: '45678-18', - documentType: 'Answer', - eventCode: 'A', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: mockUserId, - }, - { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - docketNumber: '45678-18', - documentType: 'Answer', - eventCode: 'A', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: mockUserId, - }, - { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - docketNumber: '45678-18', - documentType: 'Answer', - eventCode: 'A', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: mockUserId, - }, - ], - docketNumber: '45678-18', - docketNumberWithSuffix: '45678-18W', - filingType: 'Myself', - partyType: PARTY_TYPES.petitioner, - petitioners: [ - { - address1: '123 Main St', - city: 'Somewhere', - contactType: CONTACT_TYPES.primary, - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'fieri@example.com', - name: 'Guy Fieri', - phone: '1234567890', - postalCode: '12345', - state: 'CA', - }, - ], - preferredTrialCity: 'Fresno, California', - procedureType: 'Regular', - role: ROLES.petitioner, - status: CASE_STATUS_TYPES.new, - userId: 'ddd6c900-388b-4151-8014-b3378076bfb0', - }; - let mockLock; - - beforeAll(() => { - applicationContext - .getPersistenceGateway() - .getLock.mockImplementation(() => mockLock); - }); - - beforeEach(() => { - mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ); - - applicationContext.getPersistenceGateway().getUserById.mockReturnValue( - new User({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ); - - applicationContext - .getPersistenceGateway() - .getCaseByDocketNumber.mockReturnValue(caseRecord); - }); - - it('should throw an error if not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - - await expect( - fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - eventCode: 'OSC', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ).rejects.toThrow('Unauthorized'); - }); - - it('should add order document to case', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries.length, - ).toEqual(4); - }); - - it('should add order document to case and set freeText and draftOrderState.freeText to the document title if it is a generic order (eventCode O)', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - draftOrderState: {}, - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries.length, - ).toEqual(4); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3], - ).toMatchObject({ - draftOrderState: { freeText: 'Order to do anything' }, - freeText: 'Order to do anything', - }); - }); - - it('should delete draftOrderState properties if they exists on the documentMetadata, after saving the document', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: {}, - documentTitle: 'Order to do anything', - documentType: 'Order', - draftOrderState: { - documentContents: 'something', - editorDelta: 'something', - richText: 'something', - }, - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3].draftOrderState.documentContents, - ).toBeUndefined(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3].draftOrderState.editorDelta, - ).toBeUndefined(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3].draftOrderState.richText, - ).toBeUndefined(); - }); - - it('should add a generic notice document to case, set freeText to the document title, and set the document to signed', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Notice to be nice', - documentType: 'Notice', - eventCode: 'NOT', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().updateCase, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries.length, - ).toEqual(4); - const result = - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3]; - expect(result).toMatchObject({ freeText: 'Notice to be nice' }); - expect(result.signedAt).toBeTruthy(); - }); - - it('should store documentMetadata.documentContents in S3 and delete from data sent to persistence', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().saveDocumentFromLambda.mock - .calls[0][0], - ).toMatchObject({ - useTempBucket: false, - }); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3].documentContents, - ).toBeUndefined(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3], - ).toMatchObject({ - documentContentsId: expect.anything(), - draftOrderState: {}, - }); - }); - - it('should append docket number with suffix and case caption to document contents before storing', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - const savedDocumentContents = JSON.parse( - applicationContext - .getPersistenceGateway() - .saveDocumentFromLambda.mock.calls[0][0].document.toString(), - ).documentContents; - - expect(savedDocumentContents).toContain(caseRecord.docketNumberWithSuffix); - expect(savedDocumentContents).toContain(caseRecord.caseCaption); - }); - - it('should set documentMetadata documentContents if parseAndScrapePdfContents returns content', async () => { - const mockDocumentContents = 'bloop ee doop brnabowbow'; - applicationContext - .getUseCaseHelpers() - .parseAndScrapePdfContents.mockReturnValue(mockDocumentContents); - - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - const savedDocumentContents = JSON.parse( - applicationContext - .getPersistenceGateway() - .saveDocumentFromLambda.mock.calls[0][0].document.toString(), - ).documentContents; - - expect(savedDocumentContents).toContain(mockDocumentContents); - }); - - it('should parse and scrape pdf contents', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'TC Opinion', - documentType: 'T.C. Opinion', - eventCode: 'TCOP', - judge: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getUseCaseHelpers().parseAndScrapePdfContents, - ).toHaveBeenCalled(); - }); - - it('should add order document to most recent message if a parentMessageId is passed in', async () => { - applicationContext - .getPersistenceGateway() - .getMessageThreadByParentId.mockReturnValue([ - { - caseStatus: caseRecord.status, - caseTitle: PARTY_TYPES.petitioner, - createdAt: '2019-03-01T21:40:46.415Z', - docketNumber: caseRecord.docketNumber, - docketNumberWithSuffix: caseRecord.docketNumber, - from: 'Test Petitionsclerk', - fromSection: PETITIONS_SECTION, - fromUserId: '4791e892-14ee-4ab1-8468-0c942ec379d2', - message: 'hey there', - messageId: 'a10d6855-f3ee-4c11-861c-c7f11cba4dff', - parentMessageId: '31687a1e-3640-42cd-8e7e-a8e6df39ce9a', - subject: 'hello', - to: 'Test Petitionsclerk2', - toSection: PETITIONS_SECTION, - toUserId: '449b916e-3362-4a5d-bf56-b2b94ba29c12', - }, - ]); - - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - eventCode: 'O', - parentMessageId: '6c1fd626-c1e1-4367-bca6-e00f9ef98cf5', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().updateMessage, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateMessage.mock.calls[0][0] - .message.attachments, - ).toEqual([ - { - documentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentTitle: 'Order to do anything', - }, - ]); - }); - - it('should set isDraft to true when creating a court issued document', async () => { - applicationContext - .getPersistenceGateway() - .getMessageThreadByParentId.mockReturnValue([ - { - caseStatus: caseRecord.status, - caseTitle: PARTY_TYPES.petitioner, - createdAt: '2019-03-01T21:40:46.415Z', - docketNumber: caseRecord.docketNumber, - docketNumberWithSuffix: caseRecord.docketNumber, - from: 'Test Petitionsclerk', - fromSection: PETITIONS_SECTION, - fromUserId: '4791e892-14ee-4ab1-8468-0c942ec379d2', - message: 'hey there', - messageId: 'a10d6855-f3ee-4c11-861c-c7f11cba4dff', - parentMessageId: '31687a1e-3640-42cd-8e7e-a8e6df39ce9a', - subject: 'hello', - to: 'Test Petitionsclerk2', - toSection: PETITIONS_SECTION, - toUserId: '449b916e-3362-4a5d-bf56-b2b94ba29c12', - }, - ]); - - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - eventCode: 'O', - parentMessageId: '6c1fd626-c1e1-4367-bca6-e00f9ef98cf5', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - const lastDocumentIndex = - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries.length - 1; - - const newlyFiledDocument = - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[lastDocumentIndex]; - - expect(newlyFiledDocument).toMatchObject({ - isDraft: true, - }); - }); - - it('should throw an error if fails to parse pdf', async () => { - applicationContext - .getUseCaseHelpers() - .parseAndScrapePdfContents.mockImplementation(() => { - throw new Error('error parsing pdf'); - }); - - await expect( - fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'TC Opinion', - documentType: 'T.C. Opinion', - eventCode: 'TCOP', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ).rejects.toThrow('error parsing pdf'); - }); - - it('should throw a ServiceUnavailableError if the Case is currently locked', async () => { - mockLock = MOCK_LOCK; - - await expect( - fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ).rejects.toThrow(ServiceUnavailableError); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).not.toHaveBeenCalled(); - }); - - it('should acquire and remove the lock on the case', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().createLock, - ).toHaveBeenCalledWith({ - applicationContext, - identifier: `case|${caseRecord.docketNumber}`, - ttl: 30, - }); - - expect( - applicationContext.getPersistenceGateway().removeLock, - ).toHaveBeenCalledWith({ - applicationContext, - identifiers: [`case|${caseRecord.docketNumber}`], - }); - }); -}); diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.ts deleted file mode 100644 index 39390119fbc..00000000000 --- a/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.ts +++ /dev/null @@ -1,150 +0,0 @@ -import { Case } from '../../../../../shared/src/business/entities/cases/Case'; -import { DOCUMENT_RELATIONSHIPS } from '../../../../../shared/src/business/entities/EntityConstants'; -import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; -import { Message } from '../../../../../shared/src/business/entities/Message'; -import { - ROLE_PERMISSIONS, - isAuthorized, -} from '../../../../../shared/src/authorization/authorizationClientService'; -import { ServerApplicationContext } from '@web-api/applicationContext'; -import { UnauthorizedError } from '@web-api/errors/errors'; -import { orderBy } from 'lodash'; -import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; - -export const fileCourtIssuedOrder = async ( - applicationContext: ServerApplicationContext, - { - documentMetadata, - primaryDocumentFileId, - }: { documentMetadata: any; primaryDocumentFileId: string }, -): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - const { docketNumber } = documentMetadata; - - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT)) { - throw new UnauthorizedError('Unauthorized'); - } - - const user = await applicationContext - .getPersistenceGateway() - .getUserById({ applicationContext, userId: authorizedUser.userId }); - - const caseToUpdate = await applicationContext - .getPersistenceGateway() - .getCaseByDocketNumber({ - applicationContext, - docketNumber, - }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); - - const shouldScrapePDFContents = !documentMetadata.documentContents; - - if (['O', 'NOT'].includes(documentMetadata.eventCode)) { - documentMetadata.freeText = documentMetadata.documentTitle; - if (documentMetadata.draftOrderState) { - documentMetadata.draftOrderState.freeText = - documentMetadata.documentTitle; - } - } - - if (shouldScrapePDFContents) { - const pdfBuffer = await applicationContext - .getPersistenceGateway() - .getDocument({ applicationContext, key: primaryDocumentFileId }); - - const contents = await applicationContext - .getUseCaseHelpers() - .parseAndScrapePdfContents({ applicationContext, pdfBuffer }); - - if (contents) { - documentMetadata.documentContents = contents; - } - } - - if (documentMetadata.documentContents) { - documentMetadata.documentContents += ` ${caseEntity.docketNumberWithSuffix} ${caseEntity.caseCaption}`; - - const documentContentsId = applicationContext.getUniqueId(); - - const contentToStore = { - documentContents: documentMetadata.documentContents, - richText: documentMetadata.draftOrderState - ? documentMetadata.draftOrderState.richText - : undefined, - }; - - await applicationContext.getPersistenceGateway().saveDocumentFromLambda({ - applicationContext, - contentType: 'application/json', - document: Buffer.from(JSON.stringify(contentToStore)), - key: documentContentsId, - useTempBucket: false, - }); - - if (documentMetadata.draftOrderState) { - delete documentMetadata.draftOrderState.documentContents; - delete documentMetadata.draftOrderState.richText; - delete documentMetadata.draftOrderState.editorDelta; - } - - delete documentMetadata.documentContents; - documentMetadata.documentContentsId = documentContentsId; - } - - const docketEntryEntity = new DocketEntry( - { - ...documentMetadata, - docketEntryId: primaryDocumentFileId, - documentType: documentMetadata.documentType, - filedBy: user.name, - isDraft: true, - isFileAttached: true, - relationship: DOCUMENT_RELATIONSHIPS.PRIMARY, - }, - { applicationContext }, - ); - - docketEntryEntity.setFiledBy(user); - - docketEntryEntity.setAsProcessingStatusAsCompleted(); - - caseEntity.addDocketEntry(docketEntryEntity); - - await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ - applicationContext, - caseToUpdate: caseEntity, - }); - - if (documentMetadata.parentMessageId) { - const messages = await applicationContext - .getPersistenceGateway() - .getMessageThreadByParentId({ - applicationContext, - parentMessageId: documentMetadata.parentMessageId, - }); - - const mostRecentMessage = orderBy(messages, 'createdAt', 'desc')[0]; - - const messageEntity = new Message(mostRecentMessage, { - applicationContext, - }).validate(); - messageEntity.addAttachment({ - documentId: docketEntryEntity.docketEntryId, - documentTitle: docketEntryEntity.documentTitle, - }); - - await applicationContext.getPersistenceGateway().updateMessage({ - applicationContext, - message: messageEntity.validate().toRawObject(), - }); - } - - return caseEntity.toRawObject(); -}; - -export const fileCourtIssuedOrderInteractor = withLocking( - fileCourtIssuedOrder, - (_applicationContext: ServerApplicationContext, { documentMetadata }) => ({ - identifiers: [`case|${documentMetadata.docketNumber}`], - }), -); From 77d5abe6bd83d6512936c15520d2f84251ac30e8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 11:53:25 -0700 Subject: [PATCH 148/523] 10417: migrate away from applicationContext.getCurrentUser --- .../fileCourtIssuedOrderInteractor.test.ts | 327 ++++++++++-------- .../fileCourtIssuedOrderInteractor.ts | 3 +- .../fileCourtIssuedOrderToCaseLambda.ts | 20 +- 3 files changed, 201 insertions(+), 149 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.ts b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.ts index 6aee7f77f43..968160793dd 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.test.ts @@ -12,6 +12,10 @@ import { ServiceUnavailableError } from '@web-api/errors/errors'; import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { fileCourtIssuedOrderInteractor } from './fileCourtIssuedOrderInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('fileCourtIssuedOrderInteractor', () => { const mockUserId = applicationContext.getUniqueId(); @@ -81,13 +85,6 @@ describe('fileCourtIssuedOrderInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ); applicationContext.getPersistenceGateway().getUserById.mockReturnValue( new User({ @@ -103,32 +100,38 @@ describe('fileCourtIssuedOrderInteractor', () => { }); it('should throw an error if not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - fileCourtIssuedOrderInteractor(applicationContext, { + fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentType: 'Order to Show Cause', + eventCode: 'OSC', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockPetitionerUser, + ), + ).rejects.toThrow('Unauthorized'); + }); + + it('should add order document to case', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { documentMetadata: { docketNumber: caseRecord.docketNumber, documentType: 'Order to Show Cause', eventCode: 'OSC', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', }, primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ).rejects.toThrow('Unauthorized'); - }); - - it('should add order document to case', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -140,19 +143,23 @@ describe('fileCourtIssuedOrderInteractor', () => { }); it('should add order document to case and set freeText and draftOrderState.freeText to the document title if it is a generic order (eventCode O)', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - draftOrderState: {}, - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Order to do anything', + documentType: 'Order', + draftOrderState: {}, + eventCode: 'O', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -171,24 +178,28 @@ describe('fileCourtIssuedOrderInteractor', () => { }); it('should delete draftOrderState properties if they exists on the documentMetadata, after saving the document', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: {}, - documentTitle: 'Order to do anything', - documentType: 'Order', - draftOrderState: { - documentContents: 'something', - editorDelta: 'something', - richText: 'something', + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentContents: {}, + documentTitle: 'Order to do anything', + documentType: 'Order', + draftOrderState: { + documentContents: 'something', + editorDelta: 'something', + richText: 'something', + }, + eventCode: 'O', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', }, - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -205,18 +216,22 @@ describe('fileCourtIssuedOrderInteractor', () => { }); it('should add a generic notice document to case, set freeText to the document title, and set the document to signed', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Notice to be nice', - documentType: 'Notice', - eventCode: 'NOT', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Notice to be nice', + documentType: 'Notice', + eventCode: 'NOT', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -233,18 +248,22 @@ describe('fileCourtIssuedOrderInteractor', () => { }); it('should store documentMetadata.documentContents in S3 and delete from data sent to persistence', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentContents: 'I am some document contents', + documentType: 'Order to Show Cause', + eventCode: 'OSC', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda.mock @@ -266,18 +285,22 @@ describe('fileCourtIssuedOrderInteractor', () => { }); it('should append docket number with suffix and case caption to document contents before storing', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentContents: 'I am some document contents', + documentType: 'Order to Show Cause', + eventCode: 'OSC', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); const savedDocumentContents = JSON.parse( applicationContext @@ -290,18 +313,22 @@ describe('fileCourtIssuedOrderInteractor', () => { }); it('should append the docket number and case caption to the document contents if document contents was defined', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'hello', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentContents: 'hello', + documentType: 'Order to Show Cause', + eventCode: 'OSC', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); const savedDocumentContents = JSON.parse( applicationContext @@ -335,19 +362,23 @@ describe('fileCourtIssuedOrderInteractor', () => { }, ]); - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - eventCode: 'O', - parentMessageId: '6c1fd626-c1e1-4367-bca6-e00f9ef98cf5', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Order to do anything', + documentType: 'Order', + eventCode: 'O', + parentMessageId: '6c1fd626-c1e1-4367-bca6-e00f9ef98cf5', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateMessage, @@ -386,19 +417,23 @@ describe('fileCourtIssuedOrderInteractor', () => { }, ]); - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - eventCode: 'O', - parentMessageId: '6c1fd626-c1e1-4367-bca6-e00f9ef98cf5', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + await fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Order to do anything', + documentType: 'Order', + eventCode: 'O', + parentMessageId: '6c1fd626-c1e1-4367-bca6-e00f9ef98cf5', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); const lastDocumentIndex = applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -417,7 +452,33 @@ describe('fileCourtIssuedOrderInteractor', () => { mockLock = MOCK_LOCK; await expect( - fileCourtIssuedOrderInteractor(applicationContext, { + fileCourtIssuedOrderInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentContents: 'I am some document contents', + documentType: 'Order to Show Cause', + eventCode: 'OSC', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), + ).rejects.toThrow(ServiceUnavailableError); + + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).not.toHaveBeenCalled(); + }); + + it('should acquire and remove the lock on the case', async () => { + await fileCourtIssuedOrderInteractor( + applicationContext, + { documentMetadata: { docketNumber: caseRecord.docketNumber, documentContents: 'I am some document contents', @@ -428,27 +489,9 @@ describe('fileCourtIssuedOrderInteractor', () => { signedJudgeName: 'Dredd', }, primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ).rejects.toThrow(ServiceUnavailableError); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).not.toHaveBeenCalled(); - }); - - it('should acquire and remove the lock on the case', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts index 6a9cce65163..a025ce4b40b 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts @@ -8,6 +8,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { orderBy } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -17,8 +18,8 @@ export const fileCourtIssuedOrder = async ( documentMetadata, primaryDocumentFileId, }: { documentMetadata: any; primaryDocumentFileId: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); const { docketNumber } = documentMetadata; if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT)) { diff --git a/web-api/src/lambdas/documents/fileCourtIssuedOrderToCaseLambda.ts b/web-api/src/lambdas/documents/fileCourtIssuedOrderToCaseLambda.ts index 1950cfd7f92..af337032af2 100644 --- a/web-api/src/lambdas/documents/fileCourtIssuedOrderToCaseLambda.ts +++ b/web-api/src/lambdas/documents/fileCourtIssuedOrderToCaseLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { fileCourtIssuedOrderInteractor } from '@web-api/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +8,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const fileCourtIssuedOrderToCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .fileCourtIssuedOrderInteractor( +export const fileCourtIssuedOrderToCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await fileCourtIssuedOrderInteractor( applicationContext, JSON.parse(event.body), + authorizedUser, ); - }); + }, + authorizedUser, + ); From 61080dbff953e03b71622ad2491a7532f502efc5 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 11:59:40 -0700 Subject: [PATCH 149/523] 10417: migrate away from applicationContext.getCurrentUser --- .../notifications/onConnectInteractor.test.ts | 31 ++++++++++++------- .../notifications/onConnectInteractor.ts | 3 +- web-api/src/genericHandler.ts | 5 ++- .../lambdas/notifications/connectLambda.ts | 15 ++++++--- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/web-api/src/business/useCases/notifications/onConnectInteractor.test.ts b/web-api/src/business/useCases/notifications/onConnectInteractor.test.ts index 4f0dbe86367..fa75207eea9 100644 --- a/web-api/src/business/useCases/notifications/onConnectInteractor.test.ts +++ b/web-api/src/business/useCases/notifications/onConnectInteractor.test.ts @@ -1,4 +1,5 @@ import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { onConnectInteractor } from './onConnectInteractor'; describe('onConnectInteractor', () => { @@ -7,11 +8,15 @@ describe('onConnectInteractor', () => { const mockEndpoint = 'www.example.com'; it('should save the user connection', async () => { - await onConnectInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - connectionId: mockConnectionId, - endpoint: mockEndpoint, - }); + await onConnectInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + connectionId: mockConnectionId, + endpoint: mockEndpoint, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveUserConnection, @@ -19,13 +24,15 @@ describe('onConnectInteractor', () => { }); it('should NOT save the user connection when the current user is undefined', async () => { - applicationContext.getCurrentUser.mockReturnValue(undefined); - - await onConnectInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - connectionId: mockConnectionId, - endpoint: mockEndpoint, - }); + await onConnectInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + connectionId: mockConnectionId, + endpoint: mockEndpoint, + }, + undefined, + ); expect( applicationContext.getPersistenceGateway().saveUserConnection, diff --git a/web-api/src/business/useCases/notifications/onConnectInteractor.ts b/web-api/src/business/useCases/notifications/onConnectInteractor.ts index d3054da7879..565fdef0b1d 100644 --- a/web-api/src/business/useCases/notifications/onConnectInteractor.ts +++ b/web-api/src/business/useCases/notifications/onConnectInteractor.ts @@ -1,4 +1,5 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const onConnectInteractor = async ( applicationContext: ServerApplicationContext, @@ -7,8 +8,8 @@ export const onConnectInteractor = async ( connectionId, endpoint, }: { clientConnectionId: string; connectionId: string; endpoint: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); if (!authorizedUser) { // silence local development errors return; diff --git a/web-api/src/genericHandler.ts b/web-api/src/genericHandler.ts index 05707e547af..d68fb00a748 100644 --- a/web-api/src/genericHandler.ts +++ b/web-api/src/genericHandler.ts @@ -74,7 +74,10 @@ export const checkMaintenanceMode = async ({ applicationContext }) => { export const genericHandler = ( awsEvent, - cb: (appContext: { applicationContext: ServerApplicationContext }) => any, + cb: (params: { + applicationContext: ServerApplicationContext; + clientConnectionId?: string; + }) => any, user: UnknownAuthUser, options: { bypassMaintenanceCheck?: boolean; diff --git a/web-api/src/lambdas/notifications/connectLambda.ts b/web-api/src/lambdas/notifications/connectLambda.ts index b6c4b0b3e9c..2bc410a702a 100644 --- a/web-api/src/lambdas/notifications/connectLambda.ts +++ b/web-api/src/lambdas/notifications/connectLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { onConnectInteractor } from '@web-api/business/useCases/notifications/onConnectInteractor'; /** * save the information about a new websocket connection @@ -6,19 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const connectLambda = event => +export const connectLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler( event, async ({ applicationContext, clientConnectionId }) => { const endpoint = event.requestContext.domainName; - await applicationContext - .getUseCases() - .onConnectInteractor(applicationContext, { + await onConnectInteractor( + applicationContext, + { clientConnectionId, connectionId: event.requestContext.connectionId, endpoint, - }); + }, + authorizedUser, + ); applicationContext.logger.debug('Websocket connected', { requestId: { @@ -26,5 +30,6 @@ export const connectLambda = event => }, }); }, + authorizedUser, { bypassMaintenanceCheck: true }, ); From 2b02335ad8a27cb6460ad68fd07846b3008278f4 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 14:22:47 -0500 Subject: [PATCH 150/523] 10417: Remove getCurrentUser from completeWorkItemForDocumentSigningAction.ts --- .../actions/completeWorkItemForDocumentSigningAction.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-client/src/presenter/actions/completeWorkItemForDocumentSigningAction.ts b/web-client/src/presenter/actions/completeWorkItemForDocumentSigningAction.ts index 2f3d6c9a480..43577cf5661 100644 --- a/web-client/src/presenter/actions/completeWorkItemForDocumentSigningAction.ts +++ b/web-client/src/presenter/actions/completeWorkItemForDocumentSigningAction.ts @@ -22,8 +22,8 @@ export const completeWorkItemForDocumentSigningAction = async ({ await applicationContext .getUseCases() + // TODO 10417 I removed userId from what was passed in here because it doesn't appear to be used, but want to confirm. .completeWorkItemInteractor(applicationContext, { - userId: applicationContext.getCurrentUser().userId, workItemId: workItemIdToClose, }); } From 3d320404118ab7b6a2325ce414f1e43880bf078a Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 14:48:03 -0500 Subject: [PATCH 151/523] 10417: remove getCurrentUser from getCaseAssociationAction --- .../actions/getCaseAssociationAction.test.ts | 87 +++++++------------ .../actions/getCaseAssociationAction.ts | 2 +- 2 files changed, 31 insertions(+), 58 deletions(-) diff --git a/web-client/src/presenter/actions/getCaseAssociationAction.test.ts b/web-client/src/presenter/actions/getCaseAssociationAction.test.ts index 7088bb410c6..c4b69c976a3 100644 --- a/web-client/src/presenter/actions/getCaseAssociationAction.test.ts +++ b/web-client/src/presenter/actions/getCaseAssociationAction.test.ts @@ -1,10 +1,13 @@ -import { - CASE_STATUS_TYPES, - ROLES, -} from '../../../../shared/src/business/entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { getCaseAssociationAction } from './getCaseAssociationAction'; -import { irsSuperuserUser } from '@shared/test/mockUsers'; +import { + irsPractitionerUser, + irsSuperuserUser, + petitionerUser, + petitionsClerkUser, + privatePractitionerUser, +} from '@shared/test/mockUsers'; import { presenter } from '../presenter-mock'; import { runAction } from '@web-client/presenter/test.cerebral'; @@ -19,8 +22,6 @@ describe('getCaseAssociation', () => { describe('IRS SuperUser', () => { it('should return false for isAssociated and pendingAssociation if the user is an irsSuperuser and service is not allowed on the case', async () => { - applicationContext.getCurrentUser.mockReturnValue(irsSuperuserUser); - const results = await runAction(getCaseAssociationAction, { modules: { presenter, @@ -31,6 +32,7 @@ describe('getCaseAssociation', () => { docketEntries: [{ documentType: 'Petition' }], status: CASE_STATUS_TYPES.new, }, + user: irsSuperuserUser, }, }); @@ -42,8 +44,6 @@ describe('getCaseAssociation', () => { }); it('should return true for isAssociated and false for pendingAssociation if the user is an irsSuperuser and service is allowed for the case', async () => { - applicationContext.getCurrentUser.mockReturnValue(irsSuperuserUser); - const results = await runAction(getCaseAssociationAction, { modules: { presenter, @@ -59,6 +59,7 @@ describe('getCaseAssociation', () => { ], status: CASE_STATUS_TYPES.generalDocket, }, + user: irsSuperuserUser, }, }); @@ -72,11 +73,6 @@ describe('getCaseAssociation', () => { describe('Internal user', () => { it('should return true for isAssociated and false for pendingAssociation if the user is an internal user', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: ROLES.petitionsClerk, - userId: '123', - }); - const results = await runAction(getCaseAssociationAction, { modules: { presenter, @@ -86,6 +82,7 @@ describe('getCaseAssociation', () => { caseDetail: { privatePractitioners: [{ userId: '123' }], }, + user: petitionsClerkUser, }, }); @@ -98,12 +95,6 @@ describe('getCaseAssociation', () => { }); describe('Private Practitioner, Petitioner, IRS Practitioner', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.privatePractitioner, - userId: '123', - }); - }); describe('consolidatedCases', () => {}); describe('nonConsolidatedCases', () => { it('should return that practitioner is associated', async () => { @@ -114,8 +105,11 @@ describe('getCaseAssociation', () => { props: {}, state: { caseDetail: { - privatePractitioners: [{ userId: '123' }], + privatePractitioners: [ + { userId: privatePractitionerUser.userId }, + ], }, + user: privatePractitionerUser, }, }); @@ -140,6 +134,7 @@ describe('getCaseAssociation', () => { caseDetail: { privatePractitioners: [{ userId: 'nothing' }], }, + user: privatePractitionerUser, }, }); @@ -166,6 +161,7 @@ describe('getCaseAssociation', () => { { userId: 'I am very different and not associated' }, ], }, + user: privatePractitionerUser, }, }); @@ -194,6 +190,7 @@ describe('getCaseAssociation', () => { }, ], }, + user: privatePractitionerUser, }, }); @@ -208,10 +205,6 @@ describe('getCaseAssociation', () => { applicationContext .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(false); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: '789', - }); const results = await runAction(getCaseAssociationAction, { modules: { @@ -220,8 +213,9 @@ describe('getCaseAssociation', () => { props: {}, state: { caseDetail: { - irsPractitioners: [{ userId: '789' }], + irsPractitioners: [{ userId: irsPractitionerUser.userId }], }, + user: irsPractitionerUser, }, }); @@ -235,10 +229,6 @@ describe('getCaseAssociation', () => { applicationContext .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(true); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.irsPractitioner, - userId: '789', - }); const results = await runAction(getCaseAssociationAction, { modules: { @@ -249,6 +239,7 @@ describe('getCaseAssociation', () => { caseDetail: { irsPractitioners: [{ userId: '123' }], }, + user: irsPractitionerUser, }, }); @@ -262,10 +253,6 @@ describe('getCaseAssociation', () => { applicationContext .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(false); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '123', - }); const results = await runAction(getCaseAssociationAction, { modules: { @@ -276,10 +263,11 @@ describe('getCaseAssociation', () => { caseDetail: { petitioners: [ { - contactId: '123', + contactId: petitionerUser.userId, }, ], }, + user: petitionerUser, }, }); @@ -293,10 +281,6 @@ describe('getCaseAssociation', () => { applicationContext .getUseCases() .verifyPendingCaseForUserInteractor.mockReturnValue(true); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '789', - }); const results = await runAction(getCaseAssociationAction, { modules: { presenter, @@ -311,6 +295,7 @@ describe('getCaseAssociation', () => { ], userId: '123', }, + user: petitionerUser, }, }); @@ -326,12 +311,7 @@ describe('getCaseAssociation', () => { describe('with CONSOLIDATED_CASES_GROUP_ACCESS_PETITIONER feature flag', () => { describe('Feature Flag On', () => { it('isAssociated should be true when the petitioners userId exists in the consolidated group list', async () => { - const petitionerContactId = '123'; - - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: petitionerContactId, - }); + const petitionerContactId = petitionerUser.userId; const results = await runAction(getCaseAssociationAction, { modules: { @@ -356,6 +336,7 @@ describe('getCaseAssociation', () => { }, ], }, + user: petitionerUser, }, }); @@ -364,12 +345,7 @@ describe('getCaseAssociation', () => { }); it('should return true for isAssociated when and the case is not consolidated', async () => { - const petitionerContactId = '123'; - - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: petitionerContactId, - }); + const petitionerContactId = petitionerUser.userId; const results = await runAction(getCaseAssociationAction, { modules: { @@ -384,6 +360,7 @@ describe('getCaseAssociation', () => { }, ], }, + user: petitionerUser, }, }); @@ -392,12 +369,7 @@ describe('getCaseAssociation', () => { }); it('isDirectlyAssociated should be true when the id of the caseDetail petitioner matches the users id', async () => { - const petitionerContactId = '123'; - - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: petitionerContactId, - }); + const petitionerContactId = petitionerUser.userId; const results = await runAction(getCaseAssociationAction, { modules: { @@ -414,6 +386,7 @@ describe('getCaseAssociation', () => { }, ], }, + user: petitionerUser, }, }); diff --git a/web-client/src/presenter/actions/getCaseAssociationAction.ts b/web-client/src/presenter/actions/getCaseAssociationAction.ts index ee80eca7cc7..a8a8b26e802 100644 --- a/web-client/src/presenter/actions/getCaseAssociationAction.ts +++ b/web-client/src/presenter/actions/getCaseAssociationAction.ts @@ -12,7 +12,7 @@ export const getCaseAssociationAction = async ({ applicationContext, get, }: ActionProps) => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); From a5576aac5bb6fbbbcfddac328338395d396ed496 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 14:56:42 -0500 Subject: [PATCH 152/523] 10417: Remove getCurrentUser from getCompletedMessagesForSectionAction --- .../actions/getCompletedMessagesForSectionAction.test.ts | 8 +++++--- .../actions/getCompletedMessagesForSectionAction.ts | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.test.ts b/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.test.ts index d7350e457c2..fc37bbde565 100644 --- a/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.test.ts +++ b/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.test.ts @@ -2,6 +2,7 @@ import { ADC_SECTION, DOCKET_SECTION, } from '../../../../shared/src/business/entities/EntityConstants'; +import { adcUser } from '@shared/test/mockUsers'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { getCompletedMessagesForSectionAction } from './getCompletedMessagesForSectionAction'; import { presenter } from '../presenter-mock'; @@ -24,7 +25,9 @@ describe('getCompletedMessagesForSectionAction', () => { modules: { presenter, }, - state: {}, + state: { + user: {}, + }, }); expect(results.output.messages).toEqual([message]); }); @@ -50,7 +53,6 @@ describe('getCompletedMessagesForSectionAction', () => { it("retrieves completed messages for the current user's section when state.messageBoxToDisplay.section is undefined", async () => { const currentUserSection = { section: ADC_SECTION }; - applicationContext.getCurrentUser.mockReturnValue(currentUserSection); await runAction(getCompletedMessagesForSectionAction, { modules: { @@ -58,6 +60,7 @@ describe('getCompletedMessagesForSectionAction', () => { }, state: { messageBoxToDisplay: {}, + user: adcUser, }, }); @@ -65,6 +68,5 @@ describe('getCompletedMessagesForSectionAction', () => { applicationContext.getUseCases().getCompletedMessagesForSectionInteractor .mock.calls[0][1], ).toEqual(currentUserSection); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); }); }); diff --git a/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.ts b/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.ts index 955098ef25e..bdc415db836 100644 --- a/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.ts +++ b/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.ts @@ -10,11 +10,12 @@ export const getCompletedMessagesForSectionAction = async ({ get, }: ActionProps) => { const selectedSection = get(state.messageBoxToDisplay.section); + const user = get(state.user); const messages = await applicationContext .getUseCases() .getCompletedMessagesForSectionInteractor(applicationContext, { - section: selectedSection || applicationContext.getCurrentUser().section, + section: selectedSection || user.section, }); return { messages }; From 736acbb3dde23a3ad6c72a1db6a686e0ab45db51 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:02:09 -0500 Subject: [PATCH 153/523] 10417: Remove getCurrentUser from getCompletedMessagesForUserAction --- .../actions/getCompletedMessagesForUserAction.test.ts | 2 +- .../presenter/actions/getCompletedMessagesForUserAction.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/actions/getCompletedMessagesForUserAction.test.ts b/web-client/src/presenter/actions/getCompletedMessagesForUserAction.test.ts index 8dd7a65332e..946ae2ec100 100644 --- a/web-client/src/presenter/actions/getCompletedMessagesForUserAction.test.ts +++ b/web-client/src/presenter/actions/getCompletedMessagesForUserAction.test.ts @@ -20,7 +20,7 @@ describe('getCompletedMessagesForUserAction', () => { modules: { presenter, }, - state: {}, + state: { user: {} }, }); expect(results.output.messages).toEqual([message]); }); diff --git a/web-client/src/presenter/actions/getCompletedMessagesForUserAction.ts b/web-client/src/presenter/actions/getCompletedMessagesForUserAction.ts index e0eb7e766a1..eebe640596d 100644 --- a/web-client/src/presenter/actions/getCompletedMessagesForUserAction.ts +++ b/web-client/src/presenter/actions/getCompletedMessagesForUserAction.ts @@ -1,3 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + /** * fetches the completed messages for the user * @param {object} applicationContext object that contains all the context specific methods @@ -5,11 +7,13 @@ */ export const getCompletedMessagesForUserAction = async ({ applicationContext, + get, }: ActionProps) => { + const user = get(state.user); const messages = await applicationContext .getUseCases() .getCompletedMessagesForUserInteractor(applicationContext, { - userId: applicationContext.getCurrentUser().userId, + userId: user.userId, }); return { messages }; From 1671efd65f730e5d0810c70c255d6a82bf5d2189 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 13:09:49 -0700 Subject: [PATCH 154/523] 10417: migrate away from applicationContext.getCurrentUser --- ...leCourtIssuedDocketEntryInteractor.test.ts | 341 ++++++++++-------- .../fileCourtIssuedDocketEntryInteractor.ts | 4 +- .../fileCourtIssuedDocketEntryLambda.ts | 27 +- 3 files changed, 219 insertions(+), 153 deletions(-) diff --git a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.test.ts b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.test.ts index d854e48b237..0d1be995e20 100644 --- a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.test.ts @@ -12,10 +12,14 @@ import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { fileCourtIssuedDocketEntryInteractor } from './fileCourtIssuedDocketEntryInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('fileCourtIssuedDocketEntryInteractor', () => { let caseRecord; - const mockUserId = applicationContext.getUniqueId(); + const mockUserId = mockDocketClerkUser.userId; const docketClerkUser = { name: 'Emmett Lathrop "Doc" Brown, Ph.D.', role: ROLES.docketClerk, @@ -35,7 +39,6 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); caseRecord = { ...MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE, @@ -82,30 +85,36 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { }); it('should throw an error if not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers: [], - documentMeta: { - docketEntryId: caseRecord.docketEntries[1].docketEntryId, - documentType: 'Memorandum in Support', - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any), + fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers: [], + documentMeta: { + docketEntryId: caseRecord.docketEntries[1].docketEntryId, + documentType: 'Memorandum in Support', + }, + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should throw an error if the document is not found on the case', async () => { await expect( - fileCourtIssuedDocketEntryInteractor(applicationContext, { - documentMeta: { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bd', - docketNumbers: [], - documentType: 'Order', - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any), + fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + documentMeta: { + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bd', + docketNumbers: [], + documentType: 'Order', + }, + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry not found'); }); @@ -113,29 +122,37 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { caseRecord.docketEntries[1].isOnDocketRecord = true; await expect( - fileCourtIssuedDocketEntryInteractor(applicationContext, { + fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers: [], + documentMeta: { + docketEntryId: caseRecord.docketEntries[1].docketEntryId, + documentType: 'Order', + }, + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockDocketClerkUser, + ), + ).rejects.toThrow('Docket entry has already been added to docket record'); + }); + + it('should call countPagesInDocument, updateCase, and saveWorkItem', async () => { + await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { docketNumbers: [], documentMeta: { - docketEntryId: caseRecord.docketEntries[1].docketEntryId, + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + documentTitle: 'Order', documentType: 'Order', + eventCode: 'O', + generatedDocumentTitle: 'Generated Order Document Title', }, subjectDocketNumber: caseRecord.docketNumber, - } as any), - ).rejects.toThrow('Docket entry has already been added to docket record'); - }); - - it('should call countPagesInDocument, updateCase, and saveWorkItem', async () => { - await fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers: [], - documentMeta: { - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - documentTitle: 'Order', - documentType: 'Order', - eventCode: 'O', - generatedDocumentTitle: 'Generated Order Document Title', - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any); + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -146,17 +163,21 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { }); it('should call putWorkItemInUsersOutbox with correct leadDocketNumber when documentType is unservable', async () => { - await fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers: [], - documentMeta: { - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - documentTitle: 'Hearing Exhibits for [anything]', - documentType: 'Hearing Exhibits', - eventCode: 'HE', - generatedDocumentTitle: 'Hearing Exhibits for meeeeeee', - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any); + await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers: [], + documentMeta: { + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + documentTitle: 'Hearing Exhibits for [anything]', + documentType: 'Hearing Exhibits', + eventCode: 'HE', + generatedDocumentTitle: 'Hearing Exhibits for meeeeeee', + }, + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -171,18 +192,22 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { }); it('should call updateCase with the docket entry set as pending if the document is a tracked document', async () => { - await fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers: [], - documentMeta: { - docketEntryId: caseRecord.docketEntries[1].docketEntryId, - documentTitle: 'Order to Show Cause', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - filingDate: '2011-03-01T21:40:46.415Z', - generatedDocumentTitle: 'Generated Order Document Title', - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any); + await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers: [], + documentMeta: { + docketEntryId: caseRecord.docketEntries[1].docketEntryId, + documentTitle: 'Order to Show Cause', + documentType: 'Order to Show Cause', + eventCode: 'OSC', + filingDate: '2011-03-01T21:40:46.415Z', + generatedDocumentTitle: 'Generated Order Document Title', + }, + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -200,20 +225,24 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { }); it('should set isDraft to false on a document when creating a court issued docket entry', async () => { - await fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers: [], - documentMeta: { - date: '2019-03-01T21:40:46.415Z', - docketEntryId: caseRecord.docketEntries[2].docketEntryId, - documentTitle: 'Transcript of [anything] on [date]', - documentType: 'Transcript', - eventCode: TRANSCRIPT_EVENT_CODE, - freeText: 'Dogs', - generatedDocumentTitle: 'Transcript of Dogs on 03-01-19', - isDraft: true, - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any); + await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers: [], + documentMeta: { + date: '2019-03-01T21:40:46.415Z', + docketEntryId: caseRecord.docketEntries[2].docketEntryId, + documentTitle: 'Transcript of [anything] on [date]', + documentType: 'Transcript', + eventCode: TRANSCRIPT_EVENT_CODE, + freeText: 'Dogs', + generatedDocumentTitle: 'Transcript of Dogs on 03-01-19', + isDraft: true, + }, + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockDocketClerkUser, + ); const lastDocumentIndex = applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -230,20 +259,24 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { it('should delete the draftOrderState from the docketEntry', async () => { const docketEntryToUpdate = caseRecord.docketEntries[2]; - await fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers: [], - documentMeta: { - docketEntryId: docketEntryToUpdate.docketEntryId, - documentTitle: docketEntryToUpdate.documentTitle, - documentType: docketEntryToUpdate.documentType, - draftOrderState: { - documentContents: 'Some content', - richText: 'some content', + await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers: [], + documentMeta: { + docketEntryId: docketEntryToUpdate.docketEntryId, + documentTitle: docketEntryToUpdate.documentTitle, + documentType: docketEntryToUpdate.documentType, + draftOrderState: { + documentContents: 'Some content', + richText: 'some content', + }, + eventCode: docketEntryToUpdate.eventCode, }, - eventCode: docketEntryToUpdate.eventCode, - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any); + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockDocketClerkUser, + ); const updatedDocketEntry = applicationContext .getUseCaseHelpers() @@ -255,20 +288,24 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { }); it('should use original case caption to create case title when creating work item', async () => { - await fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers: [], - documentMeta: { - date: '2019-03-01T21:40:46.415Z', - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - documentTitle: 'Order', - documentType: 'Order', - eventCode: 'O', - freeText: 'Dogs', - generatedDocumentTitle: 'Transcript of Dogs on 03-01-19', - serviceStamp: 'Served', - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any); + await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers: [], + documentMeta: { + date: '2019-03-01T21:40:46.415Z', + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + documentTitle: 'Order', + documentType: 'Order', + eventCode: 'O', + freeText: 'Dogs', + generatedDocumentTitle: 'Transcript of Dogs on 03-01-19', + serviceStamp: 'Served', + }, + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem.mock.calls[0][0] @@ -310,17 +347,23 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockResolvedValueOnce(LEAD_CASE); - await fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers: [MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber], - documentMeta: { - docketEntryId: LEAD_CASE.docketEntries[0].docketEntryId, + await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers: [ + MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, + ], + documentMeta: { + docketEntryId: LEAD_CASE.docketEntries[0].docketEntryId, - documentType: 'Trial Exhibits', - eventCode: 'TE', - freeText: 'free text testing', + documentType: 'Trial Exhibits', + eventCode: 'TE', + freeText: 'free text testing', + }, + subjectDocketNumber: LEAD_CASE.docketNumber, }, - subjectDocketNumber: LEAD_CASE.docketNumber, - }); + mockDocketClerkUser, + ); const docketEntryOnNonLead = applicationContext .getUseCaseHelpers() @@ -346,7 +389,32 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { mockLock = MOCK_LOCK; await expect( - fileCourtIssuedDocketEntryInteractor(applicationContext, { + fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers: [], + documentMeta: { + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + documentTitle: 'Order', + documentType: 'Order', + eventCode: 'O', + generatedDocumentTitle: 'Generated Order Document Title', + }, + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockDocketClerkUser, + ), + ).rejects.toThrow(ServiceUnavailableError); + + expect( + applicationContext.getPersistenceGateway().getCaseByDocketNumber, + ).not.toHaveBeenCalled(); + }); + + it('should acquire and remove the lock on the case', async () => { + await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { docketNumbers: [], documentMeta: { docketEntryId: caseRecord.docketEntries[0].docketEntryId, @@ -356,26 +424,9 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { generatedDocumentTitle: 'Generated Order Document Title', }, subjectDocketNumber: caseRecord.docketNumber, - } as any), - ).rejects.toThrow(ServiceUnavailableError); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).not.toHaveBeenCalled(); - }); - - it('should acquire and remove the lock on the case', async () => { - await fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers: [], - documentMeta: { - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - documentTitle: 'Order', - documentType: 'Order', - eventCode: 'O', - generatedDocumentTitle: 'Generated Order Document Title', - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any); + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -395,17 +446,21 @@ describe('fileCourtIssuedDocketEntryInteractor', () => { it('should acquire and remove the lock for every case', async () => { const docketNumbers = ['888-88', '999-99']; - await fileCourtIssuedDocketEntryInteractor(applicationContext, { - docketNumbers, - documentMeta: { - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - documentTitle: 'Order', - documentType: 'Order', - eventCode: 'O', - generatedDocumentTitle: 'Generated Order Document Title', - }, - subjectDocketNumber: caseRecord.docketNumber, - } as any); + await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + docketNumbers, + documentMeta: { + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + documentTitle: 'Order', + documentType: 'Order', + eventCode: 'O', + generatedDocumentTitle: 'Generated Order Document Title', + }, + subjectDocketNumber: caseRecord.docketNumber, + } as any, + mockDocketClerkUser, + ); const expectedIdentifiers = docketNumbers.map( docketNumber => `case|${docketNumber}`, diff --git a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts index d297533c10e..2db1f35ed91 100644 --- a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts @@ -7,6 +7,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; import { omit } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -29,9 +30,8 @@ export const fileCourtIssuedDocketEntry = async ( documentMeta: any; subjectDocketNumber: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - const hasPermission = isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY) || isAuthorized(authorizedUser, ROLE_PERMISSIONS.CREATE_ORDER_DOCKET_ENTRY); diff --git a/web-api/src/lambdas/documents/fileCourtIssuedDocketEntryLambda.ts b/web-api/src/lambdas/documents/fileCourtIssuedDocketEntryLambda.ts index 40976b4a6a3..f9b0768ab92 100644 --- a/web-api/src/lambdas/documents/fileCourtIssuedDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/fileCourtIssuedDocketEntryLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { fileCourtIssuedDocketEntryInteractor } from '@web-api/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const fileCourtIssuedDocketEntryLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .fileCourtIssuedDocketEntryInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const fileCourtIssuedDocketEntryLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From b4a50b1aa0533958348a25993d0f121c0eac209c Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:16:01 -0500 Subject: [PATCH 155/523] 10417: Remove getCurrentUser from getDocumentQCInboxForSectionAction --- ...getDocumentQCInboxForSectionAction.test.ts | 31 ++++++------------- .../getDocumentQCInboxForSectionAction.ts | 2 +- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.test.ts b/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.test.ts index fed4145763b..c02297d0953 100644 --- a/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.test.ts +++ b/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.test.ts @@ -1,3 +1,5 @@ +import { ADC_SECTION } from '@shared/business/entities/EntityConstants'; +import { adcUser } from '@shared/test/mockUsers'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { getDocumentQCInboxForSectionAction } from './getDocumentQCInboxForSectionAction'; import { presenter } from '../presenter-mock'; @@ -5,7 +7,7 @@ import { runAction } from '@web-client/presenter/test.cerebral'; describe('getDocumentQCInboxForSectionAction', () => { const mockWorkItems = [{ docketEntryId: 1 }, { docketEntryId: 2 }]; - const { CHIEF_JUDGE, USER_ROLES } = applicationContext.getConstants(); + const { CHIEF_JUDGE } = applicationContext.getConstants(); beforeAll(() => { applicationContext.getCurrentUser.mockReturnValue({ @@ -17,21 +19,6 @@ describe('getDocumentQCInboxForSectionAction', () => { presenter.providers.applicationContext = applicationContext; }); - it('should retrieve the current user', async () => { - await runAction(getDocumentQCInboxForSectionAction, { - modules: { - presenter, - }, - state: { - judgeUser: { - name: 'A judgy person', - }, - }, - }); - - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it('should call getDocumentQCInboxForSectionInteractor with the judge user from state', async () => { await runAction(getDocumentQCInboxForSectionAction, { modules: { @@ -41,6 +28,9 @@ describe('getDocumentQCInboxForSectionAction', () => { judgeUser: { name: 'A judgy person', }, + user: { + section: 'judgy section', + }, }, }); @@ -63,6 +53,7 @@ describe('getDocumentQCInboxForSectionAction', () => { presenter, }, state: { + user: {}, workQueueToDisplay: { section: mockSection, }, @@ -78,15 +69,11 @@ describe('getDocumentQCInboxForSectionAction', () => { }); it('should call getDocumentQCInboxForSectionInteractor with the CHIEF_JUDGE if judgeUser is not found in state and user role is adc', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: USER_ROLES.adc, - section: 'judgy section', - }); await runAction(getDocumentQCInboxForSectionAction, { modules: { presenter, }, - state: {}, + state: { user: adcUser }, }); expect( @@ -96,7 +83,7 @@ describe('getDocumentQCInboxForSectionAction', () => { judgeUser: { name: CHIEF_JUDGE, }, - section: 'judgy section', + section: ADC_SECTION, }); }); }); diff --git a/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.ts b/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.ts index 460dae40e74..bad33cae3b8 100644 --- a/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.ts +++ b/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.ts @@ -13,7 +13,7 @@ export const getDocumentQCInboxForSectionAction = async ({ const selectedSection = get(state.workQueueToDisplay.section); const { CHIEF_JUDGE, USER_ROLES } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); let judgeUser = get(state.judgeUser); if (!judgeUser && user.role === USER_ROLES.adc) { From 3b9c754adfd88489256be7507fee4cf7b9d653c1 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:19:38 -0500 Subject: [PATCH 156/523] 10417: Remove getCurrentUser from getDocumentQCInboxForUserAction --- .../getDocumentQCInboxForUserAction.test.ts | 20 ++++++------------- .../getDocumentQCInboxForUserAction.ts | 6 +++++- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/web-client/src/presenter/actions/getDocumentQCInboxForUserAction.test.ts b/web-client/src/presenter/actions/getDocumentQCInboxForUserAction.test.ts index 3920cbd0b5b..b1fc3b950d4 100644 --- a/web-client/src/presenter/actions/getDocumentQCInboxForUserAction.test.ts +++ b/web-client/src/presenter/actions/getDocumentQCInboxForUserAction.test.ts @@ -8,10 +8,6 @@ describe('getDocumentQCInboxForUserAction', () => { const mockUserId = '35f77d01-df22-479c-b5a9-84edfbc876af'; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - userId: mockUserId, - }); - applicationContext .getUseCases() .getDocumentQCInboxForUserInteractor.mockReturnValue(mockWorkItems); @@ -19,21 +15,14 @@ describe('getDocumentQCInboxForUserAction', () => { presenter.providers.applicationContext = applicationContext; }); - it('should make a call to get the current user', async () => { - await runAction(getDocumentQCInboxForUserAction, { - modules: { - presenter, - }, - }); - - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it("should make a call to getDocumentQCInboxForUserInteractor with the current user's userId", async () => { await runAction(getDocumentQCInboxForUserAction, { modules: { presenter, }, + state: { + user: { userId: mockUserId }, + }, }); expect( @@ -47,6 +36,9 @@ describe('getDocumentQCInboxForUserAction', () => { modules: { presenter, }, + state: { + user: { userId: mockUserId }, + }, }); expect(output).toEqual({ workItems: mockWorkItems }); diff --git a/web-client/src/presenter/actions/getDocumentQCInboxForUserAction.ts b/web-client/src/presenter/actions/getDocumentQCInboxForUserAction.ts index dc34316eaf2..66d330b540b 100644 --- a/web-client/src/presenter/actions/getDocumentQCInboxForUserAction.ts +++ b/web-client/src/presenter/actions/getDocumentQCInboxForUserAction.ts @@ -1,3 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + /** * fetches the document qc inbox work items for a user, * @param {object} applicationContext object that contains all the context specific methods @@ -5,11 +7,13 @@ */ export const getDocumentQCInboxForUserAction = async ({ applicationContext, + get, }: ActionProps) => { + const user = get(state.user); const workItems = await applicationContext .getUseCases() .getDocumentQCInboxForUserInteractor(applicationContext, { - userId: applicationContext.getCurrentUser().userId, + userId: user.userId, }); return { workItems }; From 31a4b186874b98ef6708fdde7c89c50c51424bef Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:23:02 -0500 Subject: [PATCH 157/523] 10417: removet getCurrentUser from getDocumentQCServedForSectionAction --- ...etDocumentQCServedForSectionAction.test.ts | 27 +++++++++---------- .../getDocumentQCServedForSectionAction.ts | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/web-client/src/presenter/actions/getDocumentQCServedForSectionAction.test.ts b/web-client/src/presenter/actions/getDocumentQCServedForSectionAction.test.ts index cb423cbe01b..c69b36edc2e 100644 --- a/web-client/src/presenter/actions/getDocumentQCServedForSectionAction.test.ts +++ b/web-client/src/presenter/actions/getDocumentQCServedForSectionAction.test.ts @@ -8,10 +8,6 @@ describe('getDocumentQCServedForSectionAction', () => { const mockSection = 'A side section'; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - section: mockSection, - }); - applicationContext .getUseCases() .getDocumentQCServedForSectionInteractor.mockReturnValue(mockWorkItems); @@ -19,21 +15,16 @@ describe('getDocumentQCServedForSectionAction', () => { presenter.providers.applicationContext = applicationContext; }); - it('should make a call to get the current user', async () => { - await runAction(getDocumentQCServedForSectionAction, { - modules: { - presenter, - }, - }); - - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it("should make a call to getDocumentQCServedForSectionInteractor with the current user's section", async () => { await runAction(getDocumentQCServedForSectionAction, { modules: { presenter, }, + state: { + user: { + section: mockSection, + }, + }, }); expect( @@ -49,6 +40,9 @@ describe('getDocumentQCServedForSectionAction', () => { presenter, }, state: { + user: { + section: mockSection, + }, workQueueToDisplay: { section: mockSelectedSection, }, @@ -67,6 +61,11 @@ describe('getDocumentQCServedForSectionAction', () => { modules: { presenter, }, + state: { + user: { + section: mockSection, + }, + }, }); expect(output).toEqual({ workItems: mockWorkItems }); diff --git a/web-client/src/presenter/actions/getDocumentQCServedForSectionAction.ts b/web-client/src/presenter/actions/getDocumentQCServedForSectionAction.ts index a6ae39b7024..46585b9d392 100644 --- a/web-client/src/presenter/actions/getDocumentQCServedForSectionAction.ts +++ b/web-client/src/presenter/actions/getDocumentQCServedForSectionAction.ts @@ -12,7 +12,7 @@ export const getDocumentQCServedForSectionAction = async ({ }: ActionProps) => { const selectedSection = get(state.workQueueToDisplay.section); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const workItems = await applicationContext .getUseCases() .getDocumentQCServedForSectionInteractor(applicationContext, { From 191f41e596fc4b0ec0774da0762f09c198b60e1e Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:26:21 -0500 Subject: [PATCH 158/523] 10417: remove getCurrentUser from getDocumentQCServedForUserAction --- .../getDocumentQCServedForUserAction.test.ts | 24 ++++++++----------- .../getDocumentQCServedForUserAction.ts | 6 ++++- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/web-client/src/presenter/actions/getDocumentQCServedForUserAction.test.ts b/web-client/src/presenter/actions/getDocumentQCServedForUserAction.test.ts index a2b36233ec2..64326c49ddf 100644 --- a/web-client/src/presenter/actions/getDocumentQCServedForUserAction.test.ts +++ b/web-client/src/presenter/actions/getDocumentQCServedForUserAction.test.ts @@ -8,10 +8,6 @@ describe('getDocumentQCServedForUserAction', () => { const mockUserId = 'a2eaa4e5-e6d8-434c-973a-fe9431f84e66'; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - userId: mockUserId, - }); - applicationContext .getUseCases() .getDocumentQCServedForUserInteractor.mockReturnValue(mockWorkItems); @@ -19,21 +15,16 @@ describe('getDocumentQCServedForUserAction', () => { presenter.providers.applicationContext = applicationContext; }); - it('should make a call to get the current user', async () => { - await runAction(getDocumentQCServedForUserAction, { - modules: { - presenter, - }, - }); - - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it("should make a call to getDocumentQCServedForUserInteractor with the current user's userId", async () => { await runAction(getDocumentQCServedForUserAction, { modules: { presenter, }, + state: { + user: { + userId: mockUserId, + }, + }, }); expect( @@ -47,6 +38,11 @@ describe('getDocumentQCServedForUserAction', () => { modules: { presenter, }, + state: { + user: { + userId: mockUserId, + }, + }, }); expect(output).toEqual({ workItems: mockWorkItems }); diff --git a/web-client/src/presenter/actions/getDocumentQCServedForUserAction.ts b/web-client/src/presenter/actions/getDocumentQCServedForUserAction.ts index d0e1dcda4cc..d1697d3368f 100644 --- a/web-client/src/presenter/actions/getDocumentQCServedForUserAction.ts +++ b/web-client/src/presenter/actions/getDocumentQCServedForUserAction.ts @@ -1,3 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + /** * fetches the document qc served work items for a user. * @param {object} applicationContext object that contains all the context specific methods @@ -5,11 +7,13 @@ */ export const getDocumentQCServedForUserAction = async ({ applicationContext, + get, }: ActionProps) => { + const user = get(state.user); const workItems = await applicationContext .getUseCases() .getDocumentQCServedForUserInteractor(applicationContext, { - userId: applicationContext.getCurrentUser().userId, + userId: user.userId, }); return { workItems }; From 86ba984ffd3691a4bffdd3065474109a9329979c Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:32:01 -0500 Subject: [PATCH 159/523] 10417: remove getCurrentUser from getInboxMessagesForSectionAction --- .../actions/getInboxMessagesForSectionAction.test.ts | 7 +++---- .../presenter/actions/getInboxMessagesForSectionAction.ts | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web-client/src/presenter/actions/getInboxMessagesForSectionAction.test.ts b/web-client/src/presenter/actions/getInboxMessagesForSectionAction.test.ts index 9ca44e24d9a..44f14241577 100644 --- a/web-client/src/presenter/actions/getInboxMessagesForSectionAction.test.ts +++ b/web-client/src/presenter/actions/getInboxMessagesForSectionAction.test.ts @@ -24,7 +24,7 @@ describe('getInboxMessagesForSectionAction', () => { modules: { presenter, }, - state: {}, + state: { user: {} }, }); expect(results.output.messages).toEqual([message]); }); @@ -38,6 +38,7 @@ describe('getInboxMessagesForSectionAction', () => { messageBoxToDisplay: { section: DOCKET_SECTION, }, + user: {}, }, }); @@ -45,12 +46,10 @@ describe('getInboxMessagesForSectionAction', () => { applicationContext.getUseCases().getInboxMessagesForSectionInteractor.mock .calls[0][1], ).toEqual({ section: DOCKET_SECTION }); - expect(applicationContext.getCurrentUser).not.toHaveBeenCalled(); }); it("retrieves inbox messages for the current user's section when state.messageBoxToDisplay.section is undefined", async () => { const currentUserSection = { section: ADC_SECTION }; - applicationContext.getCurrentUser.mockReturnValue(currentUserSection); await runAction(getInboxMessagesForSectionAction, { modules: { @@ -58,6 +57,7 @@ describe('getInboxMessagesForSectionAction', () => { }, state: { messageBoxToDisplay: {}, + user: currentUserSection, }, }); @@ -65,6 +65,5 @@ describe('getInboxMessagesForSectionAction', () => { applicationContext.getUseCases().getInboxMessagesForSectionInteractor.mock .calls[0][1], ).toEqual(currentUserSection); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); }); }); diff --git a/web-client/src/presenter/actions/getInboxMessagesForSectionAction.ts b/web-client/src/presenter/actions/getInboxMessagesForSectionAction.ts index 8245356b3a4..59057623686 100644 --- a/web-client/src/presenter/actions/getInboxMessagesForSectionAction.ts +++ b/web-client/src/presenter/actions/getInboxMessagesForSectionAction.ts @@ -10,11 +10,12 @@ export const getInboxMessagesForSectionAction = async ({ get, }: ActionProps) => { const selectedSection = get(state.messageBoxToDisplay.section); + const user = get(state.user); const messages = await applicationContext .getUseCases() .getInboxMessagesForSectionInteractor(applicationContext, { - section: selectedSection || applicationContext.getCurrentUser().section, + section: selectedSection || user.section, }); return { messages }; From 4b1b353a6c2bdf8fc157c2b6121b9e40b78bfaa6 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:33:57 -0500 Subject: [PATCH 160/523] 10417 remove getCurrentUser from getInboxMessagesForUserAction --- .../presenter/actions/getInboxMessagesForUserAction.test.ts | 2 +- .../src/presenter/actions/getInboxMessagesForUserAction.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/actions/getInboxMessagesForUserAction.test.ts b/web-client/src/presenter/actions/getInboxMessagesForUserAction.test.ts index 7559c8e0445..1da8e8b1a55 100644 --- a/web-client/src/presenter/actions/getInboxMessagesForUserAction.test.ts +++ b/web-client/src/presenter/actions/getInboxMessagesForUserAction.test.ts @@ -20,7 +20,7 @@ describe('getInboxMessagesForUserAction', () => { modules: { presenter, }, - state: {}, + state: { user: {} }, }); expect(results.output.messages).toEqual([message]); }); diff --git a/web-client/src/presenter/actions/getInboxMessagesForUserAction.ts b/web-client/src/presenter/actions/getInboxMessagesForUserAction.ts index ec7eb1fb92e..9b1eb61be63 100644 --- a/web-client/src/presenter/actions/getInboxMessagesForUserAction.ts +++ b/web-client/src/presenter/actions/getInboxMessagesForUserAction.ts @@ -1,3 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + /** * fetches the inbox messages for the user * @param {object} applicationContext object that contains all the context specific methods @@ -5,11 +7,13 @@ */ export const getInboxMessagesForUserAction = async ({ applicationContext, + get, }: ActionProps) => { + const user = get(state.user); const messages = await applicationContext .getUseCases() .getInboxMessagesForUserInteractor(applicationContext, { - userId: applicationContext.getCurrentUser().userId, + userId: user.userId, }); return { messages }; From d5ed0d95659231dd723c1adae60bda70af0ce18e Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:36:42 -0500 Subject: [PATCH 161/523] 10417 remove getCurrentUser from getJudgeForCurrentUserAction --- .../actions/getJudgeForCurrentUserAction.test.ts | 13 ++++++++++--- .../actions/getJudgeForCurrentUserAction.ts | 5 ++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/web-client/src/presenter/actions/getJudgeForCurrentUserAction.test.ts b/web-client/src/presenter/actions/getJudgeForCurrentUserAction.test.ts index 39bc92fa6a9..08178abb2b9 100644 --- a/web-client/src/presenter/actions/getJudgeForCurrentUserAction.test.ts +++ b/web-client/src/presenter/actions/getJudgeForCurrentUserAction.test.ts @@ -5,9 +5,6 @@ import { runAction } from '@web-client/presenter/test.cerebral'; describe('getJudgeForCurrentUserAction', () => { beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - userId: '123', - }); presenter.providers.applicationContext = applicationContext; }); @@ -19,6 +16,11 @@ describe('getJudgeForCurrentUserAction', () => { modules: { presenter, }, + state: { + user: { + userId: '123', + }, + }, }); expect( applicationContext.getUseCases().getJudgeInSectionInteractor, @@ -34,6 +36,11 @@ describe('getJudgeForCurrentUserAction', () => { modules: { presenter, }, + state: { + user: { + userId: '123', + }, + }, }); expect(result.output.judgeUser).toBeUndefined(); }); diff --git a/web-client/src/presenter/actions/getJudgeForCurrentUserAction.ts b/web-client/src/presenter/actions/getJudgeForCurrentUserAction.ts index ba0f487c7bf..14e6ca7d61f 100644 --- a/web-client/src/presenter/actions/getJudgeForCurrentUserAction.ts +++ b/web-client/src/presenter/actions/getJudgeForCurrentUserAction.ts @@ -1,12 +1,15 @@ import { RawUser } from '@shared/business/entities/User'; +import { state } from '@web-client/presenter/app.cerebral'; export const getJudgeForCurrentUserAction = async ({ applicationContext, + get, }: ActionProps): Promise<{ judgeUser: RawUser }> => { + const user = get(state.user); const judgeUser = await applicationContext .getUseCases() .getJudgeInSectionInteractor(applicationContext, { - section: applicationContext.getCurrentUser().section, + section: user.section, }); return { judgeUser }; From 9d304663186dd402767c4affde05af3eef40b9f0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 13:41:48 -0700 Subject: [PATCH 162/523] 10417: migrate away from applicationContext.getCurrentUser --- ...eckForReadyForTrialCasesInteractor.test.ts | 41 +++++++++++++------ .../checkForReadyForTrialCasesInteractor.ts | 4 +- .../cases/checkForReadyForTrialCasesLambda.ts | 22 +++++++--- 3 files changed, 48 insertions(+), 19 deletions(-) diff --git a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.test.ts b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.test.ts index c260d4d7cf7..7782a9b3479 100644 --- a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.test.ts +++ b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.test.ts @@ -1,18 +1,14 @@ import { CASE_STATUS_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../shared/src/test/mockLock'; -import { MOCK_USERS } from '../../../../shared/src/test/mockUsers'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { checkForReadyForTrialCasesInteractor } from './checkForReadyForTrialCasesInteractor'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('checkForReadyForTrialCasesInteractor', () => { let mockCasesReadyForTrial; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue( - MOCK_USERS['a7d90c05-f6cd-442c-a168-202db587f16f'], - ); - applicationContext .getPersistenceGateway() .getReadyForTrialCases.mockImplementation(() => mockCasesReadyForTrial); @@ -33,7 +29,10 @@ describe('checkForReadyForTrialCasesInteractor', () => { .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); await expect( - checkForReadyForTrialCasesInteractor(applicationContext), + checkForReadyForTrialCasesInteractor( + applicationContext, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); expect( @@ -51,7 +50,10 @@ describe('checkForReadyForTrialCasesInteractor', () => { mockCasesReadyForTrial = [{ docketNumber: '101-20' }]; await expect( - checkForReadyForTrialCasesInteractor(applicationContext), + checkForReadyForTrialCasesInteractor( + applicationContext, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); expect( @@ -69,7 +71,10 @@ describe('checkForReadyForTrialCasesInteractor', () => { mockCasesReadyForTrial = [{ docketNumber: '101-20' }]; await expect( - checkForReadyForTrialCasesInteractor(applicationContext), + checkForReadyForTrialCasesInteractor( + applicationContext, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); expect( @@ -99,7 +104,10 @@ describe('checkForReadyForTrialCasesInteractor', () => { mockCasesReadyForTrial = [{ docketNumber: '101-20' }]; await expect( - checkForReadyForTrialCasesInteractor(applicationContext), + checkForReadyForTrialCasesInteractor( + applicationContext, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); expect( @@ -137,7 +145,10 @@ describe('checkForReadyForTrialCasesInteractor', () => { ]); await expect( - checkForReadyForTrialCasesInteractor(applicationContext), + checkForReadyForTrialCasesInteractor( + applicationContext, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); expect( @@ -161,7 +172,10 @@ describe('checkForReadyForTrialCasesInteractor', () => { .getPersistenceGateway() .getReadyForTrialCases.mockReturnValue([{ docketNumber: '101-20' }]); - await checkForReadyForTrialCasesInteractor(applicationContext); + await checkForReadyForTrialCasesInteractor( + applicationContext, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -194,7 +208,10 @@ describe('checkForReadyForTrialCasesInteractor', () => { ]); await expect( - checkForReadyForTrialCasesInteractor(applicationContext), + checkForReadyForTrialCasesInteractor( + applicationContext, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); expect(applicationContext.getUtilities().sleep).toHaveBeenCalledTimes(1); expect( diff --git a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts index e3f8ea1970c..10988875966 100644 --- a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts +++ b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts @@ -2,6 +2,7 @@ import { CASE_STATUS_TYPES } from '../../../../shared/src/business/entities/Enti import { Case } from '../../../../shared/src/business/entities/cases/Case'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { ServiceUnavailableError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { acquireLock } from '@web-api/business/useCaseHelper/acquireLock'; import { createISODateString } from '../../../../shared/src/business/utilities/DateHandler'; import { uniqBy } from 'lodash'; @@ -11,6 +12,7 @@ import { uniqBy } from 'lodash'; */ export const checkForReadyForTrialCasesInteractor = async ( applicationContext: ServerApplicationContext, + authorizedUser: UnknownAuthUser, ) => { applicationContext.logger.debug('Time', createISODateString()); @@ -81,7 +83,7 @@ export const checkForReadyForTrialCasesInteractor = async ( if (caseToCheck) { const caseEntity = new Case(caseToCheck, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); if (caseEntity.status === CASE_STATUS_TYPES.generalDocket) { caseEntity.checkForReadyForTrial(); diff --git a/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts b/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts index 4f2d5831d4c..3041945fd65 100644 --- a/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts +++ b/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { checkForReadyForTrialCasesInteractor } from '@web-api/business/useCases/checkForReadyForTrialCasesInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,9 +8,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const checkForReadyForTrialCasesLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .checkForReadyForTrialCasesInteractor(applicationContext); - }); +export const checkForReadyForTrialCasesLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await checkForReadyForTrialCasesInteractor( + applicationContext, + authorizedUser, + ); + }, + authorizedUser, + ); From 41272c6dd00f02b3dbc46d9d78669e75d57aa4a3 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:44:27 -0500 Subject: [PATCH 163/523] 10417 remove getCurrentUser from getNotificationsAction --- .../actions/getNotificationsAction.test.ts | 14 ++++++++++++-- .../presenter/actions/getNotificationsAction.ts | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/web-client/src/presenter/actions/getNotificationsAction.test.ts b/web-client/src/presenter/actions/getNotificationsAction.test.ts index 0bfcbc1579f..3a9366ffe64 100644 --- a/web-client/src/presenter/actions/getNotificationsAction.test.ts +++ b/web-client/src/presenter/actions/getNotificationsAction.test.ts @@ -17,6 +17,9 @@ describe('getNotificationsAction', () => { modules: { presenter, }, + state: { + user: {}, + }, }); expect( @@ -33,6 +36,9 @@ describe('getNotificationsAction', () => { judgeUser: { userId: '123', }, + state: { + user: {}, + }, }, }); @@ -43,6 +49,7 @@ describe('getNotificationsAction', () => { }); it('makes a call to fetch notifications with case services supervisor information when state.messageBoxToDisplay.section is defined', async () => { + const userId = 'this is a user id'; await runAction(getNotificationsAction, { modules: { presenter, @@ -51,6 +58,7 @@ describe('getNotificationsAction', () => { messageBoxToDisplay: { section: DOCKET_SECTION, }, + user: { userId }, }, }); @@ -59,16 +67,18 @@ describe('getNotificationsAction', () => { .calls[0][1].caseServicesSupervisorData, ).toEqual({ section: DOCKET_SECTION, - userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', + userId, }); }); it('makes a call to fetch notifications with case services supervisor information when state.workQueueToDisplay.section is defined', async () => { + const userId = 'this is a user id'; await runAction(getNotificationsAction, { modules: { presenter, }, state: { + user: { userId }, workQueueToDisplay: { section: DOCKET_SECTION, }, @@ -80,7 +90,7 @@ describe('getNotificationsAction', () => { .calls[0][1].caseServicesSupervisorData, ).toEqual({ section: DOCKET_SECTION, - userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', + userId, }); }); }); diff --git a/web-client/src/presenter/actions/getNotificationsAction.ts b/web-client/src/presenter/actions/getNotificationsAction.ts index 14df5bc349d..bebe58a2320 100644 --- a/web-client/src/presenter/actions/getNotificationsAction.ts +++ b/web-client/src/presenter/actions/getNotificationsAction.ts @@ -16,12 +16,14 @@ export const getNotificationsAction = async ({ get(state.messageBoxToDisplay.section) || get(state.workQueueToDisplay.section); + const user = get(state.user); + let caseServicesSupervisorData; if (sectionToDisplay) { caseServicesSupervisorData = { section: sectionToDisplay, - userId: applicationContext.getCurrentUser().userId, + userId: user.userId, }; } From ef20fbe5ab57e78c9b8cf80cf51ee1e90976506e Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:47:21 -0500 Subject: [PATCH 164/523] 10417 remove getCurrentUser from getOutboxMessagesForSectionAction --- .../actions/getOutboxMessagesForSectionAction.test.ts | 9 +++++---- .../actions/getOutboxMessagesForSectionAction.ts | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/web-client/src/presenter/actions/getOutboxMessagesForSectionAction.test.ts b/web-client/src/presenter/actions/getOutboxMessagesForSectionAction.test.ts index eabff2a06f3..a1c494ceba8 100644 --- a/web-client/src/presenter/actions/getOutboxMessagesForSectionAction.test.ts +++ b/web-client/src/presenter/actions/getOutboxMessagesForSectionAction.test.ts @@ -24,7 +24,9 @@ describe('getOutboxMessagesForSectionAction', () => { modules: { presenter, }, - state: {}, + state: { + user: {}, + }, }); expect(results.output.messages).toEqual([message]); }); @@ -38,6 +40,7 @@ describe('getOutboxMessagesForSectionAction', () => { messageBoxToDisplay: { section: DOCKET_SECTION, }, + user: {}, }, }); @@ -45,12 +48,10 @@ describe('getOutboxMessagesForSectionAction', () => { applicationContext.getUseCases().getOutboxMessagesForSectionInteractor .mock.calls[0][1], ).toEqual({ section: DOCKET_SECTION }); - expect(applicationContext.getCurrentUser).not.toHaveBeenCalled(); }); it("retrieves sent messages for the current user's section when state.messageBoxToDisplay.section is undefined", async () => { const currentUserSection = { section: ADC_SECTION }; - applicationContext.getCurrentUser.mockReturnValue(currentUserSection); await runAction(getOutboxMessagesForSectionAction, { modules: { @@ -58,6 +59,7 @@ describe('getOutboxMessagesForSectionAction', () => { }, state: { messageBoxToDisplay: {}, + user: currentUserSection, }, }); @@ -65,6 +67,5 @@ describe('getOutboxMessagesForSectionAction', () => { applicationContext.getUseCases().getOutboxMessagesForSectionInteractor .mock.calls[0][1], ).toEqual(currentUserSection); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); }); }); diff --git a/web-client/src/presenter/actions/getOutboxMessagesForSectionAction.ts b/web-client/src/presenter/actions/getOutboxMessagesForSectionAction.ts index 1a83d09c416..c099d40f659 100644 --- a/web-client/src/presenter/actions/getOutboxMessagesForSectionAction.ts +++ b/web-client/src/presenter/actions/getOutboxMessagesForSectionAction.ts @@ -10,11 +10,12 @@ export const getOutboxMessagesForSectionAction = async ({ get, }: ActionProps) => { const selectedSection = get(state.messageBoxToDisplay.section); + const user = get(state.user); const messages = await applicationContext .getUseCases() .getOutboxMessagesForSectionInteractor(applicationContext, { - section: selectedSection || applicationContext.getCurrentUser().section, + section: selectedSection || user.section, }); return { messages }; From 9b6fb9ff87a46bff1f0fe43a058fdb4ae9212f50 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:48:57 -0500 Subject: [PATCH 165/523] 10417 remove getCurrentUser from getOutboxMessagesForUserAction --- .../actions/getOutboxMessagesForUserAction.test.ts | 2 +- .../src/presenter/actions/getOutboxMessagesForUserAction.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/actions/getOutboxMessagesForUserAction.test.ts b/web-client/src/presenter/actions/getOutboxMessagesForUserAction.test.ts index 642e7542df1..2ff90ce8ba7 100644 --- a/web-client/src/presenter/actions/getOutboxMessagesForUserAction.test.ts +++ b/web-client/src/presenter/actions/getOutboxMessagesForUserAction.test.ts @@ -20,7 +20,7 @@ describe('getOutboxMessagesForUserAction', () => { modules: { presenter, }, - state: {}, + state: { user: {} }, }); expect(results.output.messages).toEqual([message]); }); diff --git a/web-client/src/presenter/actions/getOutboxMessagesForUserAction.ts b/web-client/src/presenter/actions/getOutboxMessagesForUserAction.ts index e9be1dd3ddb..b4c7056c8c0 100644 --- a/web-client/src/presenter/actions/getOutboxMessagesForUserAction.ts +++ b/web-client/src/presenter/actions/getOutboxMessagesForUserAction.ts @@ -1,3 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + /** * fetches the outbox messages for the user * @param {object} applicationContext object that contains all the context specific methods @@ -5,11 +7,13 @@ */ export const getOutboxMessagesForUserAction = async ({ applicationContext, + get, }: ActionProps) => { + const user = get(state.user); const messages = await applicationContext .getUseCases() .getOutboxMessagesForUserInteractor(applicationContext, { - userId: applicationContext.getCurrentUser().userId, + userId: user.userId, }); return { messages }; From 81087daac26fcf4a79f7a170e961431893c0d212 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:53:05 -0500 Subject: [PATCH 166/523] 10417 remove getCurrentUser from getShouldMarkMessageAsReadAction --- .../getShouldMarkMessageAsReadAction.test.ts | 27 ++++++++++++------- .../getShouldMarkMessageAsReadAction.ts | 6 +++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/web-client/src/presenter/actions/getShouldMarkMessageAsReadAction.test.ts b/web-client/src/presenter/actions/getShouldMarkMessageAsReadAction.test.ts index f4c5b2cae32..923a953e929 100644 --- a/web-client/src/presenter/actions/getShouldMarkMessageAsReadAction.test.ts +++ b/web-client/src/presenter/actions/getShouldMarkMessageAsReadAction.test.ts @@ -17,9 +17,7 @@ describe('getShouldMarkMessageAsReadAction', () => { }); it('should return the markRead path if the message is unread and belongs to the current user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - userId: '123', - }); + const userId = '123'; await runAction(getShouldMarkMessageAsReadAction, { modules: { @@ -31,21 +29,22 @@ describe('getShouldMarkMessageAsReadAction', () => { toUserId: '123', }, }, + state: { + user: { userId }, + }, }); expect(markReadStub.mock.calls.length).toEqual(1); expect(markReadStub).toHaveBeenCalledWith({ messageToMarkRead: { isRead: false, - toUserId: '123', + toUserId: userId, }, }); }); it('should return the noAction path the message is already read', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - userId: '123', - }); + const userId = '123'; await runAction(getShouldMarkMessageAsReadAction, { modules: { @@ -57,15 +56,18 @@ describe('getShouldMarkMessageAsReadAction', () => { toUserId: '123', }, }, + state: { + user: { + userId, + }, + }, }); expect(noActionStub.mock.calls.length).toEqual(1); }); it('should return the noAction path the message is not assigned to the current user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - userId: '123', - }); + const userId = '123'; await runAction(getShouldMarkMessageAsReadAction, { modules: { @@ -77,6 +79,11 @@ describe('getShouldMarkMessageAsReadAction', () => { toUserId: '321', }, }, + state: { + user: { + userId, + }, + }, }); expect(noActionStub.mock.calls.length).toEqual(1); diff --git a/web-client/src/presenter/actions/getShouldMarkMessageAsReadAction.ts b/web-client/src/presenter/actions/getShouldMarkMessageAsReadAction.ts index 71e5935adae..ffa8ab53c4e 100644 --- a/web-client/src/presenter/actions/getShouldMarkMessageAsReadAction.ts +++ b/web-client/src/presenter/actions/getShouldMarkMessageAsReadAction.ts @@ -1,3 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + /** * returns the path based on whether the message should be marked as read * @param {object} providers the providers object @@ -7,11 +9,11 @@ * @returns {object} continue path for the sequence */ export const getShouldMarkMessageAsReadAction = ({ - applicationContext, + get, path, props, }: ActionProps) => { - const { userId } = applicationContext.getCurrentUser(); + const { userId } = get(state.user); const { mostRecentMessage } = props; if (mostRecentMessage.toUserId === userId && !mostRecentMessage.isRead) { From 2ff7c4262ba173d841d31b93ae5580824516cd59 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 15:58:39 -0500 Subject: [PATCH 167/523] 10417 remove getCurrentUser from getUsersInSectionAction --- .../src/presenter/actions/getUsersInSectionAction.test.ts | 3 +++ web-client/src/presenter/actions/getUsersInSectionAction.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web-client/src/presenter/actions/getUsersInSectionAction.test.ts b/web-client/src/presenter/actions/getUsersInSectionAction.test.ts index 1b41edb5055..e35612cef41 100644 --- a/web-client/src/presenter/actions/getUsersInSectionAction.test.ts +++ b/web-client/src/presenter/actions/getUsersInSectionAction.test.ts @@ -64,6 +64,9 @@ describe('getUsersInSectionAction', () => { modules: { presenter, }, + state: { + user: { section: mockSection }, + }, }); expect( diff --git a/web-client/src/presenter/actions/getUsersInSectionAction.ts b/web-client/src/presenter/actions/getUsersInSectionAction.ts index 065c763d6e4..8356721879e 100644 --- a/web-client/src/presenter/actions/getUsersInSectionAction.ts +++ b/web-client/src/presenter/actions/getUsersInSectionAction.ts @@ -1,10 +1,12 @@ import { RawUser } from '@shared/business/entities/User'; import { sortBy } from 'lodash'; +import { state } from '@web-client/presenter/app.cerebral'; export const getUsersInSectionAction = ({ section }: { section?: string }) => async ({ applicationContext, + get, props, }: ActionProps<{ section: string; @@ -23,7 +25,7 @@ export const getUsersInSectionAction = } if (!sectionToGet) { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); sectionToGet = user.section; } From 4a2ea43372301084c2d54a250d3692d840c6560e Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:00:59 -0500 Subject: [PATCH 168/523] 10417: remove getCurrentUser from isInternalUserAction --- .../actions/isInternalUserAction.test.ts | 19 ++++++++++--------- .../presenter/actions/isInternalUserAction.ts | 5 ++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/web-client/src/presenter/actions/isInternalUserAction.test.ts b/web-client/src/presenter/actions/isInternalUserAction.test.ts index 16549faf052..34e31442a54 100644 --- a/web-client/src/presenter/actions/isInternalUserAction.test.ts +++ b/web-client/src/presenter/actions/isInternalUserAction.test.ts @@ -18,29 +18,30 @@ describe('isInternalUserAction', () => { }); it('should call path.yes if the user is an internal user', async () => { - presenter.providers.applicationContext.getCurrentUser = () => ({ - role: ROLES.docketClerk, - }); - await runAction(isInternalUserAction, { modules: { presenter, }, - state: {}, + state: { + user: { + role: ROLES.docketClerk, + }, + }, }); expect(yesStub).toHaveBeenCalled(); }); it('should call the path.no if the user is an external user', async () => { - presenter.providers.applicationContext.getCurrentUser = () => ({ - role: ROLES.petitioner, - }); await runAction(isInternalUserAction, { modules: { presenter, }, - state: {}, + state: { + user: { + role: ROLES.petitioner, + }, + }, }); expect(noStub).toHaveBeenCalled(); diff --git a/web-client/src/presenter/actions/isInternalUserAction.ts b/web-client/src/presenter/actions/isInternalUserAction.ts index 61a028d16ea..7200330b576 100644 --- a/web-client/src/presenter/actions/isInternalUserAction.ts +++ b/web-client/src/presenter/actions/isInternalUserAction.ts @@ -1,3 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + /** * takes a path depending on if the user an internal user * @param {object} providers the providers object @@ -6,9 +8,10 @@ */ export const isInternalUserAction = ({ applicationContext, + get, path, }: ActionProps) => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); return applicationContext.getUtilities().isInternalUser(user.role) ? path.yes() : path.no(); From 4316d32681d4907e2c0d5849f73645b56c7d0df2 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:02:45 -0500 Subject: [PATCH 169/523] 10417: remove getCurrentUser from passAlongJudgeUserAction --- .../src/presenter/actions/passAlongJudgeUserAction.test.ts | 5 +++-- web-client/src/presenter/actions/passAlongJudgeUserAction.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/web-client/src/presenter/actions/passAlongJudgeUserAction.test.ts b/web-client/src/presenter/actions/passAlongJudgeUserAction.test.ts index 70d6d5258fd..c3d59aea771 100644 --- a/web-client/src/presenter/actions/passAlongJudgeUserAction.test.ts +++ b/web-client/src/presenter/actions/passAlongJudgeUserAction.test.ts @@ -8,13 +8,14 @@ describe('passAlongJudgeUserAction', () => { presenter.providers.applicationContext = applicationContext; it('should call the setItemInteractor to persists the tab and form', async () => { - applicationContext.getCurrentUser.mockReturnValue(judgeUser); - const { output } = await runAction(passAlongJudgeUserAction, { modules: { presenter, }, props: {}, + state: { + user: judgeUser, + }, }); expect(output.judgeUser).toEqual(judgeUser); diff --git a/web-client/src/presenter/actions/passAlongJudgeUserAction.ts b/web-client/src/presenter/actions/passAlongJudgeUserAction.ts index 159c770eea0..04bc6d64a78 100644 --- a/web-client/src/presenter/actions/passAlongJudgeUserAction.ts +++ b/web-client/src/presenter/actions/passAlongJudgeUserAction.ts @@ -1,8 +1,9 @@ import { RawUser } from '@shared/business/entities/User'; import { cloneDeep } from 'lodash'; +import { state } from '@web-client/presenter/app.cerebral'; export const passAlongJudgeUserAction = ({ - applicationContext, + get, }: ActionProps): { judgeUser: RawUser } => { - return { judgeUser: cloneDeep(applicationContext.getCurrentUser()) }; + return { judgeUser: cloneDeep(get(state.user)) }; }; From 918cc8c46b8865d264e2f8e33feabbda5725a9da Mon Sep 17 00:00:00 2001 From: Jim Lerza Date: Thu, 11 Jul 2024 17:03:02 -0400 Subject: [PATCH 170/523] 10417: removed getCurrentUser in getJudgeInSectionInteractor --- .../user/getJudgeInSectionInteractor.test.ts | 32 +++++++++--------- .../user/getJudgeInSectionInteractor.ts | 17 +++------- .../lambdas/users/getJudgeInSectionLambda.ts | 33 +++++++++++-------- 3 files changed, 39 insertions(+), 43 deletions(-) diff --git a/web-api/src/business/useCases/user/getJudgeInSectionInteractor.test.ts b/web-api/src/business/useCases/user/getJudgeInSectionInteractor.test.ts index 9b342dd76d3..0f929d1dad4 100644 --- a/web-api/src/business/useCases/user/getJudgeInSectionInteractor.test.ts +++ b/web-api/src/business/useCases/user/getJudgeInSectionInteractor.test.ts @@ -1,6 +1,6 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; -import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { applicationContext } from '@shared/business/test/createTestApplicationContext'; import { getJudgeInSectionInteractor } from './getJudgeInSectionInteractor'; +import { mockJudgeUser, mockPetitionerUser } from '@shared/test/mockAuthUsers'; describe('getJudgeInSectionInteractor', () => { beforeEach(() => { @@ -12,26 +12,26 @@ describe('getJudgeInSectionInteractor', () => { }); it('throws an exception if a petitioner tries to get the judge of a section', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - }); - await expect(() => - getJudgeInSectionInteractor(applicationContext, { - section: 'buchsChambers', - }), + getJudgeInSectionInteractor( + applicationContext, + { + section: 'buchsChambers', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('returns the correct judge returned from the helper', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.judge, - }); - expect( - await getJudgeInSectionInteractor(applicationContext, { - section: 'buchsChambers', - }), + await getJudgeInSectionInteractor( + applicationContext, + { + section: 'buchsChambers', + }, + mockJudgeUser, + ), ).toEqual({ judgeName: 'buch', }); diff --git a/web-api/src/business/useCases/user/getJudgeInSectionInteractor.ts b/web-api/src/business/useCases/user/getJudgeInSectionInteractor.ts index e5d070bbbbf..f933bd16ec8 100644 --- a/web-api/src/business/useCases/user/getJudgeInSectionInteractor.ts +++ b/web-api/src/business/useCases/user/getJudgeInSectionInteractor.ts @@ -1,27 +1,18 @@ import { ROLE_PERMISSIONS, isAuthorized, -} from '../../../../../shared/src/authorization/authorizationClientService'; +} from '@shared/authorization/authorizationClientService'; import { RawUser } from '@shared/business/entities/User'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; - -/** - * getJudgeInSectionInteractor - returns the judge user for a given section - * - * @param {object} applicationContext the application context - * @param {object} obj the options object - * @param {string} obj.section the section to fetch the judge from - * @returns {User} the judge user in this section provided - */ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const getJudgeInSectionInteractor = async ( applicationContext: ServerApplicationContext, { section }: { section: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.GET_USERS_IN_SECTION)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.GET_USERS_IN_SECTION)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/users/getJudgeInSectionLambda.ts b/web-api/src/lambdas/users/getJudgeInSectionLambda.ts index 8156c0360b9..a9242df3f40 100644 --- a/web-api/src/lambdas/users/getJudgeInSectionLambda.ts +++ b/web-api/src/lambdas/users/getJudgeInSectionLambda.ts @@ -1,16 +1,21 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getJudgeInSectionInteractor } from '@web-api/business/useCases/user/getJudgeInSectionInteractor'; -/** - * returns the judge associated with a chambers section - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const getJudgeInSectionLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getJudgeInSectionInteractor(applicationContext, { - section: event.pathParameters.section, - }); - }); +export const getJudgeInSectionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await getJudgeInSectionInteractor( + applicationContext, + { + section: event.pathParameters.section, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From cc3bacb7b6a45b504d3667793a26029d69307cf7 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:06:19 -0500 Subject: [PATCH 171/523] 10417: remove getCurrentUser from runPathForUserRoleAction --- .../actions/runPathForUserRoleAction.test.ts | 63 ++++++++++--------- .../actions/runPathForUserRoleAction.ts | 9 ++- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/web-client/src/presenter/actions/runPathForUserRoleAction.test.ts b/web-client/src/presenter/actions/runPathForUserRoleAction.test.ts index 92b5d34deab..579d771a0e5 100644 --- a/web-client/src/presenter/actions/runPathForUserRoleAction.test.ts +++ b/web-client/src/presenter/actions/runPathForUserRoleAction.test.ts @@ -36,93 +36,100 @@ describe('runPathForUserRoleAction', () => { }); it('should throw an exception for unrecognized roles', async () => { - presenter.providers.applicationContext.getCurrentUser = () => ({ - role: 'bananas', - }); await expect( runAction(runPathForUserRoleAction, { modules: { presenter, }, - state: {}, + state: { + user: { + role: 'bananas', + }, + }, }), ).rejects.toThrow(); }); it('should return the petitioner path for user role petitioner', async () => { - presenter.providers.applicationContext.getCurrentUser = () => ({ - role: ROLES.petitioner, - }); await runAction(runPathForUserRoleAction, { modules: { presenter, }, - state: {}, + state: { + user: { + role: ROLES.petitioner, + }, + }, }); expect(petitionerStub.mock.calls.length).toEqual(1); }); it('should return the privatePractitioner path for user role privatePractitioner', async () => { - presenter.providers.applicationContext.getCurrentUser = () => ({ - role: ROLES.privatePractitioner, - }); await runAction(runPathForUserRoleAction, { modules: { presenter, }, - state: {}, + state: { + user: { + role: ROLES.privatePractitioner, + }, + }, }); expect(privatePractitionerStub.mock.calls.length).toEqual(1); }); it('should return the irsPractitioner path for user role irsPractitioner', async () => { - presenter.providers.applicationContext.getCurrentUser = () => ({ - role: ROLES.irsPractitioner, - }); await runAction(runPathForUserRoleAction, { modules: { presenter, }, - state: {}, + state: { + user: { + role: ROLES.irsPractitioner, + }, + }, }); expect(irsPractitionerStub.mock.calls.length).toEqual(1); }); it('should return the petitionsclerk path for user role petitionsclerk', async () => { - presenter.providers.applicationContext.getCurrentUser = () => ({ - role: ROLES.petitionsClerk, - }); await runAction(runPathForUserRoleAction, { modules: { presenter, }, - state: {}, + state: { + user: { + role: ROLES.petitionsClerk, + }, + }, }); expect(petitionsclerkStub.mock.calls.length).toEqual(1); }); it('should return the docketclerk path for user role docketclerk', async () => { - presenter.providers.applicationContext.getCurrentUser = () => ({ - role: ROLES.docketClerk, - }); await runAction(runPathForUserRoleAction, { modules: { presenter, }, - state: {}, + state: { + user: { + role: ROLES.docketClerk, + }, + }, }); expect(docketclerkStub.mock.calls.length).toEqual(1); }); it('should return the judge path for user role judge', async () => { - presenter.providers.applicationContext.getCurrentUser = () => ({ - role: ROLES.judge, - }); await runAction(runPathForUserRoleAction, { modules: { presenter, }, - state: {}, + state: { + user: { + role: ROLES.judge, + }, + }, }); expect(judgeStub.mock.calls.length).toEqual(1); }); diff --git a/web-client/src/presenter/actions/runPathForUserRoleAction.ts b/web-client/src/presenter/actions/runPathForUserRoleAction.ts index 7698bb42f24..460fbcd1253 100644 --- a/web-client/src/presenter/actions/runPathForUserRoleAction.ts +++ b/web-client/src/presenter/actions/runPathForUserRoleAction.ts @@ -1,3 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + /** * get the role associated with the user * @param {object} providers the providers object @@ -5,11 +7,8 @@ * @param {object} providers.path the cerebral path object used for invoking the next path in the sequence based on the user's role * @returns {object} the path to call based on the user role */ -export const runPathForUserRoleAction = ({ - applicationContext, - path, -}: ActionProps) => { - const user = applicationContext.getCurrentUser(); +export const runPathForUserRoleAction = ({ get, path }: ActionProps) => { + const user = get(state.user); if (typeof path[user.role] !== 'function') { throw new Error(`No path available for ${JSON.stringify(user)}`); From 78f1077d4d3ec04d780ca3e67d8805ef6ef12a07 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:06:58 -0500 Subject: [PATCH 172/523] 10417: don't forget integration tests --- .../sentWorkItemsExpireAfterNDays.test.ts | 26 ++++++++++--------- .../servedWorkItemsExpireAfter7Days.test.ts | 20 ++++++++------ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/web-client/integration-tests/sentWorkItemsExpireAfterNDays.test.ts b/web-client/integration-tests/sentWorkItemsExpireAfterNDays.test.ts index c7c781938b5..73a53012dc6 100644 --- a/web-client/integration-tests/sentWorkItemsExpireAfterNDays.test.ts +++ b/web-client/integration-tests/sentWorkItemsExpireAfterNDays.test.ts @@ -1,7 +1,4 @@ -import { - CASE_STATUS_TYPES, - ROLES, -} from '../../shared/src/business/entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '../../shared/src/business/entities/EntityConstants'; import { createApplicationContext as applicationContextFactory } from '../../web-api/src/applicationContext'; import { getFormattedDocumentQCMyOutbox, @@ -10,6 +7,7 @@ import { setupTest, uploadPetition, } from './helpers'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; describe('verify old sent work items do not show up in the outbox', () => { const cerebralTest = setupTest(); @@ -31,11 +29,12 @@ describe('verify old sent work items do not show up in the outbox', () => { caseDetail = await uploadPetition(cerebralTest); expect(caseDetail.docketNumber).toBeDefined(); - const applicationContext = applicationContextFactory({ - role: ROLES.petitionsClerk, - section: 'petitions', + const mockUser = { + ...mockPetitionsClerkUser, userId: '3805d1ab-18d0-43ec-bafb-654e83405416', - }); + }; + + const applicationContext = applicationContextFactory(mockUser); applicationContext.environment.dynamoDbTableName = 'efcms-local'; const daysToRetrieveKey = applicationContext.getConstants().CONFIGURATION_ITEM_KEYS @@ -62,12 +61,12 @@ describe('verify old sent work items do not show up in the outbox', () => { workItemIdNPlus1 = applicationContext.getUniqueId(); workItemNPlus1Days = { - assigneeId: '3805d1ab-18d0-43ec-bafb-654e83405416', + assigneeId: mockUser.userId, assigneeName: 'Test petitionsclerk1', caseStatus: CASE_STATUS_TYPES.new, completedAt: CREATED_N_PLUS_1_DAYS_AGO, completedBy: 'Test Petitionsclerk', - completedByUserId: '3805d1ab-18d0-43ec-bafb-654e83405416', + completedByUserId: mockUser.userId, createdAt: CREATED_N_PLUS_1_DAYS_AGO, docketEntry: { createdAt: '2019-06-25T15:14:11.924Z', @@ -80,7 +79,7 @@ describe('verify old sent work items do not show up in the outbox', () => { section: 'petitions', sentBy: 'Test petitionsclerk1', sentBySection: 'petitions', - sentByUserId: '3805d1ab-18d0-43ec-bafb-654e83405416', + sentByUserId: mockUser.userId, updatedAt: '2019-06-26T16:31:17.643Z', workItemId: `${workItemIdNPlus1}`, }; @@ -101,23 +100,26 @@ describe('verify old sent work items do not show up in the outbox', () => { await applicationContext.getPersistenceGateway().putWorkItemInOutbox({ applicationContext, + authorizedUser: mockUser, workItem: workItemNPlus1Days, }); await applicationContext.getPersistenceGateway().putWorkItemInOutbox({ applicationContext, + authorizedUser: mockUser, workItem: workItemNDays, }); await applicationContext.getPersistenceGateway().putWorkItemInOutbox({ applicationContext, + authorizedUser: mockUser, workItem: workItemNMinus1Days, }); }); loginAs(cerebralTest, 'petitionsclerk@example.com'); - it('the petitionsclerk user should have the expected work items equal to or new than 7 days', async () => { + it('the petitionsclerk user should have the expected work items equal to or newer than 7 days', async () => { const myOutbox = ( await getFormattedDocumentQCMyOutbox(cerebralTest) ).filter(item => item.docketNumber === caseDetail.docketNumber); diff --git a/web-client/integration-tests/servedWorkItemsExpireAfter7Days.test.ts b/web-client/integration-tests/servedWorkItemsExpireAfter7Days.test.ts index 2d97f595855..0ada36c34ab 100644 --- a/web-client/integration-tests/servedWorkItemsExpireAfter7Days.test.ts +++ b/web-client/integration-tests/servedWorkItemsExpireAfter7Days.test.ts @@ -7,12 +7,12 @@ import { setupTest, uploadPetition, } from './helpers'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; const { IRS_SYSTEM_SECTION, PETITIONS_SECTION, STATUS_TYPES: CASE_STATUS_TYPES, - USER_ROLES: ROLES, } = applicationContext.getConstants(); const cerebralTest = setupTest(); @@ -37,11 +37,12 @@ describe('verify old served work items do not show up in the outbox', () => { caseDetail = await uploadPetition(cerebralTest); expect(caseDetail.docketNumber).toBeDefined(); - const appContext = applicationContextFactory({ - role: ROLES.petitionsClerk, - section: PETITIONS_SECTION, + const mockUser = { + ...mockPetitionsClerkUser, userId: '3805d1ab-18d0-43ec-bafb-654e83405416', - }); + }; + + const appContext = applicationContextFactory(mockUser); appContext.environment.dynamoDbTableName = 'efcms-local'; const CREATED_8_DAYS_AGO = applicationContext @@ -59,11 +60,11 @@ describe('verify old served work items do not show up in the outbox', () => { workItemId8 = appContext.getUniqueId(); workItem8Days = { - assigneeId: '3805d1ab-18d0-43ec-bafb-654e83405416', + assigneeId: mockUser.userId, assigneeName: 'Test petitionsclerk1', caseStatus: CASE_STATUS_TYPES.new, completedAt: '2019-06-26T16:31:17.643Z', - completedByUserId: '3805d1ab-18d0-43ec-bafb-654e83405416', + completedByUserId: mockUser.userId, createdAt: CREATED_8_DAYS_AGO, docketEntry: { createdAt: '2019-06-25T15:14:11.924Z', @@ -76,7 +77,7 @@ describe('verify old served work items do not show up in the outbox', () => { section: IRS_SYSTEM_SECTION, sentBy: 'Test petitionsclerk1', sentBySection: PETITIONS_SECTION, - sentByUserId: '3805d1ab-18d0-43ec-bafb-654e83405416', + sentByUserId: mockUser.userId, updatedAt: '2019-06-26T16:31:17.643Z', workItemId: `${workItemId8}`, }; @@ -97,16 +98,19 @@ describe('verify old served work items do not show up in the outbox', () => { await appContext.getPersistenceGateway().putWorkItemInOutbox({ applicationContext: appContext, + authorizedUser: mockUser, workItem: workItem8Days, }); await appContext.getPersistenceGateway().putWorkItemInOutbox({ applicationContext: appContext, + authorizedUser: mockUser, workItem: workItem7Days, }); await appContext.getPersistenceGateway().putWorkItemInOutbox({ applicationContext: appContext, + authorizedUser: mockUser, workItem: workItem6Days, }); }); From 2e8c9248b5a87341b071ad896bc382403f1f1fe8 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:10:38 -0500 Subject: [PATCH 173/523] 10417: re-commit: putWorkItemInOutbox --- .../workItems/completeWorkItemInteractor.ts | 1 + .../dynamo/workitems/putWorkItemInOutbox.test.ts | 7 +++---- .../dynamo/workitems/putWorkItemInOutbox.ts | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts index cd484d5a40a..68fe7a6b2e7 100644 --- a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts +++ b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts @@ -52,6 +52,7 @@ export const completeWorkItem = async ( await applicationContext.getPersistenceGateway().putWorkItemInOutbox({ applicationContext, + authorizedUser: user, workItem: { ...completedWorkItem, createdAt: createISODateString(), diff --git a/web-api/src/persistence/dynamo/workitems/putWorkItemInOutbox.test.ts b/web-api/src/persistence/dynamo/workitems/putWorkItemInOutbox.test.ts index 1263bd2393b..827eddd3a2c 100644 --- a/web-api/src/persistence/dynamo/workitems/putWorkItemInOutbox.test.ts +++ b/web-api/src/persistence/dynamo/workitems/putWorkItemInOutbox.test.ts @@ -1,6 +1,7 @@ import { DOCKET_SECTION } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createISODateString } from '../../../../../shared/src/business/utilities/DateHandler'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { putWorkItemInOutbox } from './putWorkItemInOutbox'; describe('putWorkItemInOutbox', () => { @@ -22,16 +23,14 @@ describe('putWorkItemInOutbox', () => { it('invokes the persistence layer with pk of {userId}|outbox and {section}|outbox and other expected params', async () => { const timestamp = createISODateString(); - applicationContext.getCurrentUser.mockReturnValue({ - section: DOCKET_SECTION, - userId: '1805d1ab-18d0-43ec-bafb-654e83405416', - }); + applicationContext.getDocumentClient.mockReturnValue({ get: getStub, put: putStub, }); await putWorkItemInOutbox({ applicationContext, + authorizedUser: mockDocketClerkUser, workItem: { completedAt: timestamp, workItemId: '123', diff --git a/web-api/src/persistence/dynamo/workitems/putWorkItemInOutbox.ts b/web-api/src/persistence/dynamo/workitems/putWorkItemInOutbox.ts index dfe42d9d5f1..2f9188d7216 100644 --- a/web-api/src/persistence/dynamo/workitems/putWorkItemInOutbox.ts +++ b/web-api/src/persistence/dynamo/workitems/putWorkItemInOutbox.ts @@ -1,10 +1,19 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { RawWorkItem } from '@shared/business/entities/WorkItem'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { createSectionOutboxRecords } from './createSectionOutboxRecords'; import { createUserOutboxRecord } from './createUserOutboxRecord'; import { get } from '../../dynamodbClientService'; -export const putWorkItemInOutbox = async ({ applicationContext, workItem }) => { - const authorizedUser = applicationContext.getCurrentUser(); - +export const putWorkItemInOutbox = async ({ + applicationContext, + authorizedUser, + workItem, +}: { + applicationContext: ServerApplicationContext; + authorizedUser: AuthUser; + workItem: RawWorkItem; +}) => { const user = await get({ Key: { pk: `user|${authorizedUser.userId}`, From 96613e2ecd4cc62ef3c3ad1faac6483e577733e7 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:11:15 -0500 Subject: [PATCH 174/523] 10417: remove getCurrentUser from setDefaultGenerationTypeAction --- .../actions/setDefaultGenerationTypeAction.test.ts | 14 ++++++++------ .../actions/setDefaultGenerationTypeAction.ts | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/web-client/src/presenter/actions/setDefaultGenerationTypeAction.test.ts b/web-client/src/presenter/actions/setDefaultGenerationTypeAction.test.ts index 3a2b83924ad..af9de48845f 100644 --- a/web-client/src/presenter/actions/setDefaultGenerationTypeAction.test.ts +++ b/web-client/src/presenter/actions/setDefaultGenerationTypeAction.test.ts @@ -27,6 +27,7 @@ describe('setDefaultGenerationTypeAction', () => { form: { generationType: GENERATION_TYPES.MANUAL, }, + user: privatePractitionerUser, }, }); @@ -47,6 +48,7 @@ describe('setDefaultGenerationTypeAction', () => { form: { generationType: GENERATION_TYPES.AUTO, }, + user: privatePractitionerUser, }, }); @@ -54,8 +56,6 @@ describe('setDefaultGenerationTypeAction', () => { }); it('should set the generation type to manual when the changed event code is NOT EA and the user is an IRS Practitioner', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce(irsPractitionerUser); - const { state } = await runAction(setDefaultGenerationTypeAction, { modules: { presenter }, props: { @@ -69,6 +69,7 @@ describe('setDefaultGenerationTypeAction', () => { form: { generationType: GENERATION_TYPES.AUTO, }, + user: irsPractitionerUser, }, }); @@ -76,8 +77,6 @@ describe('setDefaultGenerationTypeAction', () => { }); it('should set the generation type to "auto"" when the changed event code is EA and the user is an IRS Practitioner with no parties having paper service', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce(irsPractitionerUser); - const { state } = await runAction(setDefaultGenerationTypeAction, { modules: { presenter }, props: { @@ -91,6 +90,8 @@ describe('setDefaultGenerationTypeAction', () => { form: { generationType: GENERATION_TYPES.MANUAL, }, + + user: irsPractitionerUser, }, }); @@ -111,6 +112,7 @@ describe('setDefaultGenerationTypeAction', () => { form: { generationType: GENERATION_TYPES.AUTO, }, + user: privatePractitionerUser, }, }); @@ -118,8 +120,6 @@ describe('setDefaultGenerationTypeAction', () => { }); it('should set the generation type to manual if code is EA but a petitioner has paper', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce(irsPractitionerUser); - const { state } = await runAction(setDefaultGenerationTypeAction, { modules: { presenter }, props: { @@ -137,6 +137,7 @@ describe('setDefaultGenerationTypeAction', () => { form: { generationType: GENERATION_TYPES.AUTO, }, + user: irsPractitionerUser, }, }); @@ -162,6 +163,7 @@ describe('setDefaultGenerationTypeAction', () => { form: { generationType: GENERATION_TYPES.MANUAL, }, + user: privatePractitionerUser, }, }); diff --git a/web-client/src/presenter/actions/setDefaultGenerationTypeAction.ts b/web-client/src/presenter/actions/setDefaultGenerationTypeAction.ts index 224a2f114b4..bbc46a15735 100644 --- a/web-client/src/presenter/actions/setDefaultGenerationTypeAction.ts +++ b/web-client/src/presenter/actions/setDefaultGenerationTypeAction.ts @@ -16,7 +16,7 @@ export const setDefaultGenerationTypeAction = async ({ const { GENERATION_TYPES } = applicationContext.getConstants(); const petitioners = get(state.caseDetail.petitioners); - const user = await applicationContext.getCurrentUser(); + const user = get(state.user); if (props.key === 'eventCode') { const showGenerationTypeForm = showGenerationType( From 3226c8b518df2cb4d3c0ff8994a739cdaca38e07 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:15:20 -0500 Subject: [PATCH 175/523] 10417: Remove getCurrentUser from setSignatureNameForPdfSigningAction --- ...etSignatureNameForPdfSigningAction.test.ts | 25 +++++++++++-------- .../setSignatureNameForPdfSigningAction.ts | 3 ++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/web-client/src/presenter/actions/setSignatureNameForPdfSigningAction.test.ts b/web-client/src/presenter/actions/setSignatureNameForPdfSigningAction.test.ts index 36548e65c26..294160644a2 100644 --- a/web-client/src/presenter/actions/setSignatureNameForPdfSigningAction.test.ts +++ b/web-client/src/presenter/actions/setSignatureNameForPdfSigningAction.test.ts @@ -10,10 +10,6 @@ describe('setSignatureNameForPdfSigningAction', () => { const { ALLOWLIST_FEATURE_FLAGS, CHIEF_JUDGE } = applicationContext.getConstants(); - let user = { - section: 'colvinChambers', - }; - let judgeUser: RawUser; beforeAll(() => { @@ -28,18 +24,19 @@ describe('setSignatureNameForPdfSigningAction', () => { [ALLOWLIST_FEATURE_FLAGS.CHIEF_JUDGE_NAME.key]: 'Oscar the Grouch', }); - applicationContext.getCurrentUser.mockReturnValue(user); - presenter.providers.applicationContext = applicationContext; }); it('sets the Chief Judge for non chamber users', async () => { - user.section = 'docketclerk'; - const result = await runAction(setSignatureNameForPdfSigningAction, { modules: { presenter, }, + state: { + user: { + section: 'docketclerk', + }, + }, }); expect(result.state.pdfForSigning.nameForSigning).toEqual( 'Oscar the Grouch', @@ -50,11 +47,15 @@ describe('setSignatureNameForPdfSigningAction', () => { it('sets the chamber judge for chamber users', async () => { judgeUser.judgeFullName = 'John O. Colvin'; judgeUser.judgeTitle = 'Judge'; - user.section = 'colvinChambers'; const result = await runAction(setSignatureNameForPdfSigningAction, { modules: { presenter, }, + state: { + user: { + section: 'colvinChambers', + }, + }, }); expect(result.state.pdfForSigning.nameForSigning).toEqual('John O. Colvin'); expect(result.state.pdfForSigning.nameForSigningLine2).toEqual('Judge'); @@ -63,11 +64,15 @@ describe('setSignatureNameForPdfSigningAction', () => { it('sets special trial for special trial judge', async () => { judgeUser.judgeFullName = 'John O. Colvin'; judgeUser.judgeTitle = 'Special Trial Judge'; - user.section = 'colvinChambers'; const result = await runAction(setSignatureNameForPdfSigningAction, { modules: { presenter, }, + state: { + user: { + section: 'colvinChambers', + }, + }, }); expect(result.state.pdfForSigning.nameForSigning).toEqual('John O. Colvin'); expect(result.state.pdfForSigning.nameForSigningLine2).toEqual( diff --git a/web-client/src/presenter/actions/setSignatureNameForPdfSigningAction.ts b/web-client/src/presenter/actions/setSignatureNameForPdfSigningAction.ts index 1abdad66c57..00996476e97 100644 --- a/web-client/src/presenter/actions/setSignatureNameForPdfSigningAction.ts +++ b/web-client/src/presenter/actions/setSignatureNameForPdfSigningAction.ts @@ -8,9 +8,10 @@ import { state } from '@web-client/presenter/app.cerebral'; */ export const setSignatureNameForPdfSigningAction = async ({ applicationContext, + get, store, }: ActionProps) => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { ALLOWLIST_FEATURE_FLAGS, CHIEF_JUDGE } = applicationContext.getConstants(); From 0d8e7aea6c5741e1459e9f8626d0fdc4961b819f Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:17:58 -0500 Subject: [PATCH 176/523] 10417: remove getCurrentUser from udpateUserContactInformationAction --- .../actions/updateUserContactInformationAction.test.ts | 5 ++++- .../presenter/actions/updateUserContactInformationAction.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/actions/updateUserContactInformationAction.test.ts b/web-client/src/presenter/actions/updateUserContactInformationAction.test.ts index 1bf8eb28c22..f746389376f 100644 --- a/web-client/src/presenter/actions/updateUserContactInformationAction.test.ts +++ b/web-client/src/presenter/actions/updateUserContactInformationAction.test.ts @@ -18,12 +18,14 @@ describe('updateUserContactInformationAction', () => { contact: { address1: '999 Jump St' }, firmName: 'testing', }, + user: {}, }, }); expect(result.state.userContactEditProgress.inProgress).toBe(true); }); it('should call the use case to update the user contact', async () => { + const userId = 'a805d1ab-18d0-43ec-bafb-654e83405416'; await runAction(updateUserContactInformationAction, { modules: { presenter, @@ -33,6 +35,7 @@ describe('updateUserContactInformationAction', () => { contact: { address1: '999 Jump St' }, firmName: 'testing', }, + user: { userId }, }, }); expect( @@ -46,7 +49,7 @@ describe('updateUserContactInformationAction', () => { address1: '999 Jump St', }, firmName: 'testing', - userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', + userId, }); }); }); diff --git a/web-client/src/presenter/actions/updateUserContactInformationAction.ts b/web-client/src/presenter/actions/updateUserContactInformationAction.ts index 9bd9c1325c8..d53bbd6b9ee 100644 --- a/web-client/src/presenter/actions/updateUserContactInformationAction.ts +++ b/web-client/src/presenter/actions/updateUserContactInformationAction.ts @@ -12,7 +12,7 @@ export const updateUserContactInformationAction = async ({ store, }: ActionProps) => { const formUser = get(state.form); - const currentUser = applicationContext.getCurrentUser(); + const currentUser = get(state.user); store.set(state.userContactEditProgress.inProgress, true); From 43c3c4f59253ba995132086b9de42bf458fee3fe Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:23:32 -0500 Subject: [PATCH 177/523] 10417: remove getCurrentUser from validateUserContactAction --- .../src/presenter/actions/validateUserContactAction.test.ts | 4 ++-- web-client/src/presenter/actions/validateUserContactAction.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web-client/src/presenter/actions/validateUserContactAction.test.ts b/web-client/src/presenter/actions/validateUserContactAction.test.ts index 55cb4b91cc3..6c0af36d0f3 100644 --- a/web-client/src/presenter/actions/validateUserContactAction.test.ts +++ b/web-client/src/presenter/actions/validateUserContactAction.test.ts @@ -23,7 +23,7 @@ describe('validateUserContactAction', () => { modules: { presenter, }, - state: { form: { contact: {} } }, + state: { form: { contact: {} }, user: {} }, }); expect(errorMock).toHaveBeenCalled(); }); @@ -36,7 +36,7 @@ describe('validateUserContactAction', () => { modules: { presenter, }, - state: { form: { contact: {} } }, + state: { form: { contact: {} }, user: {} }, }); expect(successMock).toHaveBeenCalled(); }); diff --git a/web-client/src/presenter/actions/validateUserContactAction.ts b/web-client/src/presenter/actions/validateUserContactAction.ts index d69e20c6078..72c61c286c2 100644 --- a/web-client/src/presenter/actions/validateUserContactAction.ts +++ b/web-client/src/presenter/actions/validateUserContactAction.ts @@ -14,7 +14,7 @@ export const validateUserContactAction = ({ path, }: ActionProps) => { const formContact = get(state.form); - const currentUser = applicationContext.getCurrentUser(); + const currentUser = get(state.user); const errors = applicationContext .getUseCases() From 2dbf77c9f0c76425bb8cb808ca39fd4b6a4431ba Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:25:53 -0500 Subject: [PATCH 178/523] 10417: remove getCurrentUser from setDefaultServiceStampAction --- .../setDefaultServiceStampAction.test.ts | 10 ++-------- .../setDefaultServiceStampAction.ts | 3 ++- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.test.ts b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.test.ts index 2d206126bf0..06f0dcb9b11 100644 --- a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.test.ts +++ b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.test.ts @@ -8,16 +8,13 @@ presenter.providers.applicationContext = applicationContext; describe('setDefaultServiceStampAction', () => { it('should set default serviceStamp on form if user is a petitions clerk', async () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.petitionsClerk, - }); - const result = await runAction(setDefaultServiceStampAction, { modules: { presenter, }, state: { form: {}, + user: { role: ROLES.petitionsClerk }, }, }); @@ -27,16 +24,13 @@ describe('setDefaultServiceStampAction', () => { }); it('should not set default serviceStamp on form if user is a docket clerk', async () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.docketClerk, - }); - const result = await runAction(setDefaultServiceStampAction, { modules: { presenter, }, state: { form: {}, + user: { role: ROLES.docketClerk }, }, }); diff --git a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.ts b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.ts index 3991900ca77..f1fecaacfcc 100644 --- a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.ts +++ b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setDefaultServiceStampAction.ts @@ -8,9 +8,10 @@ import { state } from '@web-client/presenter/app.cerebral'; */ export const setDefaultServiceStampAction = ({ applicationContext, + get, store, }: ActionProps) => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); if (user.role === USER_ROLES.petitionsClerk) { store.set(state.form.serviceStamp, 'Served'); From a389e47bb347a7746633be8d826afe2ce37b08c6 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:28:45 -0500 Subject: [PATCH 179/523] 10417: remove getCurrentUser from setDefaultFileDocumentFormValuesAction --- ...DefaultFileDocumentFormValuesAction.test.ts | 18 ++++++------------ .../setDefaultFileDocumentFormValuesAction.ts | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.test.ts b/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.test.ts index 3a6de6936b6..441582362dd 100644 --- a/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.test.ts +++ b/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.test.ts @@ -18,8 +18,6 @@ describe('setDefaultFileDocumentFormValuesAction', () => { presenter.providers.applicationContext = applicationContext; it('should set fileAcrossConsolidatedGroup to false when the user is filing a document on a case that is NOT consolidated', async () => { - applicationContext.getCurrentUser.mockReturnValue(privatePractitionerUser); - const result = await runAction(setDefaultFileDocumentFormValuesAction, { modules: { presenter }, state: { @@ -28,6 +26,7 @@ describe('setDefaultFileDocumentFormValuesAction', () => { leadDocketNumber: undefined, }, form: {}, + user: privatePractitionerUser, }, }); @@ -44,8 +43,6 @@ describe('setDefaultFileDocumentFormValuesAction', () => { }); it('should set fileAcrossConsolidatedGroup to false when the user is filing on a consolidated case but the document they are filing is NOT multi-docketable', async () => { - applicationContext.getCurrentUser.mockReturnValue(privatePractitionerUser); - const result = await runAction(setDefaultFileDocumentFormValuesAction, { modules: { presenter }, state: { @@ -56,6 +53,7 @@ describe('setDefaultFileDocumentFormValuesAction', () => { form: { eventCode: NON_MULTI_DOCKETABLE_EVENT_CODES[0], }, + user: privatePractitionerUser, }, }); @@ -73,8 +71,6 @@ describe('setDefaultFileDocumentFormValuesAction', () => { }); it('should set fileAcrossConsolidatedGroup to true when the user is filing a document on a case that is consolidated and they have chosen to file a document that is multi-docketable', async () => { - applicationContext.getCurrentUser.mockReturnValue(privatePractitionerUser); - const result = await runAction(setDefaultFileDocumentFormValuesAction, { modules: { presenter }, state: { @@ -85,6 +81,7 @@ describe('setDefaultFileDocumentFormValuesAction', () => { form: { eventCode: MULTI_DOCKET_FILING_EVENT_CODES[0], }, + user: privatePractitionerUser, }, }); @@ -102,13 +99,12 @@ describe('setDefaultFileDocumentFormValuesAction', () => { }); it('should set filersMap[userId] to true when the logged in user is a petitioner', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - const result = await runAction(setDefaultFileDocumentFormValuesAction, { modules: { presenter }, state: { caseDetail: {}, form: {}, + user: petitionerUser, }, }); @@ -118,8 +114,6 @@ describe('setDefaultFileDocumentFormValuesAction', () => { }); it('should set partyIrsPractitioner to true when first IRS filing', async () => { - applicationContext.getCurrentUser.mockReturnValue(irsPractitionerUser); - const result = await runAction(setDefaultFileDocumentFormValuesAction, { modules: { presenter }, state: { @@ -129,6 +123,7 @@ describe('setDefaultFileDocumentFormValuesAction', () => { form: { eventCode: 'EA', }, + user: irsPractitionerUser, }, }); @@ -136,13 +131,12 @@ describe('setDefaultFileDocumentFormValuesAction', () => { }); it('should default the generationType to manual', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - const result = await runAction(setDefaultFileDocumentFormValuesAction, { modules: { presenter }, state: { caseDetail: {}, form: { generationType: undefined }, + user: petitionerUser, }, }); diff --git a/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.ts b/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.ts index d8903682474..b589da3a0a3 100644 --- a/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.ts +++ b/web-client/src/presenter/actions/FileDocument/setDefaultFileDocumentFormValuesAction.ts @@ -7,7 +7,7 @@ export const setDefaultFileDocumentFormValuesAction = ({ get, store, }: ActionProps) => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); From 897579aac698b25119134a06812066945ee28388 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:30:25 -0500 Subject: [PATCH 180/523] 10417 remove getCurrentUser from setPractitionerOnFormAction --- .../FileDocument/setPractitionerOnFormAction.test.ts | 10 ++++++---- .../FileDocument/setPractitionerOnFormAction.ts | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.test.ts b/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.test.ts index 56a3b835dc4..2a1f5f45133 100644 --- a/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.test.ts +++ b/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.test.ts @@ -15,18 +15,20 @@ describe('setPractitionerOnFormAction', () => { const { state } = await runAction(setPractitionerOnFormAction, { modules: { presenter }, + state: { + user: { role: USER_ROLES.docketClerk }, + }, }); expect(state.form).toBeUndefined(); }); it('should set state.form.practitioner to the logged in user when the user is a privatePractitioner', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: USER_ROLES.privatePractitioner, - }); - const { state } = await runAction(setPractitionerOnFormAction, { modules: { presenter }, + state: { + user: { role: USER_ROLES.privatePractitioner }, + }, }); expect(state.form.practitioner).toEqual([ diff --git a/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.ts b/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.ts index d827b8b8feb..61d297597a1 100644 --- a/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.ts +++ b/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.ts @@ -10,9 +10,10 @@ import { state } from '@web-client/presenter/app.cerebral'; */ export const setPractitionerOnFormAction = ({ applicationContext, + get, store, }: ActionProps) => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); if (user.role === USER_ROLES.privatePractitioner) { From a76b3d434a6c16411da7a39de50a89c7dd7dcfb1 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:34:29 -0500 Subject: [PATCH 181/523] 10417: remove getCurrentUser from submtCaseAssociationRequestAction --- .../FileDocument/submitCaseAssociationRequestAction.test.ts | 5 +++-- .../FileDocument/submitCaseAssociationRequestAction.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.test.ts b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.test.ts index c8b5d50c4d4..5513e92d207 100644 --- a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.test.ts +++ b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.test.ts @@ -8,8 +8,6 @@ import { submitCaseAssociationRequestAction } from './submitCaseAssociationReque describe('submitCaseAssociationRequestAction', () => { presenter.providers.applicationContext = applicationContext; - applicationContext.getCurrentUser.mockReturnValue(privatePractitionerUser); - it("should call submitCaseAssociationRequestInteractor when the document's event code allows for the user to be immediately associated with the case", async () => { const eventCodeAllowingImmediateAssociation = PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES_MAP.filter( @@ -29,6 +27,7 @@ describe('submitCaseAssociationRequestAction', () => { eventCode: eventCodeAllowingImmediateAssociation, primaryDocumentFile: {}, }, + user: privatePractitionerUser, }, }); @@ -56,6 +55,7 @@ describe('submitCaseAssociationRequestAction', () => { eventCode: eventCodeNotAllowingImmediateAssociation, primaryDocumentFile: {}, }, + user: privatePractitionerUser, }, }); @@ -78,6 +78,7 @@ describe('submitCaseAssociationRequestAction', () => { form: { primaryDocumentFile: {}, }, + user: privatePractitionerUser, }, }); diff --git a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts index 6af62581c8b..2b0e1b65362 100644 --- a/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts +++ b/web-client/src/presenter/actions/FileDocument/submitCaseAssociationRequestAction.ts @@ -16,7 +16,7 @@ export const submitCaseAssociationRequestAction = async ({ const { PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES_MAP } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { primaryDocumentId } = props.documentsFiled; From fe9bb8aeed2ac8ac76634d2d878eabfcdbbb3998 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:36:25 -0500 Subject: [PATCH 182/523] 10417: remove getCurrentUser from submitRespondentCaseAssociationRequestAction --- .../submitRespondentCaseAssociationRequestAction.test.ts | 5 +++-- .../submitRespondentCaseAssociationRequestAction.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.test.ts b/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.test.ts index c85d8bcfb88..84951bcb23c 100644 --- a/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.test.ts +++ b/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.test.ts @@ -9,14 +9,13 @@ describe('submitRespondentCaseAssociationRequestAction', () => { presenter.providers.applicationContext = applicationContext; it('should not call submitCaseAssociationRequestInteractor when the logged in user is not an IRS practitioner', async () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - await runAction(submitRespondentCaseAssociationRequestAction, { modules: { presenter }, state: { caseDetail: { docketNumber: MOCK_CASE.docketNumber, }, + user: docketClerkUser, }, }); @@ -34,6 +33,7 @@ describe('submitRespondentCaseAssociationRequestAction', () => { caseDetail: { docketNumber: MOCK_CASE.docketNumber, }, + user: irsPractitionerUser, }, }); @@ -59,6 +59,7 @@ describe('submitRespondentCaseAssociationRequestAction', () => { caseDetail: { docketNumber: MOCK_CASE.docketNumber, }, + user: irsPractitionerUser, }, }, ); diff --git a/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.ts b/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.ts index b9b17cfb6e5..26ffd61b09e 100644 --- a/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.ts +++ b/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.ts @@ -13,7 +13,7 @@ export const submitRespondentCaseAssociationRequestAction = async ({ }: ActionProps) => { const { docketNumber } = get(state.caseDetail); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); From c9182d407ecdfa265275310837120c3db439843e Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:39:05 -0500 Subject: [PATCH 183/523] 10417 Remove getCurrentUser from getTrialSessionsForJudgeAction --- .../getTrialSessionsForJudgeAction.test.ts | 12 ++++-------- .../TrialSession/getTrialSessionsForJudgeAction.ts | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/getTrialSessionsForJudgeAction.test.ts b/web-client/src/presenter/actions/TrialSession/getTrialSessionsForJudgeAction.test.ts index 3f2857b26ee..7bf6485a435 100644 --- a/web-client/src/presenter/actions/TrialSession/getTrialSessionsForJudgeAction.test.ts +++ b/web-client/src/presenter/actions/TrialSession/getTrialSessionsForJudgeAction.test.ts @@ -9,10 +9,6 @@ describe('getTrialSessionsForJudgeAction', () => { }); it('should invoke the interactor with the expected judge id when calling this action as a judge user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: 'judge', - userId: '123', - }); applicationContext .getUseCases() .getTrialSessionsForJudgeInteractor.mockResolvedValue([ @@ -26,7 +22,7 @@ describe('getTrialSessionsForJudgeAction', () => { presenter, }, props: {}, - state: {}, + state: { user: { role: 'judge', userId: '123' } }, }); expect( @@ -36,9 +32,6 @@ describe('getTrialSessionsForJudgeAction', () => { }); it('should invoke the interactor with the expected judge id when calling this action as a chambers user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: 'chambers', - }); applicationContext .getUseCases() .getTrialSessionsForJudgeInteractor.mockResolvedValue([ @@ -57,6 +50,9 @@ describe('getTrialSessionsForJudgeAction', () => { role: 'judge', userId: '123', }, + user: { + role: 'chambers', + }, }, }); diff --git a/web-client/src/presenter/actions/TrialSession/getTrialSessionsForJudgeAction.ts b/web-client/src/presenter/actions/TrialSession/getTrialSessionsForJudgeAction.ts index e654d6022f6..e9cea73bb23 100644 --- a/web-client/src/presenter/actions/TrialSession/getTrialSessionsForJudgeAction.ts +++ b/web-client/src/presenter/actions/TrialSession/getTrialSessionsForJudgeAction.ts @@ -10,7 +10,7 @@ export const getTrialSessionsForJudgeAction = async ({ applicationContext, get, }: ActionProps) => { - const { role, userId } = applicationContext.getCurrentUser(); + const { role, userId } = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); const chambersJudgeUser = get(state.judgeUser); const isChambersUser = role === USER_ROLES.chambers; From 9358e9680e31d7b3f11f527f9e65257b950947e1 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 11 Jul 2024 14:40:36 -0700 Subject: [PATCH 184/523] 10417: migrate away from applicationContext.getCurrentUser --- ...cumentInteractor.consolidatedCases.test.ts | 77 ++-- ...rtIssuedDocumentInteractor.locking.test.ts | 26 +- ...ServeCourtIssuedDocumentInteractor.test.ts | 409 +++++++++++------- ...leAndServeCourtIssuedDocumentInteractor.ts | 34 +- .../fileAndServeCourtIssuedDocumentLambda.ts | 27 +- 5 files changed, 344 insertions(+), 229 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.consolidatedCases.test.ts b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.consolidatedCases.test.ts index fe4d742f633..c0188ec36b1 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.consolidatedCases.test.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.consolidatedCases.test.ts @@ -11,6 +11,7 @@ import { MOCK_DOCUMENTS } from '../../../../../shared/src/test/mockDocketEntry'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; import { fileAndServeCourtIssuedDocumentInteractor } from './fileAndServeCourtIssuedDocumentInteractor'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { v4 as uuidv4 } from 'uuid'; describe('consolidated cases', () => { @@ -52,8 +53,6 @@ describe('consolidated cases', () => { .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getUseCaseHelpers() .countPagesInDocument.mockReturnValue(1); @@ -127,16 +126,21 @@ describe('consolidated cases', () => { .mockRejectedValueOnce(new Error(expectedErrorString)); await expect( - fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId, - docketEntryId: leadCaseDocketEntries[0].docketEntryId, - docketNumbers: [ - MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, - MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, - ], - form: leadCaseDocketEntries[0], - subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, - }), + fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: leadCaseDocketEntries[0].docketEntryId, + docketNumbers: [ + MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, + MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, + ], + form: leadCaseDocketEntries[0], + subjectCaseDocketNumber: + MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(expectedErrorString); const initialCall = 1; @@ -175,16 +179,21 @@ describe('consolidated cases', () => { .mockRejectedValueOnce(innerError); await expect( - fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId, - docketEntryId: leadCaseDocketEntries[0].docketEntryId, - docketNumbers: [ - MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, - MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, - ], - form: leadCaseDocketEntries[0], - subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, - }), + fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: leadCaseDocketEntries[0].docketEntryId, + docketNumbers: [ + MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, + MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, + ], + form: leadCaseDocketEntries[0], + subjectCaseDocketNumber: + MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(expectedErrorString); expect(applicationContext.logger.error).toHaveBeenCalledTimes(1); @@ -194,16 +203,20 @@ describe('consolidated cases', () => { }); it('should create a single source of truth for the document by saving only one copy', async () => { - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId, - docketEntryId: leadCaseDocketEntries[0].docketEntryId, - docketNumbers: [ - MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, - MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, - ], - form: leadCaseDocketEntries[0], - subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: leadCaseDocketEntries[0].docketEntryId, + docketNumbers: [ + MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, + MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, + ], + form: leadCaseDocketEntries[0], + subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda, diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.locking.test.ts b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.locking.test.ts index 977ef019006..9d7603e0182 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.locking.test.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.locking.test.ts @@ -8,6 +8,7 @@ import { handleLockError, } from './fileAndServeCourtIssuedDocumentInteractor'; import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('determineEntitiesToLock', () => { let mockParams; @@ -43,13 +44,11 @@ describe('determineEntitiesToLock', () => { describe('handleLockError', () => { const mockClientConnectionId = '987654'; - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - }); - - it('should determine who the user is based on applicationContext', async () => { - await handleLockError(applicationContext, { foo: 'bar' }); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); + it('should not send a notification if there is no authorizedUser', async () => { + await handleLockError(applicationContext, { foo: 'bar' }, undefined); + expect( + applicationContext.getNotificationGateway().sendNotificationToUser, + ).not.toHaveBeenCalled(); }); it('should send a notification to the user with "retry_file_and_serve_court_issued_document" and the originalRequest', async () => { @@ -57,7 +56,11 @@ describe('handleLockError', () => { clientConnectionId: mockClientConnectionId, foo: 'bar', }; - await handleLockError(applicationContext, mockOriginalRequest); + await handleLockError( + applicationContext, + mockOriginalRequest, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -96,7 +99,6 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => mockLock); - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); @@ -132,6 +134,7 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { fileAndServeCourtIssuedDocumentInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ), ).rejects.toThrow(ServiceUnavailableError); @@ -145,6 +148,7 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { fileAndServeCourtIssuedDocumentInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ), ).rejects.toThrow(ServiceUnavailableError); @@ -158,7 +162,7 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { originalRequest: mockRequest, requestToRetry: 'file_and_serve_court_issued_document', }, - userId: docketClerkUser.userId, + userId: mockDocketClerkUser.userId, }); expect( @@ -176,6 +180,7 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { await fileAndServeCourtIssuedDocumentInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ); expect( @@ -198,6 +203,7 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { await fileAndServeCourtIssuedDocumentInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ); expect( applicationContext.getPersistenceGateway().removeLock, diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.test.ts b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.test.ts index 7d9e63e1784..fcb2e63892f 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.test.ts @@ -12,6 +12,7 @@ import { judgeUser, } from '../../../../../shared/src/test/mockUsers'; import { fileAndServeCourtIssuedDocumentInteractor } from './fileAndServeCourtIssuedDocumentInteractor'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { testPdfDoc } from '../../../../../shared/src/business/test/getFakeFile'; let MOCK_DATE; @@ -87,8 +88,6 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { ], }; - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); @@ -115,16 +114,18 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { }); it('should throw an error when the user is not authorized to file and serve a court issued document', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: caseRecord.docketEntries[1].docketEntryId, - docketNumbers: [], - form: {}, - subjectCaseDocketNumber: caseRecord.docketNumber, - }), + fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: caseRecord.docketEntries[1].docketEntryId, + docketNumbers: [], + form: {}, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + undefined, + ), ).rejects.toThrow('Unauthorized'); }); @@ -132,13 +133,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { const notFoundDocketEntryId = 'c54ba5a9-b37b-479d-9201-067ec6e335bd'; await expect( - fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: notFoundDocketEntryId, - docketNumbers: [], - form: {}, - subjectCaseDocketNumber: caseRecord.docketNumber, - }), + fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: notFoundDocketEntryId, + docketNumbers: [], + form: {}, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(`Docket entry ${notFoundDocketEntryId} was not found.`); }); @@ -146,15 +151,19 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { caseRecord.docketEntries[1].servedAt = MOCK_DATE; await expect( - fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: caseRecord.docketEntries[1].docketEntryId, - docketNumbers: [], - form: { - documentType: 'Order', + fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: caseRecord.docketEntries[1].docketEntryId, + docketNumbers: [], + form: { + documentType: 'Order', + }, + subjectCaseDocketNumber: caseRecord.docketNumber, }, - subjectCaseDocketNumber: caseRecord.docketNumber, - }), + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry has already been served'); }); @@ -163,13 +172,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { docketEntry.isPendingService = true; await expect( - fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: docketEntry.docketEntryId, - docketNumbers: [], - form: docketEntry, - subjectCaseDocketNumber: docketEntry.docketNumber, - }), + fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: docketEntry.docketEntryId, + docketNumbers: [], + form: docketEntry, + subjectCaseDocketNumber: docketEntry.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry is already being served'); expect( @@ -192,13 +205,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { caseRecord.docketEntries.push(mockAutoGeneratedDeadlineDocketEntry); - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockAutoGeneratedDeadlineDocketEntry.docketEntryId, - docketNumbers: [], - form: mockAutoGeneratedDeadlineForm, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockAutoGeneratedDeadlineDocketEntry.docketEntryId, + docketNumbers: [], + form: mockAutoGeneratedDeadlineForm, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().autoGenerateDeadline.mock @@ -225,13 +242,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { caseRecord.docketEntries.push(mockOrderDocketEntry); - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockOrderDocketEntry.docketEntryId, - docketNumbers: [], - form: mockOrderForm, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockOrderDocketEntry.docketEntryId, + docketNumbers: [], + form: mockOrderForm, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().autoGenerateDeadline, @@ -264,13 +285,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { eventCode: AUTO_GENERATED_DEADLINE_DOCUMENT_TYPES[0].eventCode, }; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockAutoGeneratedDeadlineDocketEntry.docketEntryId, - docketNumbers: [nonSubjectCaseRecord.docketNumber], - form: mockAutoGeneratedDeadlineForm, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockAutoGeneratedDeadlineDocketEntry.docketEntryId, + docketNumbers: [nonSubjectCaseRecord.docketNumber], + form: mockAutoGeneratedDeadlineForm, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().autoGenerateDeadline.mock @@ -279,13 +304,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { }); it('should make a call to stamp the document as served', async () => { - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - docketNumbers: [], - form: caseRecord.docketEntries[0], - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + docketNumbers: [], + form: caseRecord.docketEntries[0], + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().stampDocumentForService, @@ -298,13 +327,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { .getUseCaseHelpers() .countPagesInDocument.mockReturnValue(mockNumberOfPages); - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - docketNumbers: [], - form: caseRecord.docketEntries[0], - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + docketNumbers: [], + form: caseRecord.docketEntries[0], + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().countPagesInDocument.mock @@ -330,13 +363,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { serviceStamp: 'Blah blah blah', }; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - form: mockForm, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + form: mockForm, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); const expectedDocketEntry = applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -367,13 +404,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { serviceStamp: 'Blah blah blah', }; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - form: mockForm, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + form: mockForm, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); const expectedDocketEntry = applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -393,13 +434,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { serviceStamp: 'Blah blah blah', }; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - form: mockForm, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + form: mockForm, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); const expectedDocketEntry = applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -420,13 +465,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { trialLocation: 'San Diego, CA', }; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - form: mockForm, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + form: mockForm, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); const expectedDocketEntry = applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -447,13 +496,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { }; caseRecord.docketEntries[0].filingDate = '2009-03-01T21:40:46.415Z'; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - form: mockForm, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + form: mockForm, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); const expectedDocketEntry = applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -473,13 +526,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { serviceStamp: 'Blah blah blah', }; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - form: mockForm, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + form: mockForm, + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); const expectedDocketEntry = applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -491,13 +548,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { caseRecord.petitioners[0].serviceIndicator = SERVICE_INDICATOR_TYPES.SI_PAPER; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - docketNumbers: [], - form: caseRecord.docketEntries[0], - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + docketNumbers: [], + form: caseRecord.docketEntries[0], + subjectCaseDocketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -520,13 +581,17 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { const docketEntry = caseRecord.docketEntries[0]; docketEntry.isPendingService = false; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: docketEntry.docketEntryId, - docketNumbers: [], - form: docketEntry, - subjectCaseDocketNumber: docketEntry.docketNumber, - }); + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: docketEntry.docketEntryId, + docketNumbers: [], + form: docketEntry, + subjectCaseDocketNumber: docketEntry.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -554,17 +619,21 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { .getUseCaseHelpers() .addServedStampToDocument.mockReturnValue({}); - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - docketNumbers: [], - form: { - ...caseRecord.docketEntries[0], - documentType: 'Notice', - eventCode: 'ODJ', + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + docketNumbers: [], + form: { + ...caseRecord.docketEntries[0], + documentType: 'Notice', + eventCode: 'ODJ', + }, + subjectCaseDocketNumber: caseRecord.docketNumber, }, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda.mock @@ -576,17 +645,21 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { }); it('should attempt to scrape the pdf if event code is scrape enabled', async () => { - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - docketNumbers: [], - form: { - ...caseRecord.docketEntries[0], - documentType: 'Notice', - eventCode: 'O', + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + docketNumbers: [], + form: { + ...caseRecord.docketEntries[0], + documentType: 'Notice', + eventCode: 'O', + }, + subjectCaseDocketNumber: caseRecord.docketNumber, }, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().parseAndScrapePdfContents, @@ -603,17 +676,21 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { it('should not attempt to scrape the pdf if event code is non-scrapable', async () => { mockDocketEntryWithWorkItem.eventCode = 'EXH'; - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - docketNumbers: [], - form: { - ...caseRecord.docketEntries[0], - documentType: 'Notice', - eventCode: 'EXH', + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + docketNumbers: [], + form: { + ...caseRecord.docketEntries[0], + documentType: 'Notice', + eventCode: 'EXH', + }, + subjectCaseDocketNumber: caseRecord.docketNumber, }, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().parseAndScrapePdfContents, @@ -625,17 +702,21 @@ describe('fileAndServeCourtIssuedDocumentInteractor', () => { .getUseCaseHelpers() .parseAndScrapePdfContents.mockRejectedValue(new Error('error')); - await fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: caseRecord.docketEntries[0].docketEntryId, - docketNumbers: [], - form: { - ...caseRecord.docketEntries[0], - documentType: 'Notice', - eventCode: 'O', + await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: caseRecord.docketEntries[0].docketEntryId, + docketNumbers: [], + form: { + ...caseRecord.docketEntries[0], + documentType: 'Notice', + eventCode: 'O', + }, + subjectCaseDocketNumber: caseRecord.docketNumber, }, - subjectCaseDocketNumber: caseRecord.docketNumber, - }); + mockDocketClerkUser, + ); expect(applicationContext.logger.error).toHaveBeenCalled(); expect( diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts index e5c2491368d..75ad15952cf 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.ts @@ -10,6 +10,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createISODateString } from '@shared/business/utilities/DateHandler'; import { omit } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -29,9 +30,8 @@ export const fileAndServeCourtIssuedDocument = async ( form: any; subjectCaseDocketNumber: string; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - const hasPermission = (isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY) || isAuthorized( @@ -284,19 +284,23 @@ export const determineEntitiesToLock = ( ttl: 900, }); -export const handleLockError = async (applicationContext, originalRequest) => { - const user = applicationContext.getCurrentUser(); - - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - clientConnectionId: originalRequest.clientConnectionId, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'file_and_serve_court_issued_document', - }, - userId: user.userId, - }); +export const handleLockError = async ( + applicationContext, + originalRequest, + authorizedUser: UnknownAuthUser, +) => { + if (authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + clientConnectionId: originalRequest.clientConnectionId, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'file_and_serve_court_issued_document', + }, + userId: authorizedUser.userId, + }); + } }; export const fileAndServeCourtIssuedDocumentInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/fileAndServeCourtIssuedDocumentLambda.ts b/web-api/src/lambdas/cases/fileAndServeCourtIssuedDocumentLambda.ts index 3f6f492340f..608881eb93b 100644 --- a/web-api/src/lambdas/cases/fileAndServeCourtIssuedDocumentLambda.ts +++ b/web-api/src/lambdas/cases/fileAndServeCourtIssuedDocumentLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { fileAndServeCourtIssuedDocumentInteractor } from '@web-api/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const fileAndServeCourtIssuedDocumentLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .fileAndServeCourtIssuedDocumentInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const fileAndServeCourtIssuedDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From a41b7dd7a0b74778ea70315e00d781c84e130534 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 11 Jul 2024 16:53:52 -0500 Subject: [PATCH 185/523] 10417 remove getcurrentuser from isUserASsociatedWithTrialSessionAction --- ...erAssociatedWithTrialSessionAction.test.ts | 41 +++++++++++-------- .../isUserAssociatedWithTrialSessionAction.ts | 2 +- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.test.ts b/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.test.ts index 8ba282b7062..dc1a8134a57 100644 --- a/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.test.ts +++ b/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.test.ts @@ -21,10 +21,6 @@ describe('isUserAssociatedWithTrialSessionAction', () => { }); it('should return path.yes() if the judge is associated with the trial session', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: USER_ROLES.judge, - userId: '123', - }); await runAction(isUserAssociatedWithTrialSessionAction, { modules: { presenter, @@ -33,6 +29,10 @@ describe('isUserAssociatedWithTrialSessionAction', () => { trialSession: { judge: { userId: '123' }, }, + user: { + role: USER_ROLES.judge, + userId: '123', + }, }, }); @@ -40,10 +40,6 @@ describe('isUserAssociatedWithTrialSessionAction', () => { }); it('should return path.no() if the judge is not associated with the trial session', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: USER_ROLES.judge, - userId: '234', - }); await runAction(isUserAssociatedWithTrialSessionAction, { modules: { presenter, @@ -52,6 +48,10 @@ describe('isUserAssociatedWithTrialSessionAction', () => { trialSession: { judge: { userId: '123' }, }, + user: { + role: USER_ROLES.judge, + userId: '234', + }, }, }); @@ -71,6 +71,10 @@ describe('isUserAssociatedWithTrialSessionAction', () => { trialSession: { judge: { userId: '123' }, }, + user: { + role: USER_ROLES.chambers, + userId: '234', + }, users: [{ role: USER_ROLES.judge, userId: '456' }], }, }); @@ -79,10 +83,6 @@ describe('isUserAssociatedWithTrialSessionAction', () => { }); it('should return path.yes() if the user is in the chambers section and their judge is associated with the trial session', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: USER_ROLES.chambers, - userId: '234', - }); await runAction(isUserAssociatedWithTrialSessionAction, { modules: { presenter, @@ -91,6 +91,11 @@ describe('isUserAssociatedWithTrialSessionAction', () => { trialSession: { judge: { userId: '123' }, }, + + user: { + role: USER_ROLES.chambers, + userId: '234', + }, users: [{ role: USER_ROLES.judge, userId: '123' }], }, }); @@ -111,6 +116,10 @@ describe('isUserAssociatedWithTrialSessionAction', () => { trialSession: { trialClerk: { userId: '123' }, }, + user: { + role: USER_ROLES.trialClerk, + userId: '123', + }, }, }); @@ -118,10 +127,6 @@ describe('isUserAssociatedWithTrialSessionAction', () => { }); it('should return path.no() if the current user is a trial clerk but is NOT the trial clerk for this trial session', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: USER_ROLES.trialClerk, - userId: '234', - }); await runAction(isUserAssociatedWithTrialSessionAction, { modules: { presenter, @@ -130,6 +135,10 @@ describe('isUserAssociatedWithTrialSessionAction', () => { trialSession: { trialClerk: { userId: '123' }, }, + user: { + role: USER_ROLES.trialClerk, + userId: '234', + }, }, }); diff --git a/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.ts b/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.ts index 32f472dfd8f..ec50840f8a8 100644 --- a/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.ts +++ b/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.ts @@ -14,7 +14,7 @@ export const isUserAssociatedWithTrialSessionAction = ({ path, }: ActionProps) => { const trialSession = get(state.trialSession); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); if (user.role === USER_ROLES.judge) { From ad2b0225b87241cde843f0703de8bbc5e0de398e Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 11 Jul 2024 15:40:09 -0700 Subject: [PATCH 186/523] 10417: remove appcontext.getCurrentUser from addDraftStampOrderDocketEntryInteractor --- .../generateDraftStampOrderInteractor.ts | 20 +++--- ...aftStampOrderDocketEntryInteractor.test.ts | 63 +++++++++++-------- ...addDraftStampOrderDocketEntryInteractor.ts | 19 +++--- 3 files changed, 61 insertions(+), 41 deletions(-) diff --git a/shared/src/business/useCases/generateDraftStampOrderInteractor.ts b/shared/src/business/useCases/generateDraftStampOrderInteractor.ts index 19a359d14f7..7f3507b8b03 100644 --- a/shared/src/business/useCases/generateDraftStampOrderInteractor.ts +++ b/shared/src/business/useCases/generateDraftStampOrderInteractor.ts @@ -41,14 +41,18 @@ export const generateDraftStampOrderInteractor = async ( await applicationContext .getUseCaseHelpers() - .addDraftStampOrderDocketEntryInteractor(applicationContext, { - docketNumber, - formattedDraftDocumentTitle, - originalDocketEntryId: motionDocketEntryId, - parentMessageId, - stampData, - stampedDocketEntryId, - }); + .addDraftStampOrderDocketEntryInteractor( + applicationContext, + { + docketNumber, + formattedDraftDocumentTitle, + originalDocketEntryId: motionDocketEntryId, + parentMessageId, + stampData, + stampedDocketEntryId, + }, + authorizedUser, + ); await applicationContext .getUseCaseHelpers() diff --git a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts index 62103560d24..8ddf5d1080a 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts @@ -10,12 +10,10 @@ import { ServiceUnavailableError, UnauthorizedError, } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { addDraftStampOrderDocketEntryInteractor } from './addDraftStampOrderDocketEntryInteractor'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { - clerkOfCourtUser, - judgeUser, -} from '../../../../../shared/src/test/mockUsers'; +import { mockJudgeUser } from '@shared/test/mockAuthUsers'; describe('addDraftStampOrderDocketEntryInteractor', () => { let mockLock; @@ -42,17 +40,18 @@ describe('addDraftStampOrderDocketEntryInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue(clerkOfCourtUser); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); - - applicationContext.getCurrentUser.mockReturnValue(judgeUser); }); it('should add a draft order docket entry to the case', async () => { - await addDraftStampOrderDocketEntryInteractor(applicationContext, args); + await addDraftStampOrderDocketEntryInteractor( + applicationContext, + args, + mockJudgeUser, + ); const { caseToUpdate } = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -76,20 +75,20 @@ describe('addDraftStampOrderDocketEntryInteractor', () => { docketEntryId: mockStampedDocketEntryId, docketNumber: caseToUpdate.docketNumber, documentType: ORDER_TYPES[0].documentType, - filedBy: judgeUser.judgeFullName, + filedBy: mockJudgeUser.name, freeText: `${motionDocumentType} some title with disposition and custom text`, isDraft: true, signedJudgeName: mockSigningName, }); }); + //TODO 10417: authorizedUser never has judgeFullName property - is this test still relevant? it("should set the filedBy to the current user's name if there is no judge full name on the user", async () => { - applicationContext.getCurrentUser.mockReturnValue({ - ...judgeUser, - judgeFullName: undefined, - }); - - await addDraftStampOrderDocketEntryInteractor(applicationContext, args); + await addDraftStampOrderDocketEntryInteractor( + applicationContext, + args, + mockJudgeUser, + ); const { caseToUpdate } = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -102,7 +101,7 @@ describe('addDraftStampOrderDocketEntryInteractor', () => { ); expect(draftDocketEntryEntity).toMatchObject({ - filedBy: judgeUser.name, + filedBy: mockJudgeUser.name, }); }); @@ -129,10 +128,14 @@ describe('addDraftStampOrderDocketEntryInteractor', () => { .getPersistenceGateway() .getMessageThreadByParentId.mockReturnValue([mockMessage]); - await addDraftStampOrderDocketEntryInteractor(applicationContext, { - ...args, - parentMessageId: mockParentMessageId, - }); + await addDraftStampOrderDocketEntryInteractor( + applicationContext, + { + ...args, + parentMessageId: mockParentMessageId, + }, + mockJudgeUser, + ); expect( applicationContext.getPersistenceGateway().updateMessage, @@ -153,7 +156,11 @@ describe('addDraftStampOrderDocketEntryInteractor', () => { mockLock = MOCK_LOCK; await expect( - addDraftStampOrderDocketEntryInteractor(applicationContext, args), + addDraftStampOrderDocketEntryInteractor( + applicationContext, + args, + mockJudgeUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -162,7 +169,11 @@ describe('addDraftStampOrderDocketEntryInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await addDraftStampOrderDocketEntryInteractor(applicationContext, args); + await addDraftStampOrderDocketEntryInteractor( + applicationContext, + args, + mockJudgeUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -181,10 +192,12 @@ describe('addDraftStampOrderDocketEntryInteractor', () => { }); it('should throw an Unauthorized error if the user is not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - addDraftStampOrderDocketEntryInteractor(applicationContext, args), + addDraftStampOrderDocketEntryInteractor( + applicationContext, + args, + {} as UnknownAuthUser, + ), ).rejects.toThrow(UnauthorizedError); }); }); diff --git a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts index c452094d5af..197af68002b 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts @@ -11,6 +11,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { Stamp } from '../../../../../shared/src/business/entities/Stamp'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { orderBy } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -45,10 +46,9 @@ export const addDraftStampOrderDocketEntry = async ( }; stampedDocketEntryId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.STAMP_MOTION)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.STAMP_MOTION)) { throw new UnauthorizedError('Unauthorized to update docket entry'); } @@ -58,7 +58,7 @@ export const addDraftStampOrderDocketEntry = async ( applicationContext, docketNumber, }); - const caseEntity = new Case(caseRecord, { authorizedUser: user }); + const caseEntity = new Case(caseRecord, { authorizedUser }); const originalDocketEntryEntity = caseEntity.docketEntries.find( docketEntry => docketEntry.docketEntryId === originalDocketEntryId, ); @@ -85,7 +85,7 @@ export const addDraftStampOrderDocketEntry = async ( freeText: `${originalDocketEntryEntity.documentType} ${formattedDraftDocumentTitle}`, }, eventCode: orderDocumentInfo?.eventCode, - filedBy: user.judgeFullName || user.name, + filedBy: authorizedUser.name, freeText: `${originalDocketEntryEntity.documentType} ${formattedDraftDocumentTitle}`, isDraft: true, isFileAttached: true, @@ -93,12 +93,15 @@ export const addDraftStampOrderDocketEntry = async ( processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, stampData: validatedStampData, }, - { authorizedUser: user }, + { authorizedUser }, ); - stampedDocketEntryEntity.setFiledBy(user); + stampedDocketEntryEntity.setFiledBy(authorizedUser); - stampedDocketEntryEntity.setSigned(user.userId, stampData.nameForSigning); + stampedDocketEntryEntity.setSigned( + authorizedUser.userId, + stampData.nameForSigning, + ); caseEntity.addDocketEntry(stampedDocketEntryEntity); From 4e69fee79e59f577f9a96e3e3b56dc4103628ae2 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 07:20:20 -0500 Subject: [PATCH 187/523] 10417 remove getCurrentUser from prepareUserBasedHeadingAction --- .../prepareUserBasedHeadingAction.test.ts | 2 +- .../TrialSessionWorkingCopy/prepareUserBasedHeadingAction.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSessionWorkingCopy/prepareUserBasedHeadingAction.test.ts b/web-client/src/presenter/actions/TrialSessionWorkingCopy/prepareUserBasedHeadingAction.test.ts index 04947635f58..5f1d303ce1a 100644 --- a/web-client/src/presenter/actions/TrialSessionWorkingCopy/prepareUserBasedHeadingAction.test.ts +++ b/web-client/src/presenter/actions/TrialSessionWorkingCopy/prepareUserBasedHeadingAction.test.ts @@ -8,7 +8,6 @@ describe('prepareUserBasedHeadingAction', () => { let user; const { USER_ROLES } = applicationContext.getConstants(); - applicationContext.getCurrentUser = () => user; it.each([ [USER_ROLES.trialClerk, 'Test User - Session Copy'], @@ -26,6 +25,7 @@ describe('prepareUserBasedHeadingAction', () => { formattedTrialSessionDetails: { formattedJudge: 'Buch', }, + user, }, }); expect(result.output).toEqual({ userHeading: expected }); diff --git a/web-client/src/presenter/actions/TrialSessionWorkingCopy/prepareUserBasedHeadingAction.ts b/web-client/src/presenter/actions/TrialSessionWorkingCopy/prepareUserBasedHeadingAction.ts index b45802f20ea..f9442b36f55 100644 --- a/web-client/src/presenter/actions/TrialSessionWorkingCopy/prepareUserBasedHeadingAction.ts +++ b/web-client/src/presenter/actions/TrialSessionWorkingCopy/prepareUserBasedHeadingAction.ts @@ -11,7 +11,7 @@ export const prepareUserBasedHeadingAction = ({ applicationContext, get, }: ActionProps) => { - const currentUser = applicationContext.getCurrentUser(); + const currentUser = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); const userRole = currentUser.role; const formattedTrialSessionDetails = get(state.formattedTrialSessionDetails); From 68fb87fa3deaa647fc528d8a244c07e65c287ede Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 07:22:02 -0500 Subject: [PATCH 188/523] 10417: remove getcurrentUser from setAddEditSessionNoteModalAction --- .../setAddEditSessionNoteModalStateAction.test.ts | 3 ++- .../setAddEditSessionNoteModalStateAction.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditSessionNoteModalStateAction.test.ts b/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditSessionNoteModalStateAction.test.ts index 89c50b44663..fb7c0b83f06 100644 --- a/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditSessionNoteModalStateAction.test.ts +++ b/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditSessionNoteModalStateAction.test.ts @@ -8,7 +8,6 @@ describe('setAddEditSessionNoteModalStateAction', () => { let user; const { USER_ROLES } = applicationContext.getConstants(); - applicationContext.getCurrentUser = () => user; it('should set the modal state', async () => { user = { role: USER_ROLES.judge }; @@ -24,6 +23,7 @@ describe('setAddEditSessionNoteModalStateAction', () => { trialSessionWorkingCopy: { sessionNotes: 'i got some notes', }, + user, }, }); @@ -46,6 +46,7 @@ describe('setAddEditSessionNoteModalStateAction', () => { trialSessionWorkingCopy: { sessionNotes: 'i got some notes', }, + user, }, }); diff --git a/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditSessionNoteModalStateAction.ts b/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditSessionNoteModalStateAction.ts index 9a9d4991f92..e1735d868b7 100644 --- a/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditSessionNoteModalStateAction.ts +++ b/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditSessionNoteModalStateAction.ts @@ -13,7 +13,7 @@ export const setAddEditSessionNoteModalStateAction = ({ get, store, }: ActionProps) => { - const currentUser = applicationContext.getCurrentUser(); + const currentUser = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); const notes = get(state.trialSessionWorkingCopy.sessionNotes); const trialSessionDetail = get(state.trialSession); From 5f2bb001b5bf5bdca96dccf03cec701424b1be3d Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 07:35:55 -0500 Subject: [PATCH 189/523] 10417: make WorkItem refactor compatible with JoiValidationEntity --- shared/src/business/entities/JoiValidationEntity.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/business/entities/JoiValidationEntity.ts b/shared/src/business/entities/JoiValidationEntity.ts index a36012fd274..bf4b6ef0b0e 100644 --- a/shared/src/business/entities/JoiValidationEntity.ts +++ b/shared/src/business/entities/JoiValidationEntity.ts @@ -195,7 +195,7 @@ export abstract class JoiValidationEntity { static validateRawCollection( this: new (someVar: any, someArgs: any) => T, collection: any[] = [], - args: any, + args?: any, ) { return collection.map( rawEntity => From b9a86bdd884e22cf14234680145de10a55d4a49f Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 07:36:19 -0500 Subject: [PATCH 190/523] 10417: remove getCurrentUser from setAddEditUserCaseNoteModalstateFromDetailAction --- .../setAddEditUserCaseNoteModalStateFromDetailAction.test.ts | 3 ++- .../setAddEditUserCaseNoteModalStateFromDetailAction.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditUserCaseNoteModalStateFromDetailAction.test.ts b/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditUserCaseNoteModalStateFromDetailAction.test.ts index 2b0eed45bba..5644ec1430c 100644 --- a/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditUserCaseNoteModalStateFromDetailAction.test.ts +++ b/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditUserCaseNoteModalStateFromDetailAction.test.ts @@ -8,7 +8,6 @@ describe('setAddEditUserCaseNoteModalStateFromDetailAction', () => { let user; const { USER_ROLES } = applicationContext.getConstants(); - applicationContext.getCurrentUser = () => user; it('should set the modal state from caseDetail and props', async () => { user = { role: USER_ROLES.judge }; @@ -26,6 +25,7 @@ describe('setAddEditUserCaseNoteModalStateFromDetailAction', () => { docketNumberWithSuffix: '101-19L', }, judgesNote: { notes: 'i got some notes' }, + user, }, }, ); @@ -55,6 +55,7 @@ describe('setAddEditUserCaseNoteModalStateFromDetailAction', () => { docketNumberWithSuffix: '101-19', }, judgesNote: { notes: 'i got some notes' }, + user, }, }, ); diff --git a/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditUserCaseNoteModalStateFromDetailAction.ts b/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditUserCaseNoteModalStateFromDetailAction.ts index 2da6e915279..3ef4bdfca7f 100644 --- a/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditUserCaseNoteModalStateFromDetailAction.ts +++ b/web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditUserCaseNoteModalStateFromDetailAction.ts @@ -12,7 +12,7 @@ export const setAddEditUserCaseNoteModalStateFromDetailAction = ({ get, store, }: ActionProps) => { - const currentUser = applicationContext.getCurrentUser(); + const currentUser = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); const { caseCaption, docketNumber, docketNumberWithSuffix } = get( From e9fca764feffe3d6da20371f7d507f94e99dced3 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 07:37:50 -0500 Subject: [PATCH 191/523] 10417: notes, unused references --- web-api/src/lambdas/pdfGeneration/pdf-generation.ts | 1 + .../persistence/elasticsearch/getCaseInventoryReport.test.ts | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/web-api/src/lambdas/pdfGeneration/pdf-generation.ts b/web-api/src/lambdas/pdfGeneration/pdf-generation.ts index d6c7dea639b..806d47fe735 100644 --- a/web-api/src/lambdas/pdfGeneration/pdf-generation.ts +++ b/web-api/src/lambdas/pdfGeneration/pdf-generation.ts @@ -36,6 +36,7 @@ export const changeOfAddressHandler = async event => { await applicationContext.getUseCaseHelpers().generateChangeOfAddressHelper({ applicationContext, + // TODO: 10417 authorizedUser: applicationContext.getCurrentUser(), bypassDocketEntry: eventBody.bypassDocketEntry, contactInfo: eventBody.contactInfo, diff --git a/web-api/src/persistence/elasticsearch/getCaseInventoryReport.test.ts b/web-api/src/persistence/elasticsearch/getCaseInventoryReport.test.ts index 33d600ce06b..1b0e58e9ad1 100644 --- a/web-api/src/persistence/elasticsearch/getCaseInventoryReport.test.ts +++ b/web-api/src/persistence/elasticsearch/getCaseInventoryReport.test.ts @@ -2,7 +2,6 @@ import { CASE_STATUS_TYPES, CHIEF_JUDGE, } from '../../../../shared/src/business/entities/EntityConstants'; -import { MOCK_USERS } from '../../../../shared/src/test/mockUsers'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { getCaseInventoryReport } from './getCaseInventoryReport'; import { marshall } from '@aws-sdk/util-dynamodb'; @@ -35,9 +34,6 @@ describe('getCaseInventoryReport', () => { applicationContext.getConstants.mockReturnValue({ CASE_INVENTORY_MAX_PAGE_SIZE, }); - applicationContext.getCurrentUser.mockReturnValue( - MOCK_USERS['a7d90c05-f6cd-442c-a168-202db587f16f'], - ); applicationContext.getSearchClient.mockReturnValue({ search: searchSpy, }); From e4748be6bfefbfd5567ae9381f0af34598eed286 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 07:39:26 -0500 Subject: [PATCH 192/523] 10417: remove getCurrentUser from getDocumentQCServedForUserInteractor --- ...tDocumentQCServedForUserInteractor.test.ts | 45 +++++++------------ .../getDocumentQCServedForUserInteractor.ts | 12 +++-- .../getDocumentQCServedForUserLambda.ts | 29 ++++++++---- 3 files changed, 41 insertions(+), 45 deletions(-) diff --git a/web-api/src/business/useCases/workItems/getDocumentQCServedForUserInteractor.test.ts b/web-api/src/business/useCases/workItems/getDocumentQCServedForUserInteractor.test.ts index 785e072fc8a..d7bf63cd9e4 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCServedForUserInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCServedForUserInteractor.test.ts @@ -1,21 +1,15 @@ -import { - DOCKET_SECTION, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { DOCKET_SECTION } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getDocumentQCServedForUserInteractor } from './getDocumentQCServedForUserInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getDocumentQCServedForUserInteractor', () => { - let user; - beforeEach(() => { - user = { - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }; - applicationContext.getCurrentUser.mockReturnValue(user); - applicationContext.getPersistenceGateway().getDocumentQCServedForUser = () => [ { @@ -64,17 +58,14 @@ describe('getDocumentQCServedForUserInteractor', () => { }); it('throws an error if the user does not have access to the work item', async () => { - user = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - - applicationContext.getCurrentUser.mockReturnValue(user); - await expect( - getDocumentQCServedForUserInteractor(applicationContext, { - userId: '123', - }), + getDocumentQCServedForUserInteractor( + applicationContext, + { + userId: '123', + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -84,7 +75,9 @@ describe('getDocumentQCServedForUserInteractor', () => { { userId: '123', }, + mockPetitionsClerkUser, ); + expect(result).toMatchObject([ { docketEntry: { sentBy: 'petitioner' }, @@ -104,18 +97,12 @@ describe('getDocumentQCServedForUserInteractor', () => { }); it('successfully returns the work items for a docket clerk', async () => { - user = { - role: ROLES.docketClerk, - userId: 'docketclerk', - }; - - applicationContext.getCurrentUser.mockReturnValue(user); - const result = await getDocumentQCServedForUserInteractor( applicationContext, { userId: 'abc', }, + mockDocketClerkUser, ); expect(result).toMatchObject([ { diff --git a/web-api/src/business/useCases/workItems/getDocumentQCServedForUserInteractor.ts b/web-api/src/business/useCases/workItems/getDocumentQCServedForUserInteractor.ts index f3f7c51db52..9730f4dfc78 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCServedForUserInteractor.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCServedForUserInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; /** @@ -17,10 +18,9 @@ import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; export const getDocumentQCServedForUserInteractor = async ( applicationContext: ServerApplicationContext, { userId }: { userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.WORKITEM)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.WORKITEM)) { throw new UnauthorizedError('Unauthorized'); } @@ -32,10 +32,8 @@ export const getDocumentQCServedForUserInteractor = async ( }); const filteredWorkItems = workItems.filter(workItem => - user.role === ROLES.petitionsClerk ? !!workItem.section : true, + authorizedUser.role === ROLES.petitionsClerk ? !!workItem.section : true, ); - return WorkItem.validateRawCollection(filteredWorkItems, { - applicationContext, - }); + return WorkItem.validateRawCollection(filteredWorkItems); }; diff --git a/web-api/src/lambdas/workitems/getDocumentQCServedForUserLambda.ts b/web-api/src/lambdas/workitems/getDocumentQCServedForUserLambda.ts index 56493357a21..3b88d56d889 100644 --- a/web-api/src/lambdas/workitems/getDocumentQCServedForUserLambda.ts +++ b/web-api/src/lambdas/workitems/getDocumentQCServedForUserLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getDocumentQCServedForUserInteractor } from '@web-api/business/useCases/workItems/getDocumentQCServedForUserInteractor'; /** * returns the users inbox @@ -6,13 +8,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getDocumentQCServedForUserLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { userId } = event.pathParameters || {}; +export const getDocumentQCServedForUserLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { userId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .getDocumentQCServedForUserInteractor(applicationContext, { - userId, - }); - }); + return await getDocumentQCServedForUserInteractor( + applicationContext, + { + userId, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 92e7c8c124fb95c36a68404b9677500e5fea054a Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 07:46:20 -0500 Subject: [PATCH 193/523] 10417: remove getCurrentUser from assignPetitiontoAuthenticatedUserAction --- .../assignPetitionToAuthenticatedUserAction.test.ts | 12 +++++++----- .../assignPetitionToAuthenticatedUserAction.ts | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/web-client/src/presenter/actions/WorkItem/assignPetitionToAuthenticatedUserAction.test.ts b/web-client/src/presenter/actions/WorkItem/assignPetitionToAuthenticatedUserAction.test.ts index 0f16b51fee3..90d18800db0 100644 --- a/web-client/src/presenter/actions/WorkItem/assignPetitionToAuthenticatedUserAction.test.ts +++ b/web-client/src/presenter/actions/WorkItem/assignPetitionToAuthenticatedUserAction.test.ts @@ -7,13 +7,13 @@ describe('assignPetitionToAuthenticatedUserAction', () => { const { INITIAL_DOCUMENT_TYPES } = applicationContext.getConstants(); const { assignWorkItemsInteractor } = applicationContext.getUseCases(); + const user = { + name: 'Some One', + userId: 'abc', + }; + beforeAll(() => { presenter.providers.applicationContext = applicationContext; - - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Some One', - userId: 'abc', - }); }); it('should not assign the workitem if the qc work item is not present', async () => { @@ -25,6 +25,7 @@ describe('assignPetitionToAuthenticatedUserAction', () => { caseDetail: { docketEntries: [], }, + user, }, }); @@ -45,6 +46,7 @@ describe('assignPetitionToAuthenticatedUserAction', () => { }, ], }, + user, }, }); diff --git a/web-client/src/presenter/actions/WorkItem/assignPetitionToAuthenticatedUserAction.ts b/web-client/src/presenter/actions/WorkItem/assignPetitionToAuthenticatedUserAction.ts index d45683fb4e6..9fa26148359 100644 --- a/web-client/src/presenter/actions/WorkItem/assignPetitionToAuthenticatedUserAction.ts +++ b/web-client/src/presenter/actions/WorkItem/assignPetitionToAuthenticatedUserAction.ts @@ -13,7 +13,7 @@ export const assignPetitionToAuthenticatedUserAction = async ({ }: ActionProps) => { const { INITIAL_DOCUMENT_TYPES } = applicationContext.getConstants(); const { docketEntries } = get(state.caseDetail); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const petitionDocument = docketEntries.find( document => From 344e88d6abec6dc0817716e349a97a44ea98233a Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 07:59:01 -0500 Subject: [PATCH 194/523] 10417: remove getCurrentUser from getDocumentQCServedForSectionInteractor --- ...cumentQCServedForSectionInteractor.test.ts | 38 ++++++++----------- ...getDocumentQCServedForSectionInteractor.ts | 8 ++-- .../getDocumentQCServedForSectionLambda.ts | 30 ++++++++++----- 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.test.ts b/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.test.ts index b4dd6cb4280..a0fb084feb1 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.test.ts @@ -1,7 +1,6 @@ import { DOCKET_SECTION, PETITIONS_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_USERS } from '../../../../../shared/src/test/mockUsers'; import { UnauthorizedError } from '@web-api/errors/errors'; @@ -14,18 +13,15 @@ import { calculateISODate, createISODateAtStartOfDayEST, } from '../../../../../shared/src/business/utilities/DateHandler'; +import { + mockDocketClerkUser, + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getDocumentQCServedForSectionInteractor', () => { describe('interactor', () => { - let user; - beforeEach(() => { - user = { - role: ROLES.docketClerk, - userId: 'a7d90c05-f6cd-442c-a168-202db587f16f', - }; - applicationContext.getCurrentUser.mockReturnValue(user); - applicationContext.getPersistenceGateway().getDocumentQCServedForSection = () => [ { @@ -79,16 +75,16 @@ describe('getDocumentQCServedForSectionInteractor', () => { }); it('throws an error if the user does not have access to the work item', async () => { - user = { - role: ROLES.petitioner, - userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', - }; - applicationContext.getCurrentUser.mockReturnValue(user); + applicationContext.getCurrentUser.mockReturnValue(mockPetitionerUser); await expect( - getDocumentQCServedForSectionInteractor(applicationContext, { - section: DOCKET_SECTION, - }), + getDocumentQCServedForSectionInteractor( + applicationContext, + { + section: DOCKET_SECTION, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -98,6 +94,7 @@ describe('getDocumentQCServedForSectionInteractor', () => { { section: DOCKET_SECTION, }, + mockDocketClerkUser, ); expect(result).toMatchObject([ @@ -128,17 +125,14 @@ describe('getDocumentQCServedForSectionInteractor', () => { }); it('successfully returns the work item for a petitionsclerk', async () => { - user = { - role: ROLES.petitionsClerk, - userId: '4b423e1f-4eb2-4011-a845-873b82bee0a8', - }; - applicationContext.getCurrentUser.mockReturnValue(user); + applicationContext.getCurrentUser.mockReturnValue(mockPetitionsClerkUser); const result = await getDocumentQCServedForSectionInteractor( applicationContext, { section: PETITIONS_SECTION, }, + mockPetitionsClerkUser, ); expect(result).toMatchObject([ diff --git a/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.ts b/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.ts index 52f09053fe7..3e9785f7c95 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.ts @@ -6,6 +6,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { calculateISODate, createISODateAtStartOfDayEST, @@ -21,10 +22,9 @@ import { export const getDocumentQCServedForSectionInteractor = async ( applicationContext: ServerApplicationContext, { section }: { section: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.WORKITEM)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.WORKITEM)) { throw new UnauthorizedError( 'Unauthorized for getting completed work items', ); @@ -41,7 +41,7 @@ export const getDocumentQCServedForSectionInteractor = async ( const filteredWorkItems = workItems .filter(workItem => - user.role === ROLES.petitionsClerk ? !!workItem.section : true, + authorizedUser.role === ROLES.petitionsClerk ? !!workItem.section : true, ) .map(workItem => new OutboxItem(workItem, { applicationContext })); diff --git a/web-api/src/lambdas/workitems/getDocumentQCServedForSectionLambda.ts b/web-api/src/lambdas/workitems/getDocumentQCServedForSectionLambda.ts index c0547a8fc87..dffaedd0ff6 100644 --- a/web-api/src/lambdas/workitems/getDocumentQCServedForSectionLambda.ts +++ b/web-api/src/lambdas/workitems/getDocumentQCServedForSectionLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getDocumentQCServedForSectionInteractor } from '@web-api/business/useCases/workItems/getDocumentQCServedForSectionInteractor'; /** * returns all sent work items in a particular section @@ -6,13 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getDocumentQCServedForSectionLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { section } = event.pathParameters || {}; - - return await applicationContext - .getUseCases() - .getDocumentQCServedForSectionInteractor(applicationContext, { - section, - }); - }); +export const getDocumentQCServedForSectionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { section } = event.pathParameters || {}; + return await getDocumentQCServedForSectionInteractor( + applicationContext, + { + section, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From eca330d2b0d96b8a8c4f251c26c6e92518127ab4 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 08:04:52 -0500 Subject: [PATCH 195/523] 10417 remove getCurrentUser from addCourtIssuedDocketEntryHelper --- .../computeds/addCourtIssuedDocketEntryHelper.test.ts | 8 ++++++-- .../computeds/addCourtIssuedDocketEntryHelper.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.test.ts b/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.test.ts index f811434af3b..63f4f5cf510 100644 --- a/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.test.ts +++ b/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.test.ts @@ -70,15 +70,15 @@ describe('addCourtIssuedDocketEntryHelper', () => { form: { generatedDocumentTitle: 'Circle of Life', }, + user, }; beforeEach(() => { - applicationContext.getCurrentUser.mockImplementation(() => user); - applicationContext.getConstants.mockImplementation(() => mockConstants); }); it('should calculate document types based on constants in applicationContext', () => { + console.debug('*****************************************', state.user); const result = runCompute(addCourtIssuedDocketEntryHelper, { state }); expect(result.documentTypes).toEqual([ { @@ -208,6 +208,7 @@ describe('addCourtIssuedDocketEntryHelper', () => { it('should return showSaveAndServeButton false if eventCode is found in unservable event codes list', () => { const result = runCompute(addCourtIssuedDocketEntryHelper, { state: { + ...state, caseDetail: { ...state.caseDetail, docketEntries: [ @@ -229,6 +230,7 @@ describe('addCourtIssuedDocketEntryHelper', () => { it('should return showServiceWarning true and showSaveAndServeButton false if the case can NOT allow service', () => { const result = runCompute(addCourtIssuedDocketEntryHelper, { state: { + ...state, caseDetail: { ...state.caseDetail, docketEntries: [ @@ -253,6 +255,7 @@ describe('addCourtIssuedDocketEntryHelper', () => { it('should return showServiceWarning true and showSaveAndServeButton false if eventCode is NOT found in unservable event codes list and case can NOT allow service', () => { const result = runCompute(addCourtIssuedDocketEntryHelper, { state: { + ...state, caseDetail: { ...state.caseDetail, docketEntries: [ @@ -281,6 +284,7 @@ describe('addCourtIssuedDocketEntryHelper', () => { it('should return showServiceWarning false and showSaveAndServeButton true if eventCode is NOT found in unservable event codes list and case can allow service', () => { const result = runCompute(addCourtIssuedDocketEntryHelper, { state: { + ...state, caseDetail: { ...state.caseDetail, docketEntries: [ diff --git a/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.ts b/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.ts index 4af3990dcc6..5445778df72 100644 --- a/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.ts +++ b/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.ts @@ -20,7 +20,7 @@ export const addCourtIssuedDocketEntryHelper = ( const form = get(state.form); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const eventCodes = COURT_ISSUED_EVENT_CODES; From e7b96c675a0774e8f16d4771ddb8efcdbe61b729 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 08:08:02 -0500 Subject: [PATCH 196/523] 10417: remove getCurrentUser from getDocumentQCInboxForUserInteractor --- ...etDocumentQCInboxForUserInteractor.test.ts | 58 +++++++++++-------- .../getDocumentQCInboxForUserInteractor.ts | 4 +- .../getDocumentQCInboxForUserLambda.ts | 29 +++++++--- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.test.ts b/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.test.ts index b7d100d0794..e8355b39523 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.test.ts @@ -1,11 +1,14 @@ import { DOCKET_NUMBER_SUFFIXES, DOCKET_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; import { getDocumentQCInboxForUserInteractor } from './getDocumentQCInboxForUserInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getDocumentQCInboxForUserInteractor', () => { beforeEach(() => { @@ -31,37 +34,40 @@ describe('getDocumentQCInboxForUserInteractor', () => { }); it('should throw an error when the user does not have access retrieve work items', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'petitioner', - }); - await expect( - getDocumentQCInboxForUserInteractor(applicationContext, { - userId: null, - }), + getDocumentQCInboxForUserInteractor( + applicationContext, + { + userId: '', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should fetch the user from persistence', async () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - - await getDocumentQCInboxForUserInteractor(applicationContext, { - userId: docketClerkUser.userId, - }); + await getDocumentQCInboxForUserInteractor( + applicationContext, + { + userId: docketClerkUser.userId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getUserById.mock.calls[0][0] .userId, - ).toEqual(docketClerkUser.userId); + ).toEqual(mockDocketClerkUser.userId); }); it('should query workItems that are associated with the provided userId', async () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - - await getDocumentQCInboxForUserInteractor(applicationContext, { - userId: docketClerkUser.userId, - }); + await getDocumentQCInboxForUserInteractor( + applicationContext, + { + userId: docketClerkUser.userId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDocumentQCInboxForUser.mock @@ -70,10 +76,12 @@ describe('getDocumentQCInboxForUserInteractor', () => { }); it('should filter the workItems for the provided user', async () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - - await getDocumentQCInboxForUserInteractor(applicationContext, { - userId: docketClerkUser.userId, - }); + await getDocumentQCInboxForUserInteractor( + applicationContext, + { + userId: docketClerkUser.userId, + }, + mockDocketClerkUser, + ); }); }); diff --git a/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.ts b/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.ts index 80ffe09513c..80a23e11ba3 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; /** @@ -17,9 +18,8 @@ import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; export const getDocumentQCInboxForUserInteractor = async ( applicationContext: ServerApplicationContext, { userId }: { userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.WORKITEM)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/workitems/getDocumentQCInboxForUserLambda.ts b/web-api/src/lambdas/workitems/getDocumentQCInboxForUserLambda.ts index 589a5b25902..b5e6e175974 100644 --- a/web-api/src/lambdas/workitems/getDocumentQCInboxForUserLambda.ts +++ b/web-api/src/lambdas/workitems/getDocumentQCInboxForUserLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getDocumentQCInboxForUserInteractor } from '@web-api/business/useCases/workItems/getDocumentQCInboxForUserInteractor'; /** * returns the users inbox @@ -6,13 +8,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getDocumentQCInboxForUserLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { userId } = event.pathParameters || {}; +export const getDocumentQCInboxForUserLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { userId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .getDocumentQCInboxForUserInteractor(applicationContext, { - userId, - }); - }); + return await getDocumentQCInboxForUserInteractor( + applicationContext, + { + userId, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 069684be9d0f0221f81a734f0b3f89e78a0353b0 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 08:09:42 -0500 Subject: [PATCH 197/523] 10417 remove getCurrentUser from alertHelper --- .../src/presenter/computeds/alertHelper.test.ts | 14 ++++++-------- web-client/src/presenter/computeds/alertHelper.ts | 8 ++------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/web-client/src/presenter/computeds/alertHelper.test.ts b/web-client/src/presenter/computeds/alertHelper.test.ts index 87b28a781d7..801e517d4ee 100644 --- a/web-client/src/presenter/computeds/alertHelper.test.ts +++ b/web-client/src/presenter/computeds/alertHelper.test.ts @@ -1,12 +1,7 @@ -import { alertHelper as alertHelperComputed } from './alertHelper'; +import { alertHelper } from './alertHelper'; import { runCompute } from '@web-client/presenter/test.cerebral'; -import { withAppContextDecorator } from '../../withAppContext'; -const alertHelper = withAppContextDecorator(alertHelperComputed, { - getCurrentUser: () => ({ - userId: '123', - }), -}); +const user = {}; describe('alertHelper', () => { it('single message error alert', () => { @@ -15,6 +10,7 @@ describe('alertHelper', () => { alertError: { message: 'abc', }, + user, }, }); expect(result).toMatchObject({ @@ -30,6 +26,7 @@ describe('alertHelper', () => { state: { alertError: { title: 'hello' }, }, + user, }); expect(result).toMatchObject({ showErrorAlert: true, @@ -41,7 +38,7 @@ describe('alertHelper', () => { it('alertError is undefined', () => { const result = runCompute(alertHelper, { - state: {}, + state: { user }, }); expect(result).toMatchObject({ showErrorAlert: false, @@ -57,6 +54,7 @@ describe('alertHelper', () => { alertError: { responseCode: 504, }, + user, }, }); expect(result).toMatchObject({ diff --git a/web-client/src/presenter/computeds/alertHelper.ts b/web-client/src/presenter/computeds/alertHelper.ts index a220569e585..1b6a2439811 100644 --- a/web-client/src/presenter/computeds/alertHelper.ts +++ b/web-client/src/presenter/computeds/alertHelper.ts @@ -1,14 +1,10 @@ -import { ClientApplicationContext } from '@web-client/applicationContext'; import { Get } from 'cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import { uniq } from 'lodash'; -export const alertHelper = ( - get: Get, - applicationContext: ClientApplicationContext, -): any => { +export const alertHelper = (get: Get): any => { const alertError = get(state.alertError) || {}; - const userIsIdentified = applicationContext.getCurrentUser() || false; + const userIsIdentified = get(state.user) || false; return { messagesDeduped: uniq(alertError.messages), From 295411f181eb870b12e77575fb049637a128f2df Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 08:15:59 -0500 Subject: [PATCH 198/523] 10417: remove getCurrentUser from getDocumentQCInboxForSectionInteractor --- ...ocumentQCInboxForSectionInteractor.test.ts | 74 +++++++++---------- .../getDocumentQCInboxForSectionInteractor.ts | 4 +- ...cumentQCServedForSectionInteractor.test.ts | 4 - .../getDocumentQCInboxForSectionLambda.ts | 31 +++++--- 4 files changed, 59 insertions(+), 54 deletions(-) diff --git a/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.test.ts b/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.test.ts index f1251b32ac9..da9f5cad66c 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.test.ts @@ -1,33 +1,33 @@ -import { - DOCKET_SECTION, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { DOCKET_SECTION } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getDocumentQCInboxForSectionInteractor } from './getDocumentQCInboxForSectionInteractor'; +import { + mockDocketClerkUser, + mockJudgeUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getDocumentQCInboxForSectionInteractor', () => { it('should throw an error when the user does not have permission to retrieve work items', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'petitioner', - }); - await expect( - getDocumentQCInboxForSectionInteractor(applicationContext, { - section: DOCKET_SECTION, - }), + getDocumentQCInboxForSectionInteractor( + applicationContext, + { + section: DOCKET_SECTION, + }, + mockPetitionerUser, + ), ).rejects.toThrow(); }); it('should query workItems for the provided section', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketclerk', - }); - - await getDocumentQCInboxForSectionInteractor(applicationContext, { - section: DOCKET_SECTION, - }); + await getDocumentQCInboxForSectionInteractor( + applicationContext, + { + section: DOCKET_SECTION, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDocumentQCInboxForSection @@ -36,14 +36,13 @@ describe('getDocumentQCInboxForSectionInteractor', () => { }); it('should default to query workItems for the DOCKET_SECTION when a section is provided that is NOT PETITIONS_SECTION', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketclerk', - }); - - await getDocumentQCInboxForSectionInteractor(applicationContext, { - section: 'ANY_OTHER_SECTION', - }); + await getDocumentQCInboxForSectionInteractor( + applicationContext, + { + section: 'ANY_OTHER_SECTION', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDocumentQCInboxForSection @@ -52,16 +51,15 @@ describe('getDocumentQCInboxForSectionInteractor', () => { }); it('should query workItems using a judge name when one is provided', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.judge, - userId: 'judge', - }); - - await getDocumentQCInboxForSectionInteractor(applicationContext, { - judgeUserName: 'Ashford', - section: applicationContext.getPersistenceGateway().getJudgesChambers() - .ASHFORDS_CHAMBERS_SECTION.section, - }); + await getDocumentQCInboxForSectionInteractor( + applicationContext, + { + judgeUserName: 'Ashford', + section: applicationContext.getPersistenceGateway().getJudgesChambers() + .ASHFORDS_CHAMBERS_SECTION.section, + }, + mockJudgeUser, + ); expect( applicationContext.getPersistenceGateway().getDocumentQCInboxForSection diff --git a/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.ts b/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.ts index 78ea9e28ca3..d8912c6fba6 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.ts @@ -8,6 +8,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; /** @@ -26,9 +27,8 @@ export const getDocumentQCInboxForSectionInteractor = async ( judgeUserName?: string; section: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.WORKITEM)) { throw new UnauthorizedError( 'Unauthorized for getting completed work items', diff --git a/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.test.ts b/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.test.ts index a0fb084feb1..adf08f26d47 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCServedForSectionInteractor.test.ts @@ -75,8 +75,6 @@ describe('getDocumentQCServedForSectionInteractor', () => { }); it('throws an error if the user does not have access to the work item', async () => { - applicationContext.getCurrentUser.mockReturnValue(mockPetitionerUser); - await expect( getDocumentQCServedForSectionInteractor( applicationContext, @@ -125,8 +123,6 @@ describe('getDocumentQCServedForSectionInteractor', () => { }); it('successfully returns the work item for a petitionsclerk', async () => { - applicationContext.getCurrentUser.mockReturnValue(mockPetitionsClerkUser); - const result = await getDocumentQCServedForSectionInteractor( applicationContext, { diff --git a/web-api/src/lambdas/workitems/getDocumentQCInboxForSectionLambda.ts b/web-api/src/lambdas/workitems/getDocumentQCInboxForSectionLambda.ts index 6581bd01ab1..36bb773c9ad 100644 --- a/web-api/src/lambdas/workitems/getDocumentQCInboxForSectionLambda.ts +++ b/web-api/src/lambdas/workitems/getDocumentQCInboxForSectionLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getDocumentQCInboxForSectionInteractor } from '@web-api/business/useCases/workItems/getDocumentQCInboxForSectionInteractor'; /** * returns all sent work items in a particular section @@ -6,14 +8,23 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getDocumentQCInboxForSectionLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { section } = event.pathParameters || {}; +export const getDocumentQCInboxForSectionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { section } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .getDocumentQCInboxForSectionInteractor(applicationContext, { - section, - ...event.queryStringParameters, - }); - }); + return await getDocumentQCInboxForSectionInteractor( + applicationContext, + { + section, + ...event.queryStringParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 87007dbe703b10595965daed12672039b4cc6259 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 08:17:07 -0500 Subject: [PATCH 199/523] 10417: remove getCurrentUSer from caseAssociationRequestHelper --- .../caseAssociationRequestHelper.test.ts | 26 ++++--------------- .../computeds/caseAssociationRequestHelper.ts | 2 +- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/web-client/src/presenter/computeds/caseAssociationRequestHelper.test.ts b/web-client/src/presenter/computeds/caseAssociationRequestHelper.test.ts index 67639f9edcf..c527e723158 100644 --- a/web-client/src/presenter/computeds/caseAssociationRequestHelper.test.ts +++ b/web-client/src/presenter/computeds/caseAssociationRequestHelper.test.ts @@ -20,6 +20,7 @@ describe('caseAssociationRequestHelper', () => { const state = { caseDetail: MOCK_CASE, form: {} as any, + user: { role: ROLES.privatePractitioner } as RawUser, validationErrors: {}, }; @@ -35,11 +36,6 @@ describe('caseAssociationRequestHelper', () => { }; beforeEach(() => { - applicationContext.getCurrentUser = () => - ({ - role: ROLES.privatePractitioner, - }) as RawUser; - state.form = { filersMap, }; @@ -108,10 +104,7 @@ describe('caseAssociationRequestHelper', () => { }); it('returns correct number of document options for user role irsPractitioner', () => { - applicationContext.getCurrentUser = () => - ({ - role: ROLES.irsPractitioner, - }) as RawUser; + state.user.role = ROLES.irsPractitioner; const result = runCompute(caseAssociationRequestHelper, { state }); expect(result.documents.length).toEqual(2); }); @@ -279,10 +272,7 @@ describe('caseAssociationRequestHelper', () => { petitioners: TEST_PETITIONERS, } as RawCase; - applicationContext.getCurrentUser = () => - ({ - role: ROLES.irsPractitioner, - }) as RawUser; + state.user.role = ROLES.irsPractitioner; const { showGenerationTypeForm } = runCompute( caseAssociationRequestHelper, { @@ -296,10 +286,6 @@ describe('caseAssociationRequestHelper', () => { state.form = { eventCode: 'O', }; - applicationContext.getCurrentUser = () => - ({ - role: ROLES.privatePractitioner, - }) as RawUser; const { showGenerationTypeForm } = runCompute( caseAssociationRequestHelper, { @@ -310,10 +296,7 @@ describe('caseAssociationRequestHelper', () => { }); it('should set showGenerationTypeForm to false when code is EA and any petitioner has paper and user is not a private practitioner', () => { - applicationContext.getCurrentUser = () => - ({ - role: ROLES.irsPractitioner, - }) as RawUser; + state.user.role = ROLES.irsPractitioner; const { showGenerationTypeForm } = runCompute( caseAssociationRequestHelper, { @@ -324,6 +307,7 @@ describe('caseAssociationRequestHelper', () => { }); it('should set showGenerationTypeForm to true when code is EA and user is a private practitioner with parties that have paper service', () => { + state.user.role = ROLES.privatePractitioner; const { showGenerationTypeForm } = runCompute( caseAssociationRequestHelper, { diff --git a/web-client/src/presenter/computeds/caseAssociationRequestHelper.ts b/web-client/src/presenter/computeds/caseAssociationRequestHelper.ts index d5c9ca85d90..ee5b570ec2f 100644 --- a/web-client/src/presenter/computeds/caseAssociationRequestHelper.ts +++ b/web-client/src/presenter/computeds/caseAssociationRequestHelper.ts @@ -39,7 +39,7 @@ export const caseAssociationRequestHelper = ( const { GENERATION_TYPES, PARTY_TYPES, USER_ROLES } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const caseDetail = get(state.caseDetail); const form = get(state.form); From cb6551a01a2425af210db8cd92052f30030d2175 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 08:26:40 -0500 Subject: [PATCH 200/523] 10417: remove getCurrentUser from completeWorkItemInteractor --- ...completeWorkItemInteractor.locking.test.ts | 27 +++++++-- .../completeWorkItemInteractor.test.ts | 58 +++++++++---------- .../workItems/completeWorkItemInteractor.ts | 12 ++-- .../workitems/completeWorkItemLambda.ts | 29 +++++++--- 4 files changed, 75 insertions(+), 51 deletions(-) diff --git a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.locking.test.ts b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.locking.test.ts index b914ad01f88..61853ab4c6d 100644 --- a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.locking.test.ts +++ b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.locking.test.ts @@ -7,7 +7,7 @@ import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { completeWorkItemInteractor } from './completeWorkItemInteractor'; -import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('completeWorkItemInteractor', () => { let mockLock; @@ -50,7 +50,6 @@ describe('completeWorkItemInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); @@ -62,7 +61,11 @@ describe('completeWorkItemInteractor', () => { it('throws a ServiceUnavailableError if a Case is currently locked', async () => { mockLock = MOCK_LOCK; await expect( - completeWorkItemInteractor(applicationContext, mockRequest), + completeWorkItemInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -71,7 +74,11 @@ describe('completeWorkItemInteractor', () => { }); it('acquires a lock that lasts for 30 seconds on the case', async () => { - await completeWorkItemInteractor(applicationContext, mockRequest); + await completeWorkItemInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -84,7 +91,11 @@ describe('completeWorkItemInteractor', () => { it('resolves and calls updateCaseAndAssociations', async () => { await expect( - completeWorkItemInteractor(applicationContext, mockRequest), + completeWorkItemInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations, @@ -92,7 +103,11 @@ describe('completeWorkItemInteractor', () => { }); it('removes the lock when it is finished', async () => { - await completeWorkItemInteractor(applicationContext, mockRequest); + await completeWorkItemInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().removeLock, diff --git a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.test.ts b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.test.ts index f9a7e14fbf2..edbc4ac0de7 100644 --- a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.test.ts @@ -1,16 +1,16 @@ import { DOCKET_NUMBER_SUFFIXES, DOCKET_SECTION, - PARTY_TYPES, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { completeWorkItemInteractor } from './completeWorkItemInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('completeWorkItemInteractor', () => { - let mockUser; - const mockWorkItem = { assigneeId: applicationContext.getUniqueId(), createdAt: '2019-03-11T21:56:01.625Z', @@ -36,14 +36,6 @@ describe('completeWorkItemInteractor', () => { }; beforeEach(() => { - mockUser = { - name: 'docket clerk', - role: ROLES.docketClerk, - userId: applicationContext.getUniqueId(), - }; - - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - applicationContext .getPersistenceGateway() .getWorkItemById.mockResolvedValue(mockWorkItem); @@ -58,27 +50,29 @@ describe('completeWorkItemInteractor', () => { }); it('should throw an error when the user does not have permission to complete the work item', async () => { - mockUser = { - name: PARTY_TYPES.petitioner, - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( - completeWorkItemInteractor(applicationContext, { - completedMessage: 'Completed', - workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + completeWorkItemInteractor( + applicationContext, + { + completedMessage: 'Completed', + workItemId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for complete workItem'); }); it('should retrieve the original work item from persistence', async () => { const mockWorkItemId = 'c54ba5a9-b37b-479d-9201-067ec6e335bb'; - await completeWorkItemInteractor(applicationContext, { - completedMessage: 'Completed', - workItemId: mockWorkItemId, - }); + await completeWorkItemInteractor( + applicationContext, + { + completedMessage: 'Completed', + workItemId: mockWorkItemId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getWorkItemById.mock @@ -117,10 +111,14 @@ describe('completeWorkItemInteractor', () => { ], }); - await completeWorkItemInteractor(applicationContext, { - completedMessage: 'Completed', - workItemId: mockWorkItem.workItemId, - }); + await completeWorkItemInteractor( + applicationContext, + { + completedMessage: 'Completed', + workItemId: mockWorkItem.workItemId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] diff --git a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts index 68fe7a6b2e7..e90446ab4de 100644 --- a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts +++ b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; import { createISODateString } from '../../../../../shared/src/business/utilities/DateHandler'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -27,10 +28,9 @@ export const completeWorkItem = async ( completedMessage: string; workItemId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.WORKITEM)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.WORKITEM)) { throw new UnauthorizedError('Unauthorized for complete workItem'); } @@ -45,14 +45,14 @@ export const completeWorkItem = async ( const completedWorkItem = originalWorkItemEntity .setAsCompleted({ message: completedMessage, - user, + user: authorizedUser, }) .validate() .toRawObject(); await applicationContext.getPersistenceGateway().putWorkItemInOutbox({ applicationContext, - authorizedUser: user, + authorizedUser, workItem: { ...completedWorkItem, createdAt: createISODateString(), @@ -71,7 +71,7 @@ export const completeWorkItem = async ( docketNumber: completedWorkItem.docketNumber, }); - const caseToUpdate = new Case(caseObject, { authorizedUser: user }); + const caseToUpdate = new Case(caseObject, { authorizedUser }); const workItemEntity = new WorkItem(completedWorkItem); diff --git a/web-api/src/lambdas/workitems/completeWorkItemLambda.ts b/web-api/src/lambdas/workitems/completeWorkItemLambda.ts index 02e5f404610..eb8c8db3d96 100644 --- a/web-api/src/lambdas/workitems/completeWorkItemLambda.ts +++ b/web-api/src/lambdas/workitems/completeWorkItemLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { completeWorkItemInteractor } from '@web-api/business/useCases/workItems/completeWorkItemInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const completeWorkItemLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .completeWorkItemInteractor(applicationContext, { - completedMessage: JSON.parse(event.body).completedMessage, - workItemId: event.pathParameters.workItemId, - }); - }); +export const completeWorkItemLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await completeWorkItemInteractor( + applicationContext, + { + completedMessage: JSON.parse(event.body).completedMessage, + workItemId: event.pathParameters.workItemId, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 5b93dd1cff93d49c807cdea40967ff3ba04aaf6c Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 08:36:23 -0500 Subject: [PATCH 201/523] 10417 remove getCurrentUser from caseDetailHeaderHelper cleanup --- shared/src/test/mockUsers.ts | 1 + .../computeds/caseDetailHeaderHelper.test.ts | 12 +++--------- .../presenter/computeds/caseDetailHeaderHelper.ts | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/shared/src/test/mockUsers.ts b/shared/src/test/mockUsers.ts index f6d46929add..ffff42a6ac1 100644 --- a/shared/src/test/mockUsers.ts +++ b/shared/src/test/mockUsers.ts @@ -111,6 +111,7 @@ export const judgeColvin: RawUser = { }; export const petitionerUser = { + email: 'petitioner@example.com', name: 'Tax Payer', role: ROLES.petitioner, section: 'petitioner', diff --git a/web-client/src/presenter/computeds/caseDetailHeaderHelper.test.ts b/web-client/src/presenter/computeds/caseDetailHeaderHelper.test.ts index 25e495e2309..40cc7dd4171 100644 --- a/web-client/src/presenter/computeds/caseDetailHeaderHelper.test.ts +++ b/web-client/src/presenter/computeds/caseDetailHeaderHelper.test.ts @@ -17,24 +17,17 @@ import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; describe('caseDetailHeaderHelper', () => { - let globalUser; - const getBaseState = user => { - globalUser = user; return { caseDetail: { docketEntries: [], petitioners: [] }, permissions: getUserPermissions(user), + user, }; }; const caseDetailHeaderHelper = withAppContextDecorator( caseDetailHeaderHelperComputed, - { - ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, - }, + applicationContext, ); describe('hidePublicCaseInformation', () => { @@ -589,6 +582,7 @@ describe('caseDetailHeaderHelper', () => { it('should be true when the case is sealed', () => { const result = runCompute(caseDetailHeaderHelper, { state: { + ...getBaseState(privatePractitionerUser), caseDetail: { ...getBaseState(privatePractitionerUser).caseDetail, isSealed: true, diff --git a/web-client/src/presenter/computeds/caseDetailHeaderHelper.ts b/web-client/src/presenter/computeds/caseDetailHeaderHelper.ts index ae5590313d0..066cb538bda 100644 --- a/web-client/src/presenter/computeds/caseDetailHeaderHelper.ts +++ b/web-client/src/presenter/computeds/caseDetailHeaderHelper.ts @@ -9,7 +9,7 @@ export const caseDetailHeaderHelper = ( ): any => { const { USER_ROLES } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const isExternalUser = applicationContext .getUtilities() .isExternalUser(user.role); From 422da0fe897275155f9f42293de36e16ae928c1a Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 08:39:12 -0500 Subject: [PATCH 202/523] 10417: remove getCurrentUser from assignWorkItemsInteractor --- .../assignWorkItemsInteractor.test.ts | 72 ++++++++++--------- .../workItems/assignWorkItemsInteractor.ts | 3 +- .../workitems/assignWorkItemsLambda.ts | 24 ++++--- 3 files changed, 58 insertions(+), 41 deletions(-) diff --git a/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.test.ts b/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.test.ts index dbb6f26afed..62314160aeb 100644 --- a/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.test.ts @@ -2,24 +2,16 @@ import { CASE_STATUS_TYPES, DOCKET_NUMBER_SUFFIXES, DOCKET_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { assignWorkItemsInteractor } from './assignWorkItemsInteractor'; import { caseServicesSupervisorUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('assignWorkItemsInteractor', () => { const options = { assigneeId: 'ss', assigneeName: 'ss', workItemId: '' }; - const mockUserId = 'ebb34e3f-8ac1-4ac2-bc22-265b80a2acb2'; let mockWorkItem; - const mockDocketClerkUser = { - name: 'Alex Docketclerk', - role: ROLES.docketClerk, - section: 'docket', - userId: mockUserId, - }; - beforeEach(() => { mockWorkItem = { assigneeId: '03b74100-10ac-45f1-865d-b063978cac9c', @@ -52,9 +44,10 @@ describe('assignWorkItemsInteractor', () => { }; applicationContext.getCurrentUser.mockReturnValue(mockDocketClerkUser); - applicationContext - .getPersistenceGateway() - .getUserById.mockReturnValue(mockDocketClerkUser); + applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ + ...mockDocketClerkUser, + section: DOCKET_SECTION, + }); applicationContext .getPersistenceGateway() @@ -62,12 +55,12 @@ describe('assignWorkItemsInteractor', () => { }); it('should throw an unauthorized error when the user does not have permission to assign work items', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - userId: 'baduser', - }); - await expect( - assignWorkItemsInteractor(applicationContext, options), + assignWorkItemsInteractor( + applicationContext, + options, + mockDocketClerkUser, + ), ).rejects.toThrow(); }); @@ -78,24 +71,32 @@ describe('assignWorkItemsInteractor', () => { }); await expect( - assignWorkItemsInteractor(applicationContext, options), + assignWorkItemsInteractor( + applicationContext, + options, + mockDocketClerkUser, + ), ).rejects.toThrow(); }); it('assigns a work item to the current user', async () => { - await assignWorkItemsInteractor(applicationContext, { - assigneeId: mockUserId, - assigneeName: 'Ted Docket', - workItemId: mockWorkItem.workItemId, - }); + await assignWorkItemsInteractor( + applicationContext, + { + assigneeId: mockDocketClerkUser.userId, + assigneeName: 'Ted Docket', + workItemId: mockWorkItem.workItemId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem.mock.calls[0][0] .workItem, ).toMatchObject({ - section: mockDocketClerkUser.section, + section: DOCKET_SECTION, sentBy: mockDocketClerkUser.name, - sentBySection: mockDocketClerkUser.section, + sentBySection: DOCKET_SECTION, sentByUserId: mockDocketClerkUser.userId, }); }); @@ -104,19 +105,26 @@ describe('assignWorkItemsInteractor', () => { applicationContext .getPersistenceGateway() .getUserById.mockReturnValueOnce(caseServicesSupervisorUser) - .mockReturnValueOnce(mockDocketClerkUser); + .mockReturnValueOnce({ + ...mockDocketClerkUser, + section: DOCKET_SECTION, + }); - await assignWorkItemsInteractor(applicationContext, { - assigneeId: mockUserId, - assigneeName: 'Ted Docket', - workItemId: mockWorkItem.workItemId, - }); + await assignWorkItemsInteractor( + applicationContext, + { + assigneeId: mockDocketClerkUser.userId, + assigneeName: 'Ted Docket', + workItemId: mockWorkItem.workItemId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem.mock.calls[0][0] .workItem, ).toMatchObject({ - section: mockDocketClerkUser.section, + section: DOCKET_SECTION, sentBy: caseServicesSupervisorUser.name, sentBySection: caseServicesSupervisorUser.section, sentByUserId: caseServicesSupervisorUser.userId, diff --git a/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.ts b/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.ts index c1431786ec9..b7c83df048c 100644 --- a/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.ts +++ b/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; @@ -27,8 +28,8 @@ export const assignWorkItemsInteractor = async ( assigneeName: string; workItemId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSIGN_WORK_ITEM)) { throw new UnauthorizedError('Unauthorized to assign work item'); } diff --git a/web-api/src/lambdas/workitems/assignWorkItemsLambda.ts b/web-api/src/lambdas/workitems/assignWorkItemsLambda.ts index 7adae821db8..ba6672e50bd 100644 --- a/web-api/src/lambdas/workitems/assignWorkItemsLambda.ts +++ b/web-api/src/lambdas/workitems/assignWorkItemsLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { assignWorkItemsInteractor } from '@web-api/business/useCases/workItems/assignWorkItemsInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +8,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const assignWorkItemsLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .assignWorkItemsInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const assignWorkItemsLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await assignWorkItemsInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From e388b720bf1d2a8570f10aa4c69dda952b29d939 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 08:46:56 -0500 Subject: [PATCH 203/523] 10417: Remove getCurrentUser from caseDetailHelper --- .../presenter/computeds/caseDetailHelper.test.ts | 14 +++++--------- .../src/presenter/computeds/caseDetailHelper.ts | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/web-client/src/presenter/computeds/caseDetailHelper.test.ts b/web-client/src/presenter/computeds/caseDetailHelper.test.ts index 96601e34e21..1ce051f96fc 100644 --- a/web-client/src/presenter/computeds/caseDetailHelper.test.ts +++ b/web-client/src/presenter/computeds/caseDetailHelper.test.ts @@ -15,21 +15,17 @@ import { getUserPermissions } from '../../../../shared/src/authorization/getUser import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; -const caseDetailHelper = withAppContextDecorator(caseDetailHelperComputed, { - ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, -}); - -let globalUser; +const caseDetailHelper = withAppContextDecorator( + caseDetailHelperComputed, + applicationContext, +); const getBaseState = user => { - globalUser = user; return { currentPage: 'CaseDetail', form: {}, permissions: getUserPermissions(user), + user, }; }; diff --git a/web-client/src/presenter/computeds/caseDetailHelper.ts b/web-client/src/presenter/computeds/caseDetailHelper.ts index 4e4cfc20560..08218d1c692 100644 --- a/web-client/src/presenter/computeds/caseDetailHelper.ts +++ b/web-client/src/presenter/computeds/caseDetailHelper.ts @@ -9,7 +9,7 @@ export const caseDetailHelper = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); const permissions = get(state.permissions); const hasTrackedItemsPermission = permissions.TRACKED_ITEMS; From 82ff0ef1ba9f2ee0ae5664d91512ad8d41960e5f Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 08:48:50 -0500 Subject: [PATCH 204/523] 10417 Remove getCurrentUser from caseDetailSubnavHelper --- .../computeds/caseDetailSubnavHelper.test.ts | 11 ++--------- .../src/presenter/computeds/caseDetailSubnavHelper.ts | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/web-client/src/presenter/computeds/caseDetailSubnavHelper.test.ts b/web-client/src/presenter/computeds/caseDetailSubnavHelper.test.ts index 0ef844efd18..fc5ff18769c 100644 --- a/web-client/src/presenter/computeds/caseDetailSubnavHelper.test.ts +++ b/web-client/src/presenter/computeds/caseDetailSubnavHelper.test.ts @@ -7,23 +7,16 @@ import { withAppContextDecorator } from '../../withAppContext'; const caseDetailSubnavHelper = withAppContextDecorator( caseDetailSubnavHelperComputed, - { - ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, - }, + applicationContext, ); -let globalUser; - const getBaseState = user => { - globalUser = user; return { caseDetail: { docketEntries: [], }, permissions: getUserPermissions(user), + user, }; }; diff --git a/web-client/src/presenter/computeds/caseDetailSubnavHelper.ts b/web-client/src/presenter/computeds/caseDetailSubnavHelper.ts index 0ff1b27e078..54d1669809d 100644 --- a/web-client/src/presenter/computeds/caseDetailSubnavHelper.ts +++ b/web-client/src/presenter/computeds/caseDetailSubnavHelper.ts @@ -6,7 +6,7 @@ export const caseDetailSubnavHelper = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); const isInternalUser = applicationContext .getUtilities() From 9aea707226c1e86cb24cc07d1630f290a88cd80f Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 08:52:43 -0500 Subject: [PATCH 205/523] 10417: remove getCurrentUser from verifyUserPendingEmailInteractor --- .../verifyUserPendingEmailInteractor.test.ts | 93 +++++++++++++------ .../user/verifyUserPendingEmailInteractor.ts | 4 +- .../assignWorkItemsInteractor.test.ts | 1 - .../users/verifyUserPendingEmailLambda.ts | 27 ++++-- 4 files changed, 84 insertions(+), 41 deletions(-) diff --git a/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.test.ts b/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.test.ts index 55c1baa4ef2..42b8ce21bfb 100644 --- a/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.test.ts +++ b/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.test.ts @@ -6,6 +6,11 @@ import { import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getContactPrimary } from '../../../../../shared/src/business/entities/cases/Case'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { validUser } from '../../../../../shared/src/test/mockUsers'; import { verifyUserPendingEmailInteractor } from './verifyUserPendingEmailInteractor'; @@ -13,6 +18,7 @@ describe('verifyUserPendingEmailInteractor', () => { const TOKEN = '41189629-abe1-46d7-b7a4-9d3834f919cb'; const mockPractitioner = { ...validUser, + ...mockPrivatePractitionerUser, admissionsDate: '2019-03-01', admissionsStatus: 'Active', barNumber: 'RA3333', @@ -32,6 +38,7 @@ describe('verifyUserPendingEmailInteractor', () => { const mockPetitioner = { ...validUser, + ...mockPetitionerUser, firstName: 'Olden', lastName: 'Vivas', pendingEmail: 'other@example.com', @@ -53,7 +60,6 @@ describe('verifyUserPendingEmailInteractor', () => { }; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(mockPractitioner); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(mockPractitioner); @@ -72,23 +78,26 @@ describe('verifyUserPendingEmailInteractor', () => { }); it('should throw unauthorized error when user does not have permission to verify emails', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', - }); - await expect( - verifyUserPendingEmailInteractor(applicationContext, { - token: 'abc', - }), + verifyUserPendingEmailInteractor( + applicationContext, + { + token: 'abc', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Unauthorized to manage emails'); }); it('should throw an unauthorized error when the token passed as an argument does not match stored token on user', async () => { await expect( - verifyUserPendingEmailInteractor(applicationContext, { - token: 'abc', - }), + verifyUserPendingEmailInteractor( + applicationContext, + { + token: 'abc', + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Tokens do not match'); }); @@ -99,9 +108,13 @@ describe('verifyUserPendingEmailInteractor', () => { }); await expect( - verifyUserPendingEmailInteractor(applicationContext, { - token: undefined as any, - }), + verifyUserPendingEmailInteractor( + applicationContext, + { + token: undefined as any, + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Tokens do not match'); }); @@ -111,16 +124,24 @@ describe('verifyUserPendingEmailInteractor', () => { .isEmailAvailable.mockReturnValue(false); await expect( - verifyUserPendingEmailInteractor(applicationContext, { - token: TOKEN, - }), + verifyUserPendingEmailInteractor( + applicationContext, + { + token: TOKEN, + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Email is not available'); }); it('should update the cognito email when tokens match', async () => { - await verifyUserPendingEmailInteractor(applicationContext, { - token: TOKEN, - }); + await verifyUserPendingEmailInteractor( + applicationContext, + { + token: TOKEN, + }, + mockPrivatePractitionerUser, + ); expect(applicationContext.getUserGateway().updateUser).toHaveBeenCalledWith( applicationContext, @@ -134,9 +155,13 @@ describe('verifyUserPendingEmailInteractor', () => { }); it('should update the dynamo record with the new info', async () => { - await verifyUserPendingEmailInteractor(applicationContext, { - token: TOKEN, - }); + await verifyUserPendingEmailInteractor( + applicationContext, + { + token: TOKEN, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getPersistenceGateway().updateUser.mock.calls[0][0] @@ -149,9 +174,13 @@ describe('verifyUserPendingEmailInteractor', () => { }); it('should call updateUser with email set to pendingEmail and pendingEmail set to undefined, and service indicator set to electronic with a practitioner user', async () => { - await verifyUserPendingEmailInteractor(applicationContext, { - token: TOKEN, - }); + await verifyUserPendingEmailInteractor( + applicationContext, + { + token: TOKEN, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getPersistenceGateway().updateUser.mock.calls[0][0] @@ -169,9 +198,13 @@ describe('verifyUserPendingEmailInteractor', () => { .getPersistenceGateway() .getUserById.mockReturnValue(mockPetitioner); - await verifyUserPendingEmailInteractor(applicationContext, { - token: mockPetitioner.pendingEmailVerificationToken, - }); + await verifyUserPendingEmailInteractor( + applicationContext, + { + token: mockPetitioner.pendingEmailVerificationToken, + }, + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().updateUser.mock.calls[0][0] diff --git a/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts b/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts index b22c6b41dd5..af620f47270 100644 --- a/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts +++ b/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts @@ -5,14 +5,14 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '../../../errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { updateUserPendingEmailRecord } from '@web-api/business/useCases/auth/changePasswordInteractor'; export const verifyUserPendingEmailInteractor = async ( applicationContext: ServerApplicationContext, { token }: { token: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.EMAIL_MANAGEMENT)) { throw new UnauthorizedError('Unauthorized to manage emails.'); } diff --git a/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.test.ts b/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.test.ts index 62314160aeb..cd4fbfbf1db 100644 --- a/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.test.ts +++ b/web-api/src/business/useCases/workItems/assignWorkItemsInteractor.test.ts @@ -42,7 +42,6 @@ describe('assignWorkItemsInteractor', () => { updatedAt: '2018-12-27T18:06:02.968Z', workItemId: '78de1ba3-add3-4329-8372-ce37bda6bc93', }; - applicationContext.getCurrentUser.mockReturnValue(mockDocketClerkUser); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ ...mockDocketClerkUser, diff --git a/web-api/src/lambdas/users/verifyUserPendingEmailLambda.ts b/web-api/src/lambdas/users/verifyUserPendingEmailLambda.ts index d34fc6f819c..4806d00fb46 100644 --- a/web-api/src/lambdas/users/verifyUserPendingEmailLambda.ts +++ b/web-api/src/lambdas/users/verifyUserPendingEmailLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { verifyUserPendingEmailInteractor } from '@web-api/business/useCases/user/verifyUserPendingEmailInteractor'; /** * verifies the user pending email @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const verifyUserPendingEmailLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .verifyUserPendingEmailInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const verifyUserPendingEmailLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await verifyUserPendingEmailInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 7a396922398b5647efb984713e55ae0fa813e527 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 08:56:39 -0500 Subject: [PATCH 206/523] 10417 remove getCurrentUser from caseInformationHelper cleanup --- .../computeds/caseInformationHelper.test.ts | 55 +++++-------------- .../computeds/caseInformationHelper.ts | 2 +- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/web-client/src/presenter/computeds/caseInformationHelper.test.ts b/web-client/src/presenter/computeds/caseInformationHelper.test.ts index 7f45b48a88c..e77f76c3edd 100644 --- a/web-client/src/presenter/computeds/caseInformationHelper.test.ts +++ b/web-client/src/presenter/computeds/caseInformationHelper.test.ts @@ -6,54 +6,30 @@ import { import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { caseInformationHelper as caseInformationHelperComputed } from './caseInformationHelper'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; +import { + mockAdcUser as mockAdc, + mockDocketClerkUser as mockDocketClerk, + mockJudgeUser as mockJudge, + mockPetitionerUser as mockPetitioner, + mockPetitionsClerkUser as mockPetitionsClerk, + mockPrivatePractitionerUser as mockPrivatePractitioner, +} from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; describe('caseInformationHelper', () => { - const mockPetitionsClerk = { - role: ROLES.petitionsClerk, - userId: '0dd60083-ab1f-4a43-95f8-bfbc69b48777', - }; - const mockDocketClerk = { - role: ROLES.docketClerk, - userId: 'a09053ab-58c7-4384-96a1-bd5fbe14977a', - }; - const mockPetitioner = { - role: ROLES.petitioner, - userId: 'f94cef8e-17b8-4504-9296-af911b32020a', - }; - const mockPrivatePractitioner = { - role: ROLES.privatePractitioner, - userId: '39f7c7ee-ab75-492a-a4ee-63755a24e845', - }; - const mockAdc = { - role: ROLES.adc, - userId: '11e15c96-6705-4083-8e10-1c20664ac1ae', - }; - const mockJudge = { - role: ROLES.judge, - userId: '12e15c96-6705-4083-8e10-1c20664ac1ae', - }; - const caseInformationHelper = withAppContextDecorator( caseInformationHelperComputed, applicationContext, ); const getBaseState = user => { - mockUser = { ...user }; return { permissions: getUserPermissions(user), + user, }; }; - let mockUser; - - beforeEach(() => { - mockUser = {}; - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - }); - describe('formattedPetitioners', () => { let baseState; @@ -125,6 +101,7 @@ describe('caseInformationHelper', () => { }); it('should be true when the user is an internal user with permissions to edit counsel', () => { + let state = getBaseState(mockDocketClerk); const result = runCompute(caseInformationHelper, { state: { ...getBaseState(mockDocketClerk), @@ -135,6 +112,8 @@ describe('caseInformationHelper', () => { }, }); + console.debug('********************', state); + expect(result.showAddCounsel).toEqual(true); }); @@ -318,7 +297,7 @@ describe('caseInformationHelper', () => { [ROLES.docketClerk, ROLES.petitionsClerk, ROLES.admissionsClerk].forEach( role => { it('should be true when the user has permission to edit petitioner counsel and there are privatePractitioners on the case', () => { - mockUser = { ...mockDocketClerk, role }; + let mockUser = { ...mockDocketClerk, role }; const result = runCompute(caseInformationHelper, { state: { @@ -338,11 +317,9 @@ describe('caseInformationHelper', () => { ); it('should be false when the user is an internal user that does NOT have permission to edit petitioner counsel', () => { - mockUser = { ...mockAdc }; - const result = runCompute(caseInformationHelper, { state: { - ...getBaseState(mockUser), + ...getBaseState(mockAdc), caseDetail: { irsPractitioners: [{ userId: '2' }], petitioners: [], @@ -356,11 +333,9 @@ describe('caseInformationHelper', () => { }); it('should be false when there are no privatePractitioners on the case', () => { - mockUser = { ...mockDocketClerk }; - const result = runCompute(caseInformationHelper, { state: { - ...getBaseState(mockUser), + ...getBaseState(mockDocketClerk), caseDetail: { irsPractitioners: [{ userId: '2' }], petitioners: [], diff --git a/web-client/src/presenter/computeds/caseInformationHelper.ts b/web-client/src/presenter/computeds/caseInformationHelper.ts index 8861ec49f42..d011bebabe8 100644 --- a/web-client/src/presenter/computeds/caseInformationHelper.ts +++ b/web-client/src/presenter/computeds/caseInformationHelper.ts @@ -8,7 +8,7 @@ export const caseInformationHelper = ( ): any => { const { STATUS_TYPES } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const caseDetail = get(state.caseDetail); const permissions = get(state.permissions); const isInternalUser = applicationContext From 72c9b6025ff22c304349ad6e3cdafc76028d3447 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:09:34 -0500 Subject: [PATCH 207/523] 10417: remove getCurrentUser from updateUserPendingEmailInteractor --- .../updateUserPendingEmailInteractor.test.ts | 102 +++++++++++------- .../user/updateUserPendingEmailInteractor.ts | 4 +- .../user/verifyUserPendingEmailInteractor.ts | 2 +- .../users/updateUserPendingEmailLambda.ts | 27 +++-- 4 files changed, 85 insertions(+), 50 deletions(-) diff --git a/web-api/src/business/useCases/user/updateUserPendingEmailInteractor.test.ts b/web-api/src/business/useCases/user/updateUserPendingEmailInteractor.test.ts index 9b3a884d591..9d14b127d1a 100644 --- a/web-api/src/business/useCases/user/updateUserPendingEmailInteractor.test.ts +++ b/web-api/src/business/useCases/user/updateUserPendingEmailInteractor.test.ts @@ -1,6 +1,10 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { updateUserPendingEmailInteractor } from './updateUserPendingEmailInteractor'; import { validUser } from '../../../../../shared/src/test/mockUsers'; @@ -11,6 +15,7 @@ describe('updateUserPendingEmailInteractor', () => { beforeEach(() => { mockUser = { ...validUser, + ...mockPrivatePractitionerUser, admissionsDate: '2019-03-01', admissionsStatus: 'Active', barNumber: 'RA3333', @@ -22,10 +27,8 @@ describe('updateUserPendingEmailInteractor', () => { originalBarState: 'FL', practiceType: 'Private', practitionerType: 'Attorney', - role: ROLES.privatePractitioner, }; - applicationContext.getCurrentUser.mockImplementation(() => mockUser); applicationContext .getPersistenceGateway() .getUserById.mockImplementation(() => mockUser); @@ -38,15 +41,14 @@ describe('updateUserPendingEmailInteractor', () => { }); it('should throw unauthorized error when user does not have permission to manage emails', async () => { - mockUser = { - role: ROLES.petitionsClerk, - userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', - }; - await expect( - updateUserPendingEmailInteractor(applicationContext, { - pendingEmail, - }), + updateUserPendingEmailInteractor( + applicationContext, + { + pendingEmail, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -56,24 +58,24 @@ describe('updateUserPendingEmailInteractor', () => { .isEmailAvailable.mockReturnValue(false); await expect( - updateUserPendingEmailInteractor(applicationContext, { - pendingEmail, - }), + updateUserPendingEmailInteractor( + applicationContext, + { + pendingEmail, + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Email is not available'); }); - it('should make a call to get the current user', async () => { - await updateUserPendingEmailInteractor(applicationContext, { - pendingEmail, - }); - - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it('should make a call to getUserById with the logged in user.userId', async () => { - await updateUserPendingEmailInteractor(applicationContext, { - pendingEmail, - }); + await updateUserPendingEmailInteractor( + applicationContext, + { + pendingEmail, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getPersistenceGateway().getUserById.mock.calls[0][0], @@ -81,9 +83,13 @@ describe('updateUserPendingEmailInteractor', () => { }); it('should update the user record in persistence with the pendingEmail value', async () => { - await updateUserPendingEmailInteractor(applicationContext, { - pendingEmail, - }); + await updateUserPendingEmailInteractor( + applicationContext, + { + pendingEmail, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getPersistenceGateway().updateUser.mock.calls[0][0] @@ -92,24 +98,38 @@ describe('updateUserPendingEmailInteractor', () => { }); it('should return the updated User entity when currentUser.role is petitioner', async () => { - mockUser = validUser; + const mockUserPetitioner = { ...validUser, ...mockPetitionerUser }; + applicationContext + .getPersistenceGateway() + .getUserById.mockReturnValueOnce(mockUserPetitioner); + applicationContext + .getPersistenceGateway() + .updateUser.mockReturnValueOnce(mockUserPetitioner); - const results = await updateUserPendingEmailInteractor(applicationContext, { - pendingEmail, - }); + const results = await updateUserPendingEmailInteractor( + applicationContext, + { + pendingEmail, + }, + mockPetitionerUser, + ); expect(results.entityName).toBe('User'); expect(results).toMatchObject({ - ...mockUser, + ...mockUserPetitioner, pendingEmail, pendingEmailVerificationToken: expect.anything(), }); }); it('should return the updated Practitioner entity when currentUser.role is NOT petitioner', async () => { - const results = await updateUserPendingEmailInteractor(applicationContext, { - pendingEmail, - }); + const results = await updateUserPendingEmailInteractor( + applicationContext, + { + pendingEmail, + }, + mockPrivatePractitionerUser, + ); expect(results.entityName).toBe('Practitioner'); expect(results).toMatchObject({ @@ -120,9 +140,13 @@ describe('updateUserPendingEmailInteractor', () => { }); it('should call applicationContext.getUseCaseHelpers().sendEmailVerificationLink to send the verification link to the user', async () => { - await updateUserPendingEmailInteractor(applicationContext, { - pendingEmail, - }); + await updateUserPendingEmailInteractor( + applicationContext, + { + pendingEmail, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getUseCaseHelpers().sendEmailVerificationLink.mock diff --git a/web-api/src/business/useCases/user/updateUserPendingEmailInteractor.ts b/web-api/src/business/useCases/user/updateUserPendingEmailInteractor.ts index aa245f72cfc..0f124682fd2 100644 --- a/web-api/src/business/useCases/user/updateUserPendingEmailInteractor.ts +++ b/web-api/src/business/useCases/user/updateUserPendingEmailInteractor.ts @@ -6,6 +6,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; /** @@ -20,9 +21,8 @@ import { User } from '../../../../../shared/src/business/entities/User'; export const updateUserPendingEmailInteractor = async ( applicationContext: ServerApplicationContext, { pendingEmail }: { pendingEmail: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.EMAIL_MANAGEMENT)) { throw new UnauthorizedError('Unauthorized to manage emails.'); } diff --git a/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts b/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts index af620f47270..5ba90907e8e 100644 --- a/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts +++ b/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts @@ -61,7 +61,7 @@ export const verifyUserPendingEmailInteractor = async ( message: { payload: { user: updatedUser }, type: MESSAGE_TYPES.QUEUE_UPDATE_ASSOCIATED_CASES, - user: applicationContext.getCurrentUser(), + user: authorizedUser, }, }); }; diff --git a/web-api/src/lambdas/users/updateUserPendingEmailLambda.ts b/web-api/src/lambdas/users/updateUserPendingEmailLambda.ts index bf615dfb526..2d2c52603ed 100644 --- a/web-api/src/lambdas/users/updateUserPendingEmailLambda.ts +++ b/web-api/src/lambdas/users/updateUserPendingEmailLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateUserPendingEmailInteractor } from '@web-api/business/useCases/user/updateUserPendingEmailInteractor'; /** * updates the user pending email @@ -6,11 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateUserPendingEmailLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateUserPendingEmailInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const updateUserPendingEmailLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await updateUserPendingEmailInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 2720a6aaa69447ffaf5afab9d5d8cbbd8a891d9c Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 09:32:19 -0500 Subject: [PATCH 208/523] 10417 remove getcurrentuser from caseSearchBoxHelper --- .../computeds/caseSearchBoxHelper.test.ts | 41 +++++-------------- .../computeds/caseSearchBoxHelper.ts | 3 +- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/web-client/src/presenter/computeds/caseSearchBoxHelper.test.ts b/web-client/src/presenter/computeds/caseSearchBoxHelper.test.ts index c2a1257576e..ad9e3ccb404 100644 --- a/web-client/src/presenter/computeds/caseSearchBoxHelper.test.ts +++ b/web-client/src/presenter/computeds/caseSearchBoxHelper.test.ts @@ -1,6 +1,10 @@ -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { caseSearchBoxHelper as caseSearchBoxHelperComputed } from './caseSearchBoxHelper'; +import { + irsPractitionerUser, + irsSuperuserUser, + petitionerUser, +} from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -11,65 +15,40 @@ const caseSearchBoxHelper = withAppContextDecorator( describe('caseSearchBoxHelper', () => { it('should return showSearchDescription true if the user role is not irsSuperuser', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.irsPractitioner, - userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', - }); - const result = runCompute(caseSearchBoxHelper, { - state: {}, + state: { user: irsPractitionerUser }, }); expect(result.showSearchDescription).toBe(true); }); it('should return showSearchDescription false if the user role is irsSuperuser', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.irsSuperuser, - userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', - }); - const result = runCompute(caseSearchBoxHelper, { - state: {}, + state: { user: irsSuperuserUser }, }); expect(result.showSearchDescription).toBe(false); }); it('should return showSearchDescription false if the user role is petitioner', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.petitioner, - userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', - }); - const result = runCompute(caseSearchBoxHelper, { - state: {}, + state: { user: petitionerUser }, }); expect(result.showSearchDescription).toBe(false); }); it('should return showAdvancedSearch true if the user role is not petitioner', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.irsPractitioner, - userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', - }); - const result = runCompute(caseSearchBoxHelper, { - state: {}, + state: { user: irsPractitionerUser }, }); expect(result.showAdvancedSearch).toBe(true); }); it('should return showAdvancedSearch false if the user role is petitioner', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.petitioner, - userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', - }); - const result = runCompute(caseSearchBoxHelper, { - state: {}, + state: { user: petitionerUser }, }); expect(result.showAdvancedSearch).toBe(false); diff --git a/web-client/src/presenter/computeds/caseSearchBoxHelper.ts b/web-client/src/presenter/computeds/caseSearchBoxHelper.ts index 270196c004d..f7624bfa47f 100644 --- a/web-client/src/presenter/computeds/caseSearchBoxHelper.ts +++ b/web-client/src/presenter/computeds/caseSearchBoxHelper.ts @@ -1,10 +1,11 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; import { Get } from 'cerebral'; +import { state } from '@web-client/presenter/app.cerebral'; export const caseSearchBoxHelper = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); let showSearchDescription = true; From 966aee1a6d7f8054b429037307055b90112cfa1d Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:45:48 -0500 Subject: [PATCH 209/523] 10417: remove getCurrentUser from updatePetitionerInformationInteractor --- ...Interactor.createWorkItemForChange.test.ts | 18 +- ...tionInteractor.getIsUserAuthorized.test.ts | 25 +- ...atePetitionerInformationInteractor.test.ts | 468 ++++++++++-------- .../updatePetitionerInformationInteractor.ts | 18 +- .../updatePetitionerInformationLambda.ts | 29 +- 5 files changed, 315 insertions(+), 243 deletions(-) diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.createWorkItemForChange.test.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.createWorkItemForChange.test.ts index 0c1ebb4727e..1e8c9eecde9 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.createWorkItemForChange.test.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.createWorkItemForChange.test.ts @@ -5,19 +5,15 @@ import { SERVICE_INDICATOR_TYPES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; -import { - MOCK_PRACTITIONER, - docketClerkUser, -} from '../../../../../shared/src/test/mockUsers'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { MOCK_PRACTITIONER } from '../../../../../shared/src/test/mockUsers'; import { UserCase } from '../../../../../shared/src/business/entities/UserCase'; import { addCoverToPdf } from '@web-api/business/useCases/addCoverToPdf'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { updatePetitionerInformationInteractor } from './updatePetitionerInformationInteractor'; jest.mock('@web-api/business/useCases/addCoverToPdf'); describe('updatePetitionerInformationInteractor createWorkItemForChange', () => { - let mockUser; let mockCase; const PRIMARY_CONTACT_ID = MOCK_CASE.petitioners[0].contactId; @@ -43,10 +39,6 @@ describe('updatePetitionerInformationInteractor createWorkItemForChange', () => beforeAll(() => { (addCoverToPdf as jest.Mock).mockResolvedValue({}); - applicationContext.getCurrentUser.mockImplementation( - () => new User(mockUser), - ); - applicationContext .getUseCaseHelpers() .addExistingUserToCase.mockImplementation(({ caseEntity }) => caseEntity); @@ -57,8 +49,6 @@ describe('updatePetitionerInformationInteractor createWorkItemForChange', () => }); beforeEach(() => { - mockUser = docketClerkUser; - mockCase = { ...MOCK_CASE, petitioners: mockPetitioners, @@ -93,6 +83,7 @@ describe('updatePetitionerInformationInteractor createWorkItemForChange', () => address1: 'A Changed Street', }, }, + mockDocketClerkUser, ); const noticeOfChangeDocketEntryWithWorkItem = @@ -126,6 +117,7 @@ describe('updatePetitionerInformationInteractor createWorkItemForChange', () => address1: 'A Changed Street', }, }, + mockDocketClerkUser, ); const noticeOfChangeDocketEntryWithWorkItem = @@ -159,6 +151,7 @@ describe('updatePetitionerInformationInteractor createWorkItemForChange', () => serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }, }, + mockDocketClerkUser, ); const noticeOfChangeDocketEntryWithWorkItem = @@ -194,6 +187,7 @@ describe('updatePetitionerInformationInteractor createWorkItemForChange', () => address1: 'A Changed Street', }, }, + mockDocketClerkUser, ); const noticeOfChangeDocketEntryWithWorkItem = diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.getIsUserAuthorized.test.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.getIsUserAuthorized.test.ts index ef1c140baee..8969692afe4 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.getIsUserAuthorized.test.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.getIsUserAuthorized.test.ts @@ -1,17 +1,16 @@ import { CASE_STATUS_TYPES, CONTACT_TYPES, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; -import { - MOCK_PRACTITIONER, - docketClerkUser, -} from '../../../../../shared/src/test/mockUsers'; +import { MOCK_PRACTITIONER } from '../../../../../shared/src/test/mockUsers'; import { getIsUserAuthorized } from './updatePetitionerInformationInteractor'; +import { + mockPetitionerUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('updatePetitionerInformationInteractor getIsUserAuthorized', () => { - let mockUser; let mockCase; const SECONDARY_CONTACT_ID = '56387318-0092-49a3-8cc1-921b0432bd16'; @@ -35,8 +34,6 @@ describe('updatePetitionerInformationInteractor getIsUserAuthorized', () => { }; beforeEach(() => { - mockUser = docketClerkUser; - mockCase = { ...MOCK_CASE, petitioners: mockPetitioners, @@ -51,8 +48,7 @@ describe('updatePetitionerInformationInteractor getIsUserAuthorized', () => { oldCase: mockCase, updatedPetitionerData: {}, user: { - ...mockUser, - role: ROLES.privatePractitioner, + ...mockPrivatePractitionerUser, userId: 'a003e912-7b2f-4d2f-bf00-b99ec0d29de1', }, }); @@ -65,8 +61,7 @@ describe('updatePetitionerInformationInteractor getIsUserAuthorized', () => { oldCase: mockCase, updatedPetitionerData: {}, user: { - ...mockUser, - role: ROLES.petitioner, + ...mockPetitionerUser, userId: 'a003e912-7b2f-4d2f-bf00-b99ec0d29de1', }, }); @@ -79,8 +74,7 @@ describe('updatePetitionerInformationInteractor getIsUserAuthorized', () => { oldCase: mockCase, updatedPetitionerData: { contactId: SECONDARY_CONTACT_ID }, user: { - ...mockUser, - role: ROLES.petitioner, + ...mockPetitionerUser, userId: SECONDARY_CONTACT_ID, }, }); @@ -103,8 +97,7 @@ describe('updatePetitionerInformationInteractor getIsUserAuthorized', () => { }, updatedPetitionerData: { contactId: SECONDARY_CONTACT_ID }, user: { - ...mockUser, - role: ROLES.privatePractitioner, + ...mockPrivatePractitionerUser, userId: SECONDARY_CONTACT_ID, }, }); diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts index dac48e49409..51cc0daf85d 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts @@ -19,18 +19,21 @@ import { } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; import { UserCase } from '../../../../../shared/src/business/entities/UserCase'; import { addCoverToPdf } from '@web-api/business/useCases/addCoverToPdf'; import { addExistingUserToCase } from '../../useCaseHelper/caseAssociation/addExistingUserToCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { calculateISODate } from '../../../../../shared/src/business/utilities/DateHandler'; -import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { + mockAdmissionsClerkUser, + mockDocketClerkUser, + mockPetitionerUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { updatePetitionerInformationInteractor } from './updatePetitionerInformationInteractor'; jest.mock('@web-api/business/useCases/addCoverToPdf'); describe('updatePetitionerInformationInteractor', () => { - let mockUser; let mockCase; const PRIMARY_CONTACT_ID = MOCK_CASE.petitioners[0].contactId; @@ -52,10 +55,6 @@ describe('updatePetitionerInformationInteractor', () => { beforeAll(() => { (addCoverToPdf as jest.Mock).mockResolvedValue({}); - applicationContext.getCurrentUser.mockImplementation( - () => new User(mockUser), - ); - applicationContext .getUseCaseHelpers() .addExistingUserToCase.mockReturnValue(PRIMARY_CONTACT_ID); @@ -70,7 +69,6 @@ describe('updatePetitionerInformationInteractor', () => { beforeEach(() => { mockLock = undefined; - mockUser = docketClerkUser; mockCase = { ...MOCK_CASE, @@ -85,19 +83,19 @@ describe('updatePetitionerInformationInteractor', () => { }); it('should throw an error when the user making the request does not have permission to edit petition details', async () => { - mockUser = { ...mockUser, role: ROLES.petitioner }; - await expect( - updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: {}, - }), + updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: {}, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for editing petition details'); }); it('should throw an error when the user making the request is a private practitioner not associated with the case', async () => { - mockUser = { ...mockUser, role: ROLES.privatePractitioner }; - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValueOnce({ @@ -106,24 +104,18 @@ describe('updatePetitionerInformationInteractor', () => { }); await expect( - updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: {}, - }), + updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: {}, + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Unauthorized for editing petition details'); }); it('should not throw an error when the user making the request is a private practitioner who is associated with the case', async () => { - const mockRepresentingId = '1a061240-1320-47c5-9f54-0ff975045d84'; - applicationContext.getCurrentUser.mockImplementationOnce( - () => - new User({ - ...mockUser, - role: ROLES.privatePractitioner, - userId: mockRepresentingId, - }), - ); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValueOnce({ @@ -134,19 +126,23 @@ describe('updatePetitionerInformationInteractor', () => { name: 'Example Practitioner', representing: [PRIMARY_CONTACT_ID], role: ROLES.privatePractitioner, - userId: mockRepresentingId, + userId: mockPrivatePractitionerUser.userId, }, ], }); await expect( - updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - countryType: COUNTRY_TYPES.DOMESTIC, + updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + countryType: COUNTRY_TYPES.DOMESTIC, + }, }, - }), + mockPrivatePractitionerUser, + ), ).resolves.toBeDefined(); }); @@ -154,13 +150,17 @@ describe('updatePetitionerInformationInteractor', () => { const mockNotFoundContactId = 'cd37d820-cbde-4591-8b5a-dc74da12f2a2'; // this contactId is not on the case await expect( - updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - contactId: mockNotFoundContactId, - countryType: COUNTRY_TYPES.DOMESTIC, + updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + contactId: mockNotFoundContactId, + countryType: COUNTRY_TYPES.DOMESTIC, + }, }, - }), + mockDocketClerkUser, + ), ).rejects.toThrow( `Case contact with id ${mockNotFoundContactId} was not found on the case`, ); @@ -173,13 +173,17 @@ describe('updatePetitionerInformationInteractor', () => { }; await expect( - updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - contactId: PRIMARY_CONTACT_ID, - countryType: COUNTRY_TYPES.DOMESTIC, + updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + contactId: PRIMARY_CONTACT_ID, + countryType: COUNTRY_TYPES.DOMESTIC, + }, }, - }), + mockDocketClerkUser, + ), ).rejects.toThrow( `Case with docketNumber ${mockCase.docketNumber} has not been served`, ); @@ -187,13 +191,17 @@ describe('updatePetitionerInformationInteractor', () => { it('should throw an error when the contact to update is not valid', async () => { await expect( - updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - contactId: PRIMARY_CONTACT_ID, - countryType: COUNTRY_TYPES.DOMESTIC, + updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + contactId: PRIMARY_CONTACT_ID, + countryType: COUNTRY_TYPES.DOMESTIC, + }, }, - }), + mockDocketClerkUser, + ), ).rejects.toThrow('Case entity was invalid'); expect( @@ -210,14 +218,18 @@ describe('updatePetitionerInformationInteractor', () => { .getUseCaseHelpers() .countPagesInDocument.mockReturnValue(mockNumberOfPages); - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - address1: 'changed address', - contactId: mockPetitioners[0].contactId, + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + address1: 'changed address', + contactId: mockPetitioners[0].contactId, + }, }, - }); + mockDocketClerkUser, + ); const autoGeneratedDocument = applicationContext .getPersistenceGateway() @@ -244,21 +256,25 @@ describe('updatePetitionerInformationInteractor', () => { }); it('should update contact information even when the update is changing a value to null', async () => { - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - address1: '989 Division St', - city: 'Somewhere', - contactId: mockPetitioners[0].contactId, - countryType: COUNTRY_TYPES.DOMESTIC, - name: 'Test Primary Petitioner', - phone: '1234568', - postalCode: '12345', - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, - state: 'TN', - title: 'Executor', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + address1: '989 Division St', + city: 'Somewhere', + contactId: mockPetitioners[0].contactId, + countryType: COUNTRY_TYPES.DOMESTIC, + name: 'Test Primary Petitioner', + phone: '1234568', + postalCode: '12345', + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, + state: 'TN', + title: 'Executor', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -276,6 +292,7 @@ describe('updatePetitionerInformationInteractor', () => { address1: 'A Changed Street', }, }, + mockDocketClerkUser, ); const noticeOfChangeDocketEntryWithWorkItem = @@ -295,6 +312,7 @@ describe('updatePetitionerInformationInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }, }, + mockDocketClerkUser, ); expect( @@ -319,6 +337,7 @@ describe('updatePetitionerInformationInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }, }, + mockDocketClerkUser, ); expect( @@ -334,13 +353,17 @@ describe('updatePetitionerInformationInteractor', () => { }); it('should not update petitioner email even when it is provided', async () => { - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - email: 'test2@example.com', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + email: 'test2@example.com', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -352,12 +375,16 @@ describe('updatePetitionerInformationInteractor', () => { mockPetitioners[0].paperPetitionEmail = 'paperPetitionEmail@example.com'; mockPetitioners[0].hasConsentedToEService = true; - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -371,13 +398,17 @@ describe('updatePetitionerInformationInteractor', () => { it('should update petitioner additionalName when it is passed in', async () => { const mockAdditionalName = 'Tina Belcher'; - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - additionalName: mockAdditionalName, + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + additionalName: mockAdditionalName, + }, }, - }); + mockDocketClerkUser, + ); const updatedPetitioners = applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -393,13 +424,17 @@ describe('updatePetitionerInformationInteractor', () => { }; const otherFilerToUpdate = getOtherFilers(mockCase)[0]; - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE_WITH_SECONDARY_OTHERS.docketNumber, - updatedPetitionerData: { - ...otherFilerToUpdate, - contactType: CONTACT_TYPES.otherPetitioner, + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE_WITH_SECONDARY_OTHERS.docketNumber, + updatedPetitionerData: { + ...otherFilerToUpdate, + contactType: CONTACT_TYPES.otherPetitioner, + }, }, - }); + mockDocketClerkUser, + ); const updatedPetitioners = applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -413,14 +448,18 @@ describe('updatePetitionerInformationInteractor', () => { it('should throw an error when attempting to update countryType to an invalid value', async () => { await expect( - updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - countryType: 'alien', - serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, + updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + countryType: 'alien', + serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, + }, }, - }), + mockDocketClerkUser, + ), ).rejects.toThrow('The Case entity was invalid'); expect( @@ -440,14 +479,18 @@ describe('updatePetitionerInformationInteractor', () => { ], }; - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockCase.petitioners[0], - address1: '456 Center St TEST', - isAddressSealed: true, + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockCase.petitioners[0], + address1: '456 Center St TEST', + isAddressSealed: true, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda, @@ -455,15 +498,19 @@ describe('updatePetitionerInformationInteractor', () => { }); it('should use original case caption to create case title when creating work item', async () => { - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - address1: 'changed address', - contactId: mockPetitioners[0].contactId, - name: 'Test Person22222', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + address1: 'changed address', + contactId: mockPetitioners[0].contactId, + name: 'Test Person22222', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem.mock.calls[0][0] @@ -481,13 +528,17 @@ describe('updatePetitionerInformationInteractor', () => { closedDate: '2018-01-01T05:00:00.000Z', status: 'Closed', })); - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - address1: 'changed address', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + address1: 'changed address', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().generateAndServeDocketEntry, @@ -514,15 +565,19 @@ describe('updatePetitionerInformationInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockImplementation(() => mockCase); - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - address1: 'changed address', - contactId: mockPetitioners[0].contactId, - name: 'Test Person22222', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + address1: 'changed address', + contactId: mockPetitioners[0].contactId, + name: 'Test Person22222', + }, }, - }); + mockDocketClerkUser, + ); expect(updatePetitionerSpy).toHaveBeenCalled(); expect( @@ -540,14 +595,18 @@ describe('updatePetitionerInformationInteractor', () => { .getPersistenceGateway() .getUserById.mockReturnValue(unverifiedNewPetitioner); - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - email: undefined, - updatedEmail: 'testing@example.com', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + email: undefined, + updatedEmail: 'testing@example.com', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().generateAndServeDocketEntry, @@ -574,15 +633,19 @@ describe('updatePetitionerInformationInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockImplementation(() => mockCase); - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - address1: 'changed address', - contactId: mockPetitioners[0].contactId, - name: 'Test Person22222', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + address1: 'changed address', + contactId: mockPetitioners[0].contactId, + name: 'Test Person22222', + }, }, - }); + mockDocketClerkUser, + ); expect(updatePetitionerSpy).toHaveBeenCalled(); expect( @@ -598,19 +661,6 @@ describe('updatePetitionerInformationInteractor', () => { userId: applicationContext.getUniqueId(), }; beforeAll(() => { - const admissionsClerkUser = { - email: 'admissionsclerk@example.com', - entityName: 'User', - name: 'Test Admissions Clerk', - role: 'admissionsclerk', - section: 'admissions', - userId: '9d7d63b7-d7a5-4905-ba89-ef71bf30057f', - }; - - applicationContext.getCurrentUser.mockImplementation( - () => new User(admissionsClerkUser), - ); - applicationContext .getUserGateway() .getUserByEmail.mockReturnValue('someMockId'); @@ -650,13 +700,17 @@ describe('updatePetitionerInformationInteractor', () => { ), }); - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - updatedEmail: mockUpdatedEmail, + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + updatedEmail: mockUpdatedEmail, + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().addExistingUserToCase, @@ -671,10 +725,14 @@ describe('updatePetitionerInformationInteractor', () => { }); it('should not call the update addExistingUserToCase use case helper when the petitioner is unchanged', async () => { - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: mockPetitioners[0], - }); + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: mockPetitioners[0], + }, + mockAdmissionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().addExistingUserToCase, @@ -686,13 +744,17 @@ describe('updatePetitionerInformationInteractor', () => { .getPersistenceGateway() .isEmailAvailable.mockImplementation(() => false); - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - updatedEmail: 'changed-email@example.com', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + updatedEmail: 'changed-email@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().createUserForContact, @@ -708,13 +770,17 @@ describe('updatePetitionerInformationInteractor', () => { .getPersistenceGateway() .isEmailAvailable.mockImplementation(() => true); - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - updatedEmail: 'changed-email@example.com', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + updatedEmail: 'changed-email@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().createUserForContact, @@ -730,13 +796,17 @@ describe('updatePetitionerInformationInteractor', () => { mockLock = MOCK_LOCK; await expect( - updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - updatedEmail: 'changed-email@example.com', + updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + updatedEmail: 'changed-email@example.com', + }, }, - }), + mockAdmissionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -745,13 +815,17 @@ describe('updatePetitionerInformationInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await updatePetitionerInformationInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - updatedPetitionerData: { - ...mockPetitioners[0], - updatedEmail: 'changed-email@example.com', + await updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: { + ...mockPetitioners[0], + updatedEmail: 'changed-email@example.com', + }, }, - }); + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts index 2855c82dcdb..d716e2b6017 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts @@ -14,6 +14,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; import { defaults, pick } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -108,9 +109,8 @@ const updateCaseEntityAndGenerateChange = async ({ export const updatePetitionerInformation = async ( applicationContext: ServerApplicationContext, { docketNumber, updatedPetitionerData }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - const oldCase = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); @@ -118,7 +118,7 @@ export const updatePetitionerInformation = async ( const hasAuthorization = getIsUserAuthorized({ oldCase, updatedPetitionerData, - user, + user: authorizedUser, }); if (!hasAuthorization) { @@ -176,7 +176,7 @@ export const updatePetitionerInformation = async ( { ...oldCase, }, - { authorizedUser: user }, + { authorizedUser }, ); caseToUpdateContacts.updatePetitioner({ @@ -197,7 +197,7 @@ export const updatePetitionerInformation = async ( { ...caseToUpdateContacts.toRawObject(), }, - { authorizedUser: user }, + { authorizedUser }, ).validate(); const servedParties = aggregatePartiesForService(caseEntity); @@ -232,7 +232,7 @@ export const updatePetitionerInformation = async ( oldData, privatePractitionersRepresentingContact, servedParties, - user, + user: authorizedUser, }); serviceUrl = url; } @@ -253,7 +253,7 @@ export const updatePetitionerInformation = async ( .getUseCaseHelpers() .createUserForContact({ applicationContext, - authorizedUser: user, + authorizedUser, caseEntity, contactId: updatedPetitionerData.contactId, email: updatedPetitionerData.updatedEmail, @@ -264,7 +264,7 @@ export const updatePetitionerInformation = async ( .getUseCaseHelpers() .addExistingUserToCase({ applicationContext, - authorizedUser: user, + authorizedUser, caseEntity, contactId: updatedPetitionerData.contactId, email: updatedPetitionerData.updatedEmail, @@ -286,7 +286,7 @@ export const updatePetitionerInformation = async ( applicationContext, caseEntity, petitionerOnCase: oldCaseContact, - user, + user: authorizedUser, userHasAnEmail: userToUpdate.email, }); } diff --git a/web-api/src/lambdas/cases/updatePetitionerInformationLambda.ts b/web-api/src/lambdas/cases/updatePetitionerInformationLambda.ts index 75723fa8283..6f725a4d486 100644 --- a/web-api/src/lambdas/cases/updatePetitionerInformationLambda.ts +++ b/web-api/src/lambdas/cases/updatePetitionerInformationLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updatePetitionerInformationInteractor } from '@web-api/business/useCases/user/updatePetitionerInformationInteractor'; /** * used for updating a case's petitioner information @@ -6,12 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updatePetitionerInformationLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updatePetitionerInformationInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const updatePetitionerInformationLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await updatePetitionerInformationInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 541f23c3f47f48b16e47baf86b023ab75fa062e3 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:00:28 -0500 Subject: [PATCH 210/523] 10417: remove getCurrentUser from getUsersInSectionInteractor --- .../user/getUsersInSectionInteractor.test.ts | 70 ++++++++----------- .../user/getUsersInSectionInteractor.ts | 5 +- .../lambdas/users/getUsersInSectionLambda.ts | 29 +++++--- 3 files changed, 54 insertions(+), 50 deletions(-) diff --git a/web-api/src/business/useCases/user/getUsersInSectionInteractor.test.ts b/web-api/src/business/useCases/user/getUsersInSectionInteractor.test.ts index 21008ee4495..0639d2f815b 100644 --- a/web-api/src/business/useCases/user/getUsersInSectionInteractor.test.ts +++ b/web-api/src/business/useCases/user/getUsersInSectionInteractor.test.ts @@ -1,49 +1,43 @@ import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors'; -import { - PETITIONS_SECTION, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { PETITIONS_SECTION } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getUsersInSectionInteractor } from './getUsersInSectionInteractor'; +import { + mockDocketClerkUser, + mockJudgeUser, + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('Get users in section', () => { const MOCK_SECTION = [ + mockPetitionerUser, { - name: 'Test Petitioner 1', - role: ROLES.petitioner, - userId: '304a756b-ce23-438a-a9bb-3732c6a439b7', - }, - { - name: 'Test Petitioner 2', - role: ROLES.petitioner, + ...mockPetitionerUser, + name: 'Tax Payer 2', userId: 'a79d2fac-aa2c-4183-9877-01ab1cdff127', }, ]; const MOCK_JUDGE_SECTION = [ { + ...mockJudgeUser, isSeniorJudge: false, judgeFullName: 'Test Judge 1', judgeTitle: 'Judge', name: 'Test Judge 1', - role: ROLES.judge, - userId: 'ce5add74-1559-448d-a67d-c887c8351b2e', }, { + ...mockJudgeUser, isSeniorJudge: false, judgeFullName: 'Test Judge 1', judgeTitle: 'Judge', name: 'Test Judge 2', - role: ROLES.judge, userId: 'ea83cea2-5ce9-451d-b3d6-1e7c0e51d311', }, ]; it('retrieves the users in the petitions section', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', - }); applicationContext .getPersistenceGateway() .getUsersInSection.mockReturnValue(MOCK_SECTION); @@ -52,24 +46,25 @@ describe('Get users in section', () => { const section = await getUsersInSectionInteractor( applicationContext, sectionToGet, + mockPetitionsClerkUser, ); expect(section.length).toEqual(2); - expect(section[0].name).toEqual('Test Petitioner 1'); + expect(section[0].name).toEqual('Tax Payer'); }); it('returns notfounderror when section not found', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', - }); applicationContext .getPersistenceGateway() .getUsersInSection.mockReturnValue(MOCK_SECTION); let result = 'error'; try { const sectionToGet = { section: 'unknown' }; - await getUsersInSectionInteractor(applicationContext, sectionToGet); + await getUsersInSectionInteractor( + applicationContext, + sectionToGet, + mockPetitionsClerkUser, + ); } catch (e) { if (e instanceof NotFoundError) { result = 'error'; @@ -79,10 +74,6 @@ describe('Get users in section', () => { }); it('returns unauthorizederror when user not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', - }); applicationContext .getPersistenceGateway() .getUsersInSection.mockReturnValue(MOCK_SECTION); @@ -90,7 +81,11 @@ describe('Get users in section', () => { let result = 'error'; try { const sectionToGet = { section: 'unknown' }; - await getUsersInSectionInteractor(applicationContext, sectionToGet); + await getUsersInSectionInteractor( + applicationContext, + sectionToGet, + mockPetitionerUser, + ); } catch (e) { if (e instanceof UnauthorizedError) { result = 'error'; @@ -100,10 +95,6 @@ describe('Get users in section', () => { }); it('retrieves the users in the judge section when the current user has the appropriate permissions', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', - }); applicationContext .getPersistenceGateway() .getUsersInSection.mockReturnValue(MOCK_JUDGE_SECTION); @@ -111,22 +102,23 @@ describe('Get users in section', () => { const section = await getUsersInSectionInteractor( applicationContext, sectionToGet, + mockDocketClerkUser, ); expect(section.length).toEqual(2); expect(section[0].name).toEqual('Test Judge 1'); }); - it('returns unauthorizederror when the desired section is judge and current user does not have appropriate permissions', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '5a797be2-a4b7-469f-9cfb-32b7f169d489', - }); + it('returns unauthorizedError when the desired section is judge and current user does not have appropriate permissions', async () => { applicationContext .getPersistenceGateway() .getUsersInSection.mockReturnValue(MOCK_JUDGE_SECTION); const sectionToGet = { section: 'judge' }; await expect( - getUsersInSectionInteractor(applicationContext, sectionToGet), + getUsersInSectionInteractor( + applicationContext, + sectionToGet, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); }); diff --git a/web-api/src/business/useCases/user/getUsersInSectionInteractor.ts b/web-api/src/business/useCases/user/getUsersInSectionInteractor.ts index 4a02f757704..dfabb24df20 100644 --- a/web-api/src/business/useCases/user/getUsersInSectionInteractor.ts +++ b/web-api/src/business/useCases/user/getUsersInSectionInteractor.ts @@ -8,12 +8,13 @@ import { } from '../../../../../shared/src/business/entities/User'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '../../../errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const getUsersInSectionInteractor = async ( applicationContext: ServerApplicationContext, { section }: { section: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); let rolePermission; if (section === 'judge') { @@ -22,7 +23,7 @@ export const getUsersInSectionInteractor = async ( rolePermission = ROLE_PERMISSIONS.GET_USERS_IN_SECTION; } - if (!isAuthorized(user, rolePermission)) { + if (!isAuthorized(authorizedUser, rolePermission)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/users/getUsersInSectionLambda.ts b/web-api/src/lambdas/users/getUsersInSectionLambda.ts index 360c79c1095..92b083e4726 100644 --- a/web-api/src/lambdas/users/getUsersInSectionLambda.ts +++ b/web-api/src/lambdas/users/getUsersInSectionLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getUsersInSectionInteractor } from '@web-api/business/useCases/user/getUsersInSectionInteractor'; /** * creates a new document and attaches it to a case. It also creates a work item on the docket section. @@ -6,13 +8,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getUsersInSectionLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const { section } = event.pathParameters || {}; +export const getUsersInSectionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const { section } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .getUsersInSectionInteractor(applicationContext, { - section, - }); - }); + return await getUsersInSectionInteractor( + applicationContext, + { + section, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From fa4ba7091b5e6251162a7440baa5f3fa35067597 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 13:00:21 -0500 Subject: [PATCH 211/523] 10417: remove getCurrentUser from caseSearchNoMatchesHelper --- .../computeds/caseSearchNoMatchesHelper.test.ts | 16 +++------------- .../computeds/caseSearchNoMatchesHelper.ts | 4 +++- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/web-client/src/presenter/computeds/caseSearchNoMatchesHelper.test.ts b/web-client/src/presenter/computeds/caseSearchNoMatchesHelper.test.ts index d1bc7e88afa..ccb0be67604 100644 --- a/web-client/src/presenter/computeds/caseSearchNoMatchesHelper.test.ts +++ b/web-client/src/presenter/computeds/caseSearchNoMatchesHelper.test.ts @@ -1,6 +1,6 @@ -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { caseSearchNoMatchesHelper as caseSearchNoMatchesHelperComputed } from './caseSearchNoMatchesHelper'; +import { irsPractitionerUser, petitionerUser } from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -11,26 +11,16 @@ const caseSearchNoMatchesHelper = withAppContextDecorator( describe('caseSearchNoMatchesHelper', () => { it('should return showSearchByNameOption true if the user role is not petitioner', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.irsPractitioner, - userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', - }); - const result = runCompute(caseSearchNoMatchesHelper, { - state: {}, + state: { user: irsPractitionerUser }, }); expect(result.showSearchByNameOption).toBe(true); }); it('should return showSearchByNameOption false if the user role is petitioner', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.petitioner, - userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', - }); - const result = runCompute(caseSearchNoMatchesHelper, { - state: {}, + state: { user: petitionerUser }, }); expect(result.showSearchByNameOption).toBe(false); diff --git a/web-client/src/presenter/computeds/caseSearchNoMatchesHelper.ts b/web-client/src/presenter/computeds/caseSearchNoMatchesHelper.ts index aecb20c6295..da356c47c20 100644 --- a/web-client/src/presenter/computeds/caseSearchNoMatchesHelper.ts +++ b/web-client/src/presenter/computeds/caseSearchNoMatchesHelper.ts @@ -1,10 +1,12 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; import { Get } from 'cerebral'; +import { state } from '@web-client/presenter/app.cerebral'; + export const caseSearchNoMatchesHelper = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); let showSearchByNameOption = true; From d6758887ea10697133c07d1702f4570e9f93b2b7 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 13:07:48 -0500 Subject: [PATCH 212/523] 10417 remove getCurrentUser from completeDocumentTypeSectionHelper --- .../completeDocumentTypeSectionHelper.test.ts | 27 ++++++------------- .../completeDocumentTypeSectionHelper.ts | 6 ++--- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.test.ts b/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.test.ts index 6a1d8573c4f..b5b11dc36d5 100644 --- a/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.test.ts +++ b/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.test.ts @@ -13,18 +13,13 @@ const completeDocumentTypeSectionHelper = withAppContextDecorator( applicationContext, ); -beforeEach(() => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(privatePractitionerUser); -}); - describe('completeDocumentTypeSectionHelper', () => { it("should return an empty object given there's no caseDetail", () => { const result = runCompute(completeDocumentTypeSectionHelper, { state: { caseDetail: {}, form: {}, + user: privatePractitionerUser, }, }); @@ -47,6 +42,7 @@ describe('completeDocumentTypeSectionHelper', () => { category, documentType, }, + user: privatePractitionerUser, }, }); @@ -74,6 +70,7 @@ describe('completeDocumentTypeSectionHelper', () => { documentType: 'Motion for Leave to File', }, }, + user: privatePractitionerUser, }, }); @@ -98,6 +95,7 @@ describe('completeDocumentTypeSectionHelper', () => { form: { category, }, + user: privatePractitionerUser, }, }); @@ -123,9 +121,6 @@ describe('completeDocumentTypeSectionHelper', () => { }); it('returns an array of documentTypes for select including Entry of Appearance for IRS Practitioners on first filing', () => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(irsPractitionerUser); applicationContext.getUtilities().isSealedCase = jest .fn() .mockReturnValue(false); @@ -136,6 +131,7 @@ describe('completeDocumentTypeSectionHelper', () => { docketNumber: '101-20', }, form: {}, + user: irsPractitionerUser, }, }); @@ -153,9 +149,6 @@ describe('completeDocumentTypeSectionHelper', () => { }); it('returns an array of documentTypes for select that only contains documents with canBeFirstIrsDocument for IRS Pracitioners on filing first IRS document', () => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(irsPractitionerUser); applicationContext.getUtilities().isSealedCase = jest .fn() .mockReturnValue(false); @@ -166,6 +159,7 @@ describe('completeDocumentTypeSectionHelper', () => { docketNumber: '101-20', }, form: {}, + user: irsPractitionerUser, }, }); @@ -180,9 +174,6 @@ describe('completeDocumentTypeSectionHelper', () => { }); it('returns an array of documentTypes for select excluding Entry of Appearance for IRS Practitioners on non-first filing', () => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(irsPractitionerUser); applicationContext.getUtilities().isSealedCase = jest .fn() .mockReturnValue(false); @@ -194,6 +185,7 @@ describe('completeDocumentTypeSectionHelper', () => { irsPractitioners: [{ thing: 'thing' }], }, form: {}, + user: irsPractitionerUser, }, }); @@ -206,10 +198,6 @@ describe('completeDocumentTypeSectionHelper', () => { }); it('returns an array of documentTypes for select excluding Entry of Appearance for IRS Practitioners on sealed case', () => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(irsPractitionerUser); - const result = runCompute(completeDocumentTypeSectionHelper, { state: { caseDetail: { @@ -217,6 +205,7 @@ describe('completeDocumentTypeSectionHelper', () => { isSealed: true, }, form: {}, + user: irsPractitionerUser, }, }); diff --git a/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.ts b/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.ts index ca70a5db4c1..7d6769a8cd6 100644 --- a/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.ts +++ b/web-client/src/presenter/computeds/completeDocumentTypeSectionHelper.ts @@ -59,7 +59,7 @@ export const completeDocumentTypeSectionHelper = ( value => value.eventCode, ); - const currentUser = applicationContext.getCurrentUser(); + const currentUser = get(state.user); if (currentUser.role === USER_ROLES.irsPractitioner) { if ( Case.isFirstIrsFiling(caseDetail) && @@ -85,8 +85,8 @@ export const completeDocumentTypeSectionHelper = ( return { ...documentType, documentTitle: - applicationContext.getCurrentUser().role === - USER_ROLES.irsPractitioner && documentType.eventCode === 'EA' + get(state.user).role === USER_ROLES.irsPractitioner && + documentType.eventCode === 'EA' ? `${documentType.documentTitle} for Respondent` : documentType.documentTitle, }; From 8913f7a78a5e002306de0894978334abd4f8403d Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 13:11:36 -0500 Subject: [PATCH 213/523] 10417: remove getCurrentUser from contactsHelper --- .../computeds/contactsHelper.test.ts | 19 ++++++++++++------- .../src/presenter/computeds/contactsHelper.ts | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/web-client/src/presenter/computeds/contactsHelper.test.ts b/web-client/src/presenter/computeds/contactsHelper.test.ts index 3746057b680..186b179fdf8 100644 --- a/web-client/src/presenter/computeds/contactsHelper.test.ts +++ b/web-client/src/presenter/computeds/contactsHelper.test.ts @@ -1,7 +1,10 @@ import { PARTY_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { contactsHelper as contactsHelperComputed } from './contactsHelper'; -import { privatePractitionerUser } from '../../../../shared/src/test/mockUsers'; +import { + petitionerUser, + privatePractitionerUser, +} from '../../../../shared/src/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -16,6 +19,7 @@ describe('contactsHelper', () => { const result = runCompute(contactsHelper, { state: { form: { partyType: PARTY_TYPES.conservator }, + user: petitionerUser, }, }); @@ -33,6 +37,7 @@ describe('contactsHelper', () => { form: { partyType: undefined, }, + user: petitionerUser, }, }); @@ -45,6 +50,7 @@ describe('contactsHelper', () => { form: { partyType: PARTY_TYPES.petitioner, }, + user: petitionerUser, }, }); @@ -60,6 +66,7 @@ describe('contactsHelper', () => { form: { partyType: PARTY_TYPES.petitionerSpouse, }, + user: petitionerUser, }, }); @@ -79,18 +86,13 @@ describe('contactsHelper', () => { }); describe('user role private practitioner', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue( - privatePractitionerUser, - ); - }); - it('should validate form view information for party type Partnership (as the Tax Matters Partner)', () => { const result = runCompute(contactsHelper, { state: { form: { partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, + user: privatePractitionerUser, }, }); @@ -108,6 +110,7 @@ describe('contactsHelper', () => { form: { partyType: PARTY_TYPES.petitioner, }, + user: privatePractitionerUser, }, }); @@ -123,6 +126,7 @@ describe('contactsHelper', () => { form: { partyType: PARTY_TYPES.petitionerSpouse, }, + user: privatePractitionerUser, }, }); @@ -146,6 +150,7 @@ describe('contactsHelper', () => { form: { partyType: undefined, }, + user: privatePractitionerUser, }, }); diff --git a/web-client/src/presenter/computeds/contactsHelper.ts b/web-client/src/presenter/computeds/contactsHelper.ts index fbdbdfdf5bf..7db9cdc91d7 100644 --- a/web-client/src/presenter/computeds/contactsHelper.ts +++ b/web-client/src/presenter/computeds/contactsHelper.ts @@ -17,7 +17,7 @@ export const contactsHelper = ( applicationContext: ClientApplicationContext, ): any => { const form = get(state.form); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { PARTY_TYPES, USER_ROLES } = applicationContext.getConstants(); let contactPrimary, contactSecondary; From a974f3565b1d90e41dc9e4d9080a3532b42e69ae Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 12 Jul 2024 13:17:13 -0500 Subject: [PATCH 214/523] 10417 remove getCurrentUser from dashboardExternalHelper --- .../computeds/dashboardExternalHelper.test.ts | 52 +++++++------------ .../computeds/dashboardExternalHelper.ts | 2 +- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/web-client/src/presenter/computeds/dashboardExternalHelper.test.ts b/web-client/src/presenter/computeds/dashboardExternalHelper.test.ts index 1ca67b9a5be..f4f55fe219f 100644 --- a/web-client/src/presenter/computeds/dashboardExternalHelper.test.ts +++ b/web-client/src/presenter/computeds/dashboardExternalHelper.test.ts @@ -1,7 +1,11 @@ -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { dashboardExternalHelper as dashboardExternalHelperComputed } from './dashboardExternalHelper'; -import { docketClerk1User } from '@shared/test/mockUsers'; +import { + docketClerk1User, + irsPractitionerUser, + petitionerUser, + privatePractitionerUser, +} from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -12,40 +16,33 @@ describe('dashboardExternalHelper', () => { ); it('should show "what to expect" but not case list when there are no open or closed cases', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.petitioner, - }); const result = runCompute(dashboardExternalHelper, { state: { closedCases: [], openCases: [], + user: petitionerUser, }, }); expect(result.showWhatToExpect).toEqual(true); }); it('should show case list but not "what to expect" when there is an open or closed case case', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.petitioner, - }); const result = runCompute(dashboardExternalHelper, { state: { closedCases: [{ something: true }], openCases: [{ something: true }], + user: petitionerUser, }, }); expect(result.showWhatToExpect).toEqual(false); }); it('should keep the showFileACase flag as false when the user role is petitioner', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.petitioner, - }); - const result = runCompute(dashboardExternalHelper, { state: { closedCases: [{ something: true }], openCases: [{ something: true }], + user: petitionerUser, }, }); @@ -53,14 +50,11 @@ describe('dashboardExternalHelper', () => { }); it('should set the showFileACase flag as true when the user role is a private practitioner', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.privatePractitioner, - }); - const result = runCompute(dashboardExternalHelper, { state: { closedCases: [{ something: true }], openCases: [{ something: true }], + user: privatePractitionerUser, }, }); @@ -68,14 +62,11 @@ describe('dashboardExternalHelper', () => { }); it('should keep the showStartButton flag as false when the user role is irs practitioner', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.irsPractitioner, - }); - const result = runCompute(dashboardExternalHelper, { state: { closedCases: [{ something: true }], openCases: [{ something: true }], + user: irsPractitionerUser, }, }); @@ -83,17 +74,14 @@ describe('dashboardExternalHelper', () => { }); it('should set the showStartButton flag as true when the user role is a private practitioner or petitioner', () => { - const userRoles = ['petitioner', 'privatePractitioner']; - - userRoles.forEach(userRole => { - applicationContext.getCurrentUser = () => ({ - role: userRole, - }); + const userRoles = [petitionerUser, privatePractitionerUser]; + userRoles.forEach(user => { const result = runCompute(dashboardExternalHelper, { state: { closedCases: [{ something: true }], openCases: [{ something: true }], + user, }, }); @@ -102,17 +90,14 @@ describe('dashboardExternalHelper', () => { }); it('should set the showFilingFee to true when the user is a private practitioner or petitioner', () => { - const userRoles = ['petitioner', 'privatePractitioner']; - - userRoles.forEach(userRole => { - applicationContext.getCurrentUser = () => ({ - role: userRole, - }); + const userRoles = [petitionerUser, privatePractitionerUser]; + userRoles.forEach(user => { const result = runCompute(dashboardExternalHelper, { state: { closedCases: [{ something: true }], openCases: [{ something: true }], + user, }, }); @@ -121,12 +106,11 @@ describe('dashboardExternalHelper', () => { }); it('should set the showFilingFee to false when the user is NOT a private practitioner or petitioner', () => { - applicationContext.getCurrentUser = () => docketClerk1User; - const result = runCompute(dashboardExternalHelper, { state: { closedCases: [{ something: true }], openCases: [{ something: true }], + user: docketClerk1User, }, }); diff --git a/web-client/src/presenter/computeds/dashboardExternalHelper.ts b/web-client/src/presenter/computeds/dashboardExternalHelper.ts index 870cc07dba4..f462a72a965 100644 --- a/web-client/src/presenter/computeds/dashboardExternalHelper.ts +++ b/web-client/src/presenter/computeds/dashboardExternalHelper.ts @@ -12,7 +12,7 @@ export const dashboardExternalHelper = ( showWhatToExpect: boolean; } => { const { USER_ROLES } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const openCases = get(state.openCases) || []; const closedCases = get(state.closedCases) || []; From 66087b04982338cf994956db2d5080629cd3c927 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Fri, 12 Jul 2024 12:44:33 -0700 Subject: [PATCH 215/523] 10417: remove appcontext.getCurrentUser from generateStampedCoversheetInteractor --- .../generateDraftStampOrderInteractor.ts | 16 +++--- ...enerateStampedCoversheetInteractor.test.ts | 50 ++++++++++++------- .../generateStampedCoversheetInteractor.ts | 15 ++---- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/shared/src/business/useCases/generateDraftStampOrderInteractor.ts b/shared/src/business/useCases/generateDraftStampOrderInteractor.ts index 7f3507b8b03..9043589a738 100644 --- a/shared/src/business/useCases/generateDraftStampOrderInteractor.ts +++ b/shared/src/business/useCases/generateDraftStampOrderInteractor.ts @@ -56,10 +56,14 @@ export const generateDraftStampOrderInteractor = async ( await applicationContext .getUseCaseHelpers() - .generateStampedCoversheetInteractor(applicationContext, { - docketEntryId: motionDocketEntryId, - docketNumber, - stampData, - stampedDocketEntryId, - }); + .generateStampedCoversheetInteractor( + applicationContext, + { + docketEntryId: motionDocketEntryId, + docketNumber, + stampData, + stampedDocketEntryId, + }, + authorizedUser, + ); }; diff --git a/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.test.ts b/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.test.ts index 8c6dcf7fed3..f69e3bc4129 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.test.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.test.ts @@ -2,7 +2,9 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOTION_DISPOSITIONS } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generateStampedCoversheetInteractor } from './generateStampedCoversheetInteractor'; +import { mockPetitionerUser } from '@shared/test/mockAuthUsers'; +// TODO 10417: these tests pass irrespective of which mock user (or even no user) describe('generateStampedCoversheetInteractor', () => { const mockDocketEntryId = MOCK_CASE.docketEntries[0].docketEntryId; @@ -35,12 +37,16 @@ describe('generateStampedCoversheetInteractor', () => { }); it('clears the servedAt property of the motion docket entry used for coversheet generation', async () => { - await generateStampedCoversheetInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - stampData: mockStampData, - stampedDocketEntryId: mockStampedDocketEntryId, - }); + await generateStampedCoversheetInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + stampData: mockStampData, + stampedDocketEntryId: mockStampedDocketEntryId, + }, + mockPetitionerUser, + ); expect( applicationContext.getDocumentGenerators().coverSheet.mock.calls[0][0] @@ -49,12 +55,16 @@ describe('generateStampedCoversheetInteractor', () => { }); it('generates a stamped coversheet pdf document with stampData', async () => { - await generateStampedCoversheetInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - stampData: mockStampData, - stampedDocketEntryId: mockStampedDocketEntryId, - }); + await generateStampedCoversheetInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + stampData: mockStampData, + stampedDocketEntryId: mockStampedDocketEntryId, + }, + mockPetitionerUser, + ); expect( applicationContext.getDocumentGenerators().coverSheet, @@ -68,12 +78,16 @@ describe('generateStampedCoversheetInteractor', () => { }); it('should save the stamped coversheet', async () => { - await generateStampedCoversheetInteractor(applicationContext, { - docketEntryId: mockDocketEntryId, - docketNumber: MOCK_CASE.docketNumber, - stampData: {}, - stampedDocketEntryId: mockStampedDocketEntryId, - }); + await generateStampedCoversheetInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: MOCK_CASE.docketNumber, + stampData: {}, + stampedDocketEntryId: mockStampedDocketEntryId, + }, + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda.mock diff --git a/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.ts b/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.ts index 50ef482ca1e..743e6495cee 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.ts @@ -1,4 +1,5 @@ import { Case } from '../../../../../shared/src/business/entities/cases/Case'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { generateCoverSheetData } from '../../useCases/generateCoverSheetData'; /** @@ -44,20 +45,10 @@ const createStampedCoversheetPdf = async ({ }; }; -/** - * generateStampedCoversheetInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.docketEntryId the docket entry id of the original motion - * @param {string} providers.docketNumber the docket number of the case - * @param {boolean} providers.stampData the stamp data from the form to be applied to the stamp order pdf - * @param {string} providers.stampedDocketEntryId the docket entry id of the new stamped order docket entry - * @returns {Promise<*>} updated docket entry entity - */ export const generateStampedCoversheetInteractor = async ( applicationContext, { docketEntryId, docketNumber, stampData, stampedDocketEntryId }, + authorizedUser: UnknownAuthUser, ) => { const caseRecord = await applicationContext .getPersistenceGateway() @@ -67,7 +58,7 @@ export const generateStampedCoversheetInteractor = async ( }); const caseEntity = new Case(caseRecord, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const motionDocketEntryEntity = caseEntity.getDocketEntryById({ From 7e05d00d68e781f05fa29a5cc85c6e655149c3c7 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Fri, 12 Jul 2024 14:04:11 -0700 Subject: [PATCH 216/523] 10417: remove appcontext.getCurrentUser from deleteCounselFromCaseInteractor --- .../deleteCounselFromCaseInteractor.test.ts | 136 +++++++++++------- .../deleteCounselFromCaseInteractor.ts | 10 +- .../cases/deleteCounselFromCaseLambda.ts | 28 ++-- 3 files changed, 114 insertions(+), 60 deletions(-) diff --git a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts index db5f5151a26..acd3ccddb2c 100644 --- a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts +++ b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts @@ -12,8 +12,10 @@ import { deleteCounselFromCaseInteractor, setupServiceIndicatorForUnrepresentedPetitioners, } from './deleteCounselFromCaseInteractor'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; -import { petitionerUser } from '@shared/test/mockUsers'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('deleteCounselFromCaseInteractor', () => { const mockPrivatePractitioners = [ @@ -75,10 +77,10 @@ describe('deleteCounselFromCaseInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'fb39f224-7985-438d-8327-2df162c20c8e', - }); + // applicationContext.getCurrentUser.mockReturnValue({ + // role: ROLES.docketClerk, + // userId: 'fb39f224-7985-438d-8327-2df162c20c8e', + // }); applicationContext .getPersistenceGateway() @@ -102,13 +104,15 @@ describe('deleteCounselFromCaseInteractor', () => { }); it('should return an unauthorized error when the user does not have permission to remove counsel from a case', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - await expect( - deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: '141d4c7c-4302-465d-89bd-3bc8ae16f07d', - }), + deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: '141d4c7c-4302-465d-89bd-3bc8ae16f07d', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -116,10 +120,14 @@ describe('deleteCounselFromCaseInteractor', () => { mockLock = MOCK_LOCK; await expect( - deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: '141d4c7c-4302-465d-89bd-3bc8ae16f07d', - }), + deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: '141d4c7c-4302-465d-89bd-3bc8ae16f07d', + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -128,10 +136,14 @@ describe('deleteCounselFromCaseInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: '141d4c7c-4302-465d-89bd-3bc8ae16f07d', - }); + await deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: '141d4c7c-4302-465d-89bd-3bc8ae16f07d', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -149,10 +161,14 @@ describe('deleteCounselFromCaseInteractor', () => { }); it('should remove the private practitioner with the given user id from the case', async () => { - await deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: '141d4c7c-4302-465d-89bd-3bc8ae16f07d', - }); + await deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: '141d4c7c-4302-465d-89bd-3bc8ae16f07d', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteUserFromCase, @@ -163,10 +179,14 @@ describe('deleteCounselFromCaseInteractor', () => { }); it('should remove the irs practitioner with the given userId from the case', async () => { - await deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: 'bfd97089-cda0-45e0-8454-dd879023d0af', - }); + await deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: 'bfd97089-cda0-45e0-8454-dd879023d0af', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteUserFromCase, @@ -178,10 +198,14 @@ describe('deleteCounselFromCaseInteractor', () => { it('should throw an error when the user is NOT a private practitioner or irs practitioner', async () => { await expect( - deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: '835f072c-5ea1-493c-acb8-d67b05c96f85', - }), + deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: '835f072c-5ea1-493c-acb8-d67b05c96f85', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('User is not a practitioner'); }); @@ -199,10 +223,14 @@ describe('deleteCounselFromCaseInteractor', () => { privatePractitioners: [mockPrivatePractitioners[0]], }); - await deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: mockPrivatePractitioners[0].userId, - }); + await deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: mockPrivatePractitioners[0].userId, + }, + mockDocketClerkUser, + ); const updatedCase = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -229,10 +257,14 @@ describe('deleteCounselFromCaseInteractor', () => { privatePractitioners: [mockPrivatePractitioners[0]], }); - await deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: mockPrivatePractitioners[0].userId, - }); + await deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: mockPrivatePractitioners[0].userId, + }, + mockDocketClerkUser, + ); const updatedCase = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -288,10 +320,14 @@ describe('deleteCounselFromCaseInteractor', () => { ({ caseToUpdate }) => caseToUpdate, ); - await deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: mockPrivatePractitioners[0].userId, - }); + await deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: mockPrivatePractitioners[0].userId, + }, + mockDocketClerkUser, + ); const updatedCase = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -344,10 +380,14 @@ describe('deleteCounselFromCaseInteractor', () => { ({ caseToUpdate }) => caseToUpdate, ); - await deleteCounselFromCaseInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - userId: mockPrivatePractitioners[0].userId, - }); + await deleteCounselFromCaseInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + userId: mockPrivatePractitioners[0].userId, + }, + mockDocketClerkUser, + ); const updatedCase = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock diff --git a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts index 1f63e2c392e..43fc3737a90 100644 --- a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts +++ b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts @@ -6,16 +6,18 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const deleteCounselFromCase = async ( applicationContext: ServerApplicationContext, { docketNumber, userId }: { docketNumber: string; userId: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) + ) { throw new UnauthorizedError('Unauthorized'); } @@ -33,7 +35,7 @@ export const deleteCounselFromCase = async ( userId, }); - let caseEntity = new Case(caseToUpdate, { authorizedUser: user }); + let caseEntity = new Case(caseToUpdate, { authorizedUser }); if (userToDelete.role === ROLES.privatePractitioner) { caseEntity.removePrivatePractitioner(userToDelete); diff --git a/web-api/src/lambdas/cases/deleteCounselFromCaseLambda.ts b/web-api/src/lambdas/cases/deleteCounselFromCaseLambda.ts index 29afcb34f19..81930b7689c 100644 --- a/web-api/src/lambdas/cases/deleteCounselFromCaseLambda.ts +++ b/web-api/src/lambdas/cases/deleteCounselFromCaseLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const deleteCounselFromCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteCounselFromCaseInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const deleteCounselFromCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .deleteCounselFromCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 8518396adfb63e2e1c238dfdf795fa7a2df056e9 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Fri, 12 Jul 2024 15:23:03 -0700 Subject: [PATCH 217/523] 10417: remove appcontext.getCurrentUser from generateStampedCoversheetInteractor --- ...rateEntryOfAppearancePdfInteractor.test.ts | 32 ++++++++++++------- .../generateEntryOfAppearancePdfInteractor.ts | 12 ++++--- .../generateEntryOfAppearancePdfLambda.ts | 30 +++++++++++------ 3 files changed, 48 insertions(+), 26 deletions(-) diff --git a/web-api/src/business/useCases/caseAssociationRequest/generateEntryOfAppearancePdfInteractor.test.ts b/web-api/src/business/useCases/caseAssociationRequest/generateEntryOfAppearancePdfInteractor.test.ts index 69a2cc642be..eae56f6b08d 100644 --- a/web-api/src/business/useCases/caseAssociationRequest/generateEntryOfAppearancePdfInteractor.test.ts +++ b/web-api/src/business/useCases/caseAssociationRequest/generateEntryOfAppearancePdfInteractor.test.ts @@ -1,12 +1,16 @@ +import { type AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { MOCK_PRACTITIONER, irsPractitionerUser, petitionerUser, - privatePractitionerUser, validUser, } from '@shared/test/mockUsers'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generateEntryOfAppearancePdfInteractor } from './generateEntryOfAppearancePdfInteractor'; +import { + mockIrsPractitionerUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('generateEntryOfAppearancePdfInteractor', () => { const mockFile = { @@ -25,7 +29,6 @@ describe('generateEntryOfAppearancePdfInteractor', () => { ]; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(privatePractitionerUser); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(MOCK_PRACTITIONER); @@ -38,19 +41,23 @@ describe('generateEntryOfAppearancePdfInteractor', () => { }); it('should throw an unauthorized error if the user has no access to associate self with case', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ + let bogusUser = { role: 'nope', userId: 'nope', - }); + } as unknown as AuthUser; await expect( - generateEntryOfAppearancePdfInteractor(applicationContext, { - caseCaptionExtension, - caseTitle, - docketNumberWithSuffix, - filers, - petitioners, - }), + generateEntryOfAppearancePdfInteractor( + applicationContext, + { + caseCaptionExtension, + caseTitle, + docketNumberWithSuffix, + filers, + petitioners, + }, + bogusUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -65,6 +72,7 @@ describe('generateEntryOfAppearancePdfInteractor', () => { filers, petitioners, }, + mockPrivatePractitionerUser, ); expect( @@ -93,7 +101,6 @@ describe('generateEntryOfAppearancePdfInteractor', () => { }); it('should use Respondent as the filer name when an IRS practitioner is filing an entry of appearance', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce(irsPractitionerUser); applicationContext .getPersistenceGateway() .getUserById.mockReturnValueOnce(irsPractitionerUser); @@ -108,6 +115,7 @@ describe('generateEntryOfAppearancePdfInteractor', () => { filers, petitioners, }, + mockIrsPractitionerUser, ); expect( diff --git a/web-api/src/business/useCases/caseAssociationRequest/generateEntryOfAppearancePdfInteractor.ts b/web-api/src/business/useCases/caseAssociationRequest/generateEntryOfAppearancePdfInteractor.ts index b9eec024c21..6cfb3955b5a 100644 --- a/web-api/src/business/useCases/caseAssociationRequest/generateEntryOfAppearancePdfInteractor.ts +++ b/web-api/src/business/useCases/caseAssociationRequest/generateEntryOfAppearancePdfInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export type EntryOfAppearanceProps = { caseCaptionExtension: string; @@ -26,10 +27,11 @@ export const generateEntryOfAppearancePdfInteractor = async ( filers, petitioners, }: EntryOfAppearanceProps, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.ASSOCIATE_SELF_WITH_CASE)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSOCIATE_SELF_WITH_CASE) + ) { throw new UnauthorizedError('Unauthorized'); } @@ -37,11 +39,11 @@ export const generateEntryOfAppearancePdfInteractor = async ( .getPersistenceGateway() .getUserById({ applicationContext, - userId: user.userId, + userId: authorizedUser.userId, }); const filerNames: string[] = - user.role === ROLES.irsPractitioner + authorizedUser.role === ROLES.irsPractitioner ? ['Respondent'] : (filers .map(filerId => { diff --git a/web-api/src/lambdas/caseAssociations/generateEntryOfAppearancePdfLambda.ts b/web-api/src/lambdas/caseAssociations/generateEntryOfAppearancePdfLambda.ts index cbf926e3c02..c562395920f 100644 --- a/web-api/src/lambdas/caseAssociations/generateEntryOfAppearancePdfLambda.ts +++ b/web-api/src/lambdas/caseAssociations/generateEntryOfAppearancePdfLambda.ts @@ -1,11 +1,23 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -export const generateEntryOfAppearancePdfLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .generateEntryOfAppearancePdfInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const generateEntryOfAppearancePdfLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .generateEntryOfAppearancePdfInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 502b1602901c9965fdcb3ba4965e854c7bd72621 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 15 Jul 2024 09:58:36 -0700 Subject: [PATCH 218/523] 10417: remove appcontext.getCurrentUser from submitPendingCaseAssociationRequestInteractor --- .../deleteCounselFromCaseInteractor.test.ts | 5 -- ...ngCaseAssociationRequestInteractor.test.ts | 64 ++++++++++--------- ...PendingCaseAssociationRequestInteractor.ts | 4 +- ...ractitionerPendingCaseAssociationLambda.ts | 28 +++++--- 4 files changed, 57 insertions(+), 44 deletions(-) diff --git a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts index acd3ccddb2c..7cfc848524b 100644 --- a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts +++ b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.test.ts @@ -77,11 +77,6 @@ describe('deleteCounselFromCaseInteractor', () => { beforeEach(() => { mockLock = undefined; - // applicationContext.getCurrentUser.mockReturnValue({ - // role: ROLES.docketClerk, - // userId: 'fb39f224-7985-438d-8327-2df162c20c8e', - // }); - applicationContext .getPersistenceGateway() .getUserById.mockImplementation(({ userId }) => { diff --git a/web-api/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.test.ts b/web-api/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.test.ts index 60234aaa8b8..09d144ef9c2 100644 --- a/web-api/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.test.ts +++ b/web-api/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.test.ts @@ -1,5 +1,8 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockAdcUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { submitPendingCaseAssociationRequestInteractor } from './submitPendingCaseAssociationRequestInteractor'; describe('submitPendingCaseAssociationRequest', () => { @@ -8,37 +11,32 @@ describe('submitPendingCaseAssociationRequest', () => { }; it('should throw an error when not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.adc, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - await expect( - submitPendingCaseAssociationRequestInteractor(applicationContext, { - docketNumber: caseRecord.docketNumber, - }), + submitPendingCaseAssociationRequestInteractor( + applicationContext, + { + docketNumber: caseRecord.docketNumber, + }, + mockAdcUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should not add mapping if already associated', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.privatePractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.privatePractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + applicationContext + .getPersistenceGateway() + .getUserById.mockReturnValue(mockPrivatePractitionerUser); applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(true); - await submitPendingCaseAssociationRequestInteractor(applicationContext, { - docketNumber: caseRecord.docketNumber, - }); + await submitPendingCaseAssociationRequestInteractor( + applicationContext, + { + docketNumber: caseRecord.docketNumber, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getPersistenceGateway().associateUserWithCasePending, @@ -46,9 +44,13 @@ describe('submitPendingCaseAssociationRequest', () => { }); it('should not add mapping if these is already a pending association', async () => { - await submitPendingCaseAssociationRequestInteractor(applicationContext, { - docketNumber: caseRecord.docketNumber, - }); + await submitPendingCaseAssociationRequestInteractor( + applicationContext, + { + docketNumber: caseRecord.docketNumber, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getPersistenceGateway().associateUserWithCasePending, @@ -63,9 +65,13 @@ describe('submitPendingCaseAssociationRequest', () => { .getPersistenceGateway() .verifyPendingCaseForUser.mockReturnValue(false); - await submitPendingCaseAssociationRequestInteractor(applicationContext, { - docketNumber: caseRecord.docketNumber, - }); + await submitPendingCaseAssociationRequestInteractor( + applicationContext, + { + docketNumber: caseRecord.docketNumber, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getPersistenceGateway().associateUserWithCasePending, diff --git a/web-api/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.ts b/web-api/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.ts index b47ebb934b3..377ed4dbd74 100644 --- a/web-api/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.ts +++ b/web-api/src/business/useCases/caseAssociationRequest/submitPendingCaseAssociationRequestInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * submitPendingCaseAssociationRequestInteractor @@ -16,9 +17,8 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const submitPendingCaseAssociationRequestInteractor = async ( applicationContext: ServerApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if ( !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSOCIATE_SELF_WITH_CASE) ) { diff --git a/web-api/src/lambdas/cases/privatePractitionerPendingCaseAssociationLambda.ts b/web-api/src/lambdas/cases/privatePractitionerPendingCaseAssociationLambda.ts index 3405d9f8d53..59ba9a11b17 100644 --- a/web-api/src/lambdas/cases/privatePractitionerPendingCaseAssociationLambda.ts +++ b/web-api/src/lambdas/cases/privatePractitionerPendingCaseAssociationLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const privatePractitionerPendingCaseAssociationLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .submitPendingCaseAssociationRequestInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const privatePractitionerPendingCaseAssociationLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .submitPendingCaseAssociationRequestInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 4a1ffc571bec844104bb1be2132659ea910abb59 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 15 Jul 2024 10:48:50 -0700 Subject: [PATCH 219/523] 10417: remove appcontext.getCurrentUser from removeConsolidatedCasesInteractor --- .../removeConsolidatedCasesInteractor.test.ts | 156 +++++++++++------- .../removeConsolidatedCasesInteractor.ts | 14 +- .../cases/removeConsolidatedCasesLambda.ts | 36 ++-- 3 files changed, 131 insertions(+), 75 deletions(-) diff --git a/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.test.ts b/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.test.ts index 1d862394c2f..b7e200db419 100644 --- a/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.test.ts +++ b/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.test.ts @@ -1,8 +1,11 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { removeConsolidatedCasesInteractor } from './removeConsolidatedCasesInteractor'; let mockCases; @@ -51,9 +54,6 @@ describe('removeConsolidatedCasesInteractor', () => { }, }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockImplementation(({ docketNumber }) => { @@ -72,23 +72,27 @@ describe('removeConsolidatedCasesInteractor', () => { }); it('Should return an Unauthorized error if the user does not have the CONSOLIDATE_CASES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - }); - await expect( - removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '102-19', - docketNumbersToRemove: ['101-19'], - }), + removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '102-19', + docketNumbersToRemove: ['101-19'], + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for case consolidation'); }); it('Should try to get the case by its docketNumber', async () => { - await removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '102-19', - docketNumbersToRemove: ['101-19'], - }); + await removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '102-19', + docketNumbersToRemove: ['101-19'], + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -97,27 +101,39 @@ describe('removeConsolidatedCasesInteractor', () => { it('Should return a Not Found error if the case to update can not be found', async () => { await expect( - removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '111-11', - docketNumbersToRemove: ['101-19'], - }), + removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '111-11', + docketNumbersToRemove: ['101-19'], + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Case 111-11 was not found.'); }); it('Should return a Not Found error if the case to remove cannot be found', async () => { await expect( - removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '102-19', - docketNumbersToRemove: ['111-11'], - }), + removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '102-19', + docketNumbersToRemove: ['111-11'], + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Case to consolidate with (111-11) was not found.'); }); it('Should only update the removed case if the case to remove is not the lead case', async () => { - await removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '101-19', - docketNumbersToRemove: ['102-19'], - }); + await removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '101-19', + docketNumbersToRemove: ['102-19'], + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls.length, @@ -132,10 +148,14 @@ describe('removeConsolidatedCasesInteractor', () => { }); it('Should update the removed case and all other currently consolidated cases if the case to remove is the lead case', async () => { - await removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '102-19', - docketNumbersToRemove: ['101-19'], - }); + await removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '102-19', + docketNumbersToRemove: ['101-19'], + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls.length, @@ -167,10 +187,14 @@ describe('removeConsolidatedCasesInteractor', () => { it('Should update all cases to remove consolidation if new consolidated cases length is 0', async () => { const docketNumbersToRemove = allDocketNumbers; - await removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '101-19', - docketNumbersToRemove, - }); + await removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '101-19', + docketNumbersToRemove, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations, ).toHaveBeenCalledTimes(docketNumbersToRemove.length); @@ -184,10 +208,14 @@ describe('removeConsolidatedCasesInteractor', () => { '104-19', '105-19', ]; - await removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '101-19', - docketNumbersToRemove, - }); + await removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '101-19', + docketNumbersToRemove, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations, @@ -202,10 +230,14 @@ describe('removeConsolidatedCasesInteractor', () => { }); it('Should update the removed case and remove consolidation from the original lead case if there is only one case remaining after removal', async () => { - await removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '104-19', - docketNumbersToRemove: ['105-19'], - }); + await removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '104-19', + docketNumbersToRemove: ['105-19'], + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls.length, @@ -229,10 +261,14 @@ describe('removeConsolidatedCasesInteractor', () => { }); it('Should update the removed case and remove consolidation from the original non-lead case if there is only one case remaining after removal', async () => { - await removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '105-19', - docketNumbersToRemove: ['104-19'], - }); + await removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '105-19', + docketNumbersToRemove: ['104-19'], + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls.length, @@ -259,10 +295,14 @@ describe('removeConsolidatedCasesInteractor', () => { mockLock = MOCK_LOCK; await expect( - removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '105-19', - docketNumbersToRemove: ['104-19'], - }), + removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '105-19', + docketNumbersToRemove: ['104-19'], + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -271,10 +311,14 @@ describe('removeConsolidatedCasesInteractor', () => { }); it('should acquire and remove the lock on the cases', async () => { - await removeConsolidatedCasesInteractor(applicationContext, { - docketNumber: '105-19', - docketNumbersToRemove: ['104-19'], - }); + await removeConsolidatedCasesInteractor( + applicationContext, + { + docketNumber: '105-19', + docketNumbersToRemove: ['104-19'], + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts b/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts index ae65c392523..7560be91030 100644 --- a/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts +++ b/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts @@ -5,6 +5,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -22,10 +23,9 @@ export const removeConsolidatedCases = async ( docketNumber, docketNumbersToRemove, }: { docketNumber: string; docketNumbersToRemove: string[] }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CONSOLIDATE_CASES)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CONSOLIDATE_CASES)) { throw new UnauthorizedError('Unauthorized for case consolidation'); } @@ -33,7 +33,7 @@ export const removeConsolidatedCases = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - if (!caseToUpdate) { + if (!caseToUpdate || !caseToUpdate?.leadDocketNumber) { throw new NotFoundError(`Case ${docketNumber} was not found.`); } @@ -61,7 +61,7 @@ export const removeConsolidatedCases = async ( for (let newConsolidatedCaseToUpdate of newConsolidatedCases) { const caseEntity = new Case(newConsolidatedCaseToUpdate, { - authorizedUser: user, + authorizedUser, }); caseEntity.setLeadCase(newLeadCase.docketNumber); @@ -75,7 +75,7 @@ export const removeConsolidatedCases = async ( } else if (newConsolidatedCases.length == 1) { // a case cannot be consolidated with itself const caseEntity = new Case(newConsolidatedCases[0], { - authorizedUser: user, + authorizedUser, }); caseEntity.removeConsolidation(); @@ -101,7 +101,7 @@ export const removeConsolidatedCases = async ( ); } - const caseEntity = new Case(caseToRemove, { authorizedUser: user }); + const caseEntity = new Case(caseToRemove, { authorizedUser }); caseEntity.removeConsolidation(); updateCasePromises.push( diff --git a/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts b/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts index 119ddf18757..ea6ace08a0a 100644 --- a/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts +++ b/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,16 +7,27 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const removeConsolidatedCasesLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const docketNumbersToRemove = ( - event.queryStringParameters.docketNumbersToRemove || '' - ).split(','); +export const removeConsolidatedCasesLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const docketNumbersToRemove = ( + event.queryStringParameters.docketNumbersToRemove || '' + ).split(','); - return await applicationContext - .getUseCases() - .removeConsolidatedCasesInteractor(applicationContext, { - ...event.pathParameters, - docketNumbersToRemove, - }); - }); + return await applicationContext + .getUseCases() + .removeConsolidatedCasesInteractor( + applicationContext, + { + ...event.pathParameters, + docketNumbersToRemove, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From cd1e81625dc2f5d726f9954978450867996b282d Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 15 Jul 2024 11:20:52 -0700 Subject: [PATCH 220/523] 10417: remove appcontext.getCurrentUser from createCaseDeadlineInteractor --- .../createCaseDeadlineInteractor.test.ts | 45 ++++++++++--------- .../createCaseDeadlineInteractor.ts | 8 ++-- .../caseDeadline/createCaseDeadlineLambda.ts | 28 ++++++++---- 3 files changed, 49 insertions(+), 32 deletions(-) diff --git a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.ts b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.ts index cd8356f69e5..b42c8de7bb1 100644 --- a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.ts +++ b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.ts @@ -1,7 +1,6 @@ import { AUTOMATIC_BLOCKED_REASONS, CHIEF_JUDGE, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE, @@ -12,9 +11,9 @@ import { ServiceUnavailableError, UnauthorizedError, } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createCaseDeadlineInteractor } from './createCaseDeadlineInteractor'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; describe('createCaseDeadlineInteractor', () => { const mockCaseDeadline = { @@ -22,7 +21,6 @@ describe('createCaseDeadlineInteractor', () => { description: 'hello world', docketNumber: MOCK_CASE.docketNumber, }; - let user; let mockCase; let mockLock; beforeAll(() => { @@ -34,14 +32,7 @@ describe('createCaseDeadlineInteractor', () => { beforeEach(() => { mockLock = undefined; - user = new User({ - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext .getPersistenceGateway() @@ -56,12 +47,16 @@ describe('createCaseDeadlineInteractor', () => { ]); }); + // TODO 10417: this test fails, and was failing prior to refactor it('throws an error if the user is not valid or authorized', async () => { - user = {}; await expect( - createCaseDeadlineInteractor(applicationContext, { - caseDeadline: mockCaseDeadline as any, - }), + createCaseDeadlineInteractor( + applicationContext, + { + caseDeadline: mockCaseDeadline as any, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -71,6 +66,7 @@ describe('createCaseDeadlineInteractor', () => { const caseDeadline = await createCaseDeadlineInteractor( applicationContext, { caseDeadline: mockCaseDeadline as any }, + mockPetitionsClerkUser, ); expect(caseDeadline).toBeDefined(); @@ -101,6 +97,7 @@ describe('createCaseDeadlineInteractor', () => { const caseDeadline = await createCaseDeadlineInteractor( applicationContext, { caseDeadline: mockCaseDeadline as any }, + mockPetitionsClerkUser, ); expect(caseDeadline).toBeDefined(); @@ -133,9 +130,13 @@ describe('createCaseDeadlineInteractor', () => { mockLock = MOCK_LOCK; await expect( - createCaseDeadlineInteractor(applicationContext, { - caseDeadline: mockCaseDeadline as any, - }), + createCaseDeadlineInteractor( + applicationContext, + { + caseDeadline: mockCaseDeadline as any, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -147,9 +148,13 @@ describe('createCaseDeadlineInteractor', () => { mockCase = MOCK_CASE; mockCase.associatedJudge = 'Judge Buch'; mockCase.associatedJudgeId = 'dabbad02-18d0-43ec-bafb-654e83405416'; - await createCaseDeadlineInteractor(applicationContext, { - caseDeadline: mockCaseDeadline as any, - }); + await createCaseDeadlineInteractor( + applicationContext, + { + caseDeadline: mockCaseDeadline as any, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts index b2dac81a89e..3eca2953451 100644 --- a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts +++ b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts @@ -6,15 +6,15 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const createCaseDeadline = async ( applicationContext: ServerApplicationContext, { caseDeadline }: { caseDeadline: CaseDeadline }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_DEADLINE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_DEADLINE)) { throw new UnauthorizedError('Unauthorized for create case deadline'); } @@ -24,7 +24,7 @@ export const createCaseDeadline = async ( applicationContext, docketNumber: caseDeadline.docketNumber, }); - let caseEntity = new Case(caseDetail, { authorizedUser: user }); + let caseEntity = new Case(caseDetail, { authorizedUser }); const newCaseDeadline = new CaseDeadline( { diff --git a/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts b/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts index 0598fb633ea..3255bf6929e 100644 --- a/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts +++ b/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const createCaseDeadlineLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createCaseDeadlineInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const createCaseDeadlineLambda = ( + event, + authorizedUser: UnknownAuthUser, +): Promise => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .createCaseDeadlineInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From f44e3ebd33634ba25e0afe789473b7db0c6f3928 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 15 Jul 2024 14:29:20 -0700 Subject: [PATCH 221/523] 10417: remove appcontext.getCurrentUser from deleteCaseDeadlineInteractor --- .../deleteCaseDeadlineInteractor.test.ts | 73 +++++++++++-------- .../deleteCaseDeadlineInteractor.ts | 19 ++--- .../caseDeadline/deleteCaseDeadlineLambda.ts | 28 +++++-- 3 files changed, 67 insertions(+), 53 deletions(-) diff --git a/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.test.ts b/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.test.ts index 36fcea717f8..526fe875438 100644 --- a/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.test.ts +++ b/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.test.ts @@ -1,16 +1,13 @@ -import { - AUTOMATIC_BLOCKED_REASONS, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { AUTOMATIC_BLOCKED_REASONS } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE_WITHOUT_PENDING } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { ServiceUnavailableError, UnauthorizedError, } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { deleteCaseDeadlineInteractor } from './deleteCaseDeadlineInteractor'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; describe('deleteCaseDeadlineInteractor', () => { let user; @@ -34,23 +31,21 @@ describe('deleteCaseDeadlineInteractor', () => { }); beforeEach(() => { - user = new User({ - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); mockLock = undefined; - applicationContext.getCurrentUser.mockImplementation(() => user); }); it('should throw a ServiceUnavailableError if the Case is currently locked', async () => { mockLock = MOCK_LOCK; await expect( - deleteCaseDeadlineInteractor(applicationContext, { - caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: MOCK_CASE_WITHOUT_PENDING.docketNumber, - }), + deleteCaseDeadlineInteractor( + applicationContext, + { + caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: MOCK_CASE_WITHOUT_PENDING.docketNumber, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -59,10 +54,14 @@ describe('deleteCaseDeadlineInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await deleteCaseDeadlineInteractor(applicationContext, { - caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: MOCK_CASE_WITHOUT_PENDING.docketNumber, - }); + await deleteCaseDeadlineInteractor( + applicationContext, + { + caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: MOCK_CASE_WITHOUT_PENDING.docketNumber, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -83,20 +82,28 @@ describe('deleteCaseDeadlineInteractor', () => { it('throws an error if the user is not valid or authorized', async () => { user = {}; await expect( - deleteCaseDeadlineInteractor(applicationContext, { - caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: '123-20', - }), + deleteCaseDeadlineInteractor( + applicationContext, + { + caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: '123-20', + }, + user, + ), ).rejects.toThrow(UnauthorizedError); }); it('calls persistence to delete a case deadline and sets the case as no longer automatically blocked if there are no more deadlines', async () => { mockDeadlines = []; - await deleteCaseDeadlineInteractor(applicationContext, { - caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: '123-20', - }); + await deleteCaseDeadlineInteractor( + applicationContext, + { + caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: '123-20', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteCaseDeadline.mock @@ -122,10 +129,14 @@ describe('deleteCaseDeadlineInteractor', () => { it('calls persistence to delete a case deadline and leaves the case automatically blocked if there are more deadlines', async () => { mockDeadlines = [{ deadline: 'something' }]; - await deleteCaseDeadlineInteractor(applicationContext, { - caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', - docketNumber: '123-20', - }); + await deleteCaseDeadlineInteractor( + applicationContext, + { + caseDeadlineId: '6805d1ab-18d0-43ec-bafb-654e83405416', + docketNumber: '123-20', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteCaseDeadline.mock diff --git a/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts b/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts index 06c6cb0408b..bd48f8b3f52 100644 --- a/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts +++ b/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts @@ -5,27 +5,18 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -/** - * deleteCaseDeadline - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.caseDeadlineId the id of the case deadline to delete - * @param {string} providers.docketNumber the docket number of the case the case deadline is attached to - * @returns {Promise} the promise of the delete call - */ export const deleteCaseDeadline = async ( applicationContext: ServerApplicationContext, { caseDeadlineId, docketNumber, }: { caseDeadlineId: string; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_DEADLINE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_DEADLINE)) { throw new UnauthorizedError('Unauthorized for deleting case deadline'); } @@ -33,7 +24,7 @@ export const deleteCaseDeadline = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - let updatedCase = new Case(caseToUpdate, { authorizedUser: user }); + let updatedCase = new Case(caseToUpdate, { authorizedUser }); await applicationContext.getPersistenceGateway().deleteCaseDeadline({ applicationContext, @@ -54,7 +45,7 @@ export const deleteCaseDeadline = async ( applicationContext, caseToUpdate: updatedCase, }); - return new Case(result, { applicationContext }).validate().toRawObject(); + return new Case(result, { authorizedUser }).validate().toRawObject(); }; export const deleteCaseDeadlineInteractor = withLocking( diff --git a/web-api/src/lambdas/caseDeadline/deleteCaseDeadlineLambda.ts b/web-api/src/lambdas/caseDeadline/deleteCaseDeadlineLambda.ts index ae0556e68b9..cd68e6d2388 100644 --- a/web-api/src/lambdas/caseDeadline/deleteCaseDeadlineLambda.ts +++ b/web-api/src/lambdas/caseDeadline/deleteCaseDeadlineLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const deleteCaseDeadlineLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteCaseDeadlineInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const deleteCaseDeadlineLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .deleteCaseDeadlineInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From c35a49217c2e930a420bc340adbfd5961f10b668 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 15 Jul 2024 14:39:11 -0700 Subject: [PATCH 222/523] 10417: fixed createCaseDeadlineInteractor.test.ts --- .../caseDeadline/createCaseDeadlineInteractor.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.ts b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.ts index b42c8de7bb1..5d33e245a78 100644 --- a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.ts +++ b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.test.ts @@ -11,6 +11,7 @@ import { ServiceUnavailableError, UnauthorizedError, } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createCaseDeadlineInteractor } from './createCaseDeadlineInteractor'; import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; @@ -47,15 +48,15 @@ describe('createCaseDeadlineInteractor', () => { ]); }); - // TODO 10417: this test fails, and was failing prior to refactor it('throws an error if the user is not valid or authorized', async () => { + let user = {} as UnknownAuthUser; await expect( createCaseDeadlineInteractor( applicationContext, { caseDeadline: mockCaseDeadline as any, }, - mockPetitionsClerkUser, + user, ), ).rejects.toThrow(UnauthorizedError); }); From 4be6fe0c3160de54da32b15194705cea1c33d0b4 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 15 Jul 2024 14:49:05 -0700 Subject: [PATCH 223/523] 10417: remove appcontext.getCurrentUser from updateCaseDeadlineInteractor --- .../updateCaseDeadlineInteractor.test.ts | 23 +++++++-------- .../updateCaseDeadlineInteractor.ts | 14 ++-------- .../caseDeadline/updateCaseDeadlineLambda.ts | 28 +++++++++++++------ 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/web-api/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.test.ts b/web-api/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.test.ts index 9d0e2c225f4..1a588295df6 100644 --- a/web-api/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.test.ts +++ b/web-api/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.test.ts @@ -1,6 +1,6 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; import { updateCaseDeadlineInteractor } from './updateCaseDeadlineInteractor'; describe('updateCaseDeadlineInteractor', () => { @@ -16,29 +16,26 @@ describe('updateCaseDeadlineInteractor', () => { } as any; it('throws an error if the user is not valid or authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - updateCaseDeadlineInteractor(applicationContext, { - caseDeadline: mockCaseDeadline, - }), + updateCaseDeadlineInteractor( + applicationContext, + { + caseDeadline: mockCaseDeadline, + }, + {} as UnknownAuthUser, + ), ).rejects.toThrow('Unauthorized'); }); it('updates a case deadline', async () => { - const mockPetitionsClerk = new User({ - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '65370e00-f608-4118-980c-56b6c0fe8df5', - }); applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockReturnValue(mockPetitionsClerk); const caseDeadline = await updateCaseDeadlineInteractor( applicationContext, { caseDeadline: mockCaseDeadline, }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.ts b/web-api/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.ts index 8ea56e04307..ffc19a64f35 100644 --- a/web-api/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.ts +++ b/web-api/src/business/useCases/caseDeadline/updateCaseDeadlineInteractor.ts @@ -5,22 +5,14 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * updateCaseDeadlineInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.caseDeadline the case deadline data - * @returns {object} the updated case deadline - */ export const updateCaseDeadlineInteractor = async ( applicationContext: ServerApplicationContext, { caseDeadline }: { caseDeadline: CaseDeadline }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_DEADLINE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_DEADLINE)) { throw new UnauthorizedError('Unauthorized for updating case deadline'); } diff --git a/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts b/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts index 0704e546cc1..a924eee9890 100644 --- a/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts +++ b/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateCaseDeadlineLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCaseDeadlineInteractor(applicationContext, { - ...JSON.parse(event.body), - }); - }); +export const updateCaseDeadlineLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .updateCaseDeadlineInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 0c01d45b34a65808dcd01f381179bff0ac8544de Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Tue, 16 Jul 2024 07:40:11 -0700 Subject: [PATCH 224/523] 10417: remove appcontext.getCurrentUser from getCaseInventoryReportInteractor --- .../getCaseInventoryReportInteractor.test.ts | 51 ++++++++++--------- .../getCaseInventoryReportInteractor.ts | 4 +- .../reports/getCaseInventoryReportLambda.ts | 28 +++++++--- 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/web-api/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.test.ts b/web-api/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.test.ts index 8229b3adc4c..82ffc7b1a1c 100644 --- a/web-api/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.test.ts +++ b/web-api/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.test.ts @@ -2,35 +2,34 @@ import { CASE_STATUS_TYPES, CHIEF_JUDGE, DOCKET_NUMBER_SUFFIXES, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getCaseInventoryReportInteractor } from './getCaseInventoryReportInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getCaseInventoryReportInteractor', () => { - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: '9754a349-1013-44fa-9e61-d39aba2637e0', - }); - }); - it('throws an error if user is not authorized for case inventory report', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, //petitioner does not have CASE_INVENTORY_REPORT permission - userId: '8e20dd1b-d142-40f4-8362-6297f1be68bf', - }); - await expect( - getCaseInventoryReportInteractor(applicationContext, { - associatedJudge: CHIEF_JUDGE, - }), + getCaseInventoryReportInteractor( + applicationContext, + { + associatedJudge: CHIEF_JUDGE, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for case inventory report'); }); it('throws an error if associatedJudge and status are not passed in', async () => { await expect( - getCaseInventoryReportInteractor(applicationContext, {}), + getCaseInventoryReportInteractor( + applicationContext, + {}, + mockDocketClerkUser, + ), ).rejects.toThrow('Either judge or status must be provided'); }); @@ -43,21 +42,25 @@ describe('getCaseInventoryReportInteractor', () => { caseCaption: 'A Test Caption', docketNumber: '123-20', docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.LIEN_LEVY, - status: CASE_STATUS_TYPES.NEW, + status: CASE_STATUS_TYPES.new, }, ]); - const result = await getCaseInventoryReportInteractor(applicationContext, { - associatedJudge: CHIEF_JUDGE, - status: CASE_STATUS_TYPES.NEW, - }); + const result = await getCaseInventoryReportInteractor( + applicationContext, + { + associatedJudge: CHIEF_JUDGE, + status: CASE_STATUS_TYPES.new, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseInventoryReport, ).toHaveBeenCalledWith({ applicationContext: expect.anything(), associatedJudge: CHIEF_JUDGE, - status: CASE_STATUS_TYPES.NEW, + status: CASE_STATUS_TYPES.new, }); expect(result).toEqual([ { @@ -65,7 +68,7 @@ describe('getCaseInventoryReportInteractor', () => { caseCaption: 'A Test Caption', docketNumber: '123-20', docketNumberSuffix: DOCKET_NUMBER_SUFFIXES.LIEN_LEVY, - status: CASE_STATUS_TYPES.NEW, + status: CASE_STATUS_TYPES.new, }, ]); }); diff --git a/web-api/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.ts b/web-api/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.ts index 5c0d993dc0f..8be78f158c3 100644 --- a/web-api/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.ts +++ b/web-api/src/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor.ts @@ -3,6 +3,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const getCaseInventoryReportInteractor = async ( applicationContext, { @@ -16,9 +17,8 @@ export const getCaseInventoryReportInteractor = async ( pageSize?: number; status?: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_INVENTORY_REPORT)) { throw new UnauthorizedError('Unauthorized for case inventory report'); } diff --git a/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts b/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts index 899dc41fdeb..161ee030272 100644 --- a/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts +++ b/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCaseInventoryReportLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCaseInventoryReportInteractor(applicationContext, { - ...event.queryStringParameters, - }); - }); +export const getCaseInventoryReportLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getCaseInventoryReportInteractor( + applicationContext, + { + ...event.queryStringParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 94c888d60c2021b535f27ab8775963138f22fc87 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Tue, 16 Jul 2024 09:55:28 -0700 Subject: [PATCH 225/523] 10417: remove appcontext.getCurrentUser from deleteCaseNoteInteractor --- .../updateCaseAndAssociations.ts | 5 +- .../caseNote/deleteCaseNoteInteractor.test.ts | 55 +++++++++++-------- .../caseNote/deleteCaseNoteInteractor.ts | 9 +-- .../lambdas/caseNote/deleteCaseNoteLambda.ts | 23 +++++--- 4 files changed, 57 insertions(+), 35 deletions(-) diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts index 6cc777e3f29..bac9075cdf0 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { CaseDeadline } from '../../../../../shared/src/business/entities/CaseDeadline'; import { Correspondence } from '../../../../../shared/src/business/entities/Correspondence'; @@ -442,15 +443,17 @@ const updateCaseDeadlines = async ({ */ export const updateCaseAndAssociations = async ({ applicationContext, + authorizedUser, caseToUpdate, }: { applicationContext: ServerApplicationContext; + authorizedUser: AuthUser; caseToUpdate: any; }): Promise => { const caseEntity: Case = caseToUpdate.validate ? caseToUpdate : new Case(caseToUpdate, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const oldCaseEntity = await applicationContext diff --git a/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.test.ts b/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.test.ts index 4861a8ca4bc..05b7392ee7c 100644 --- a/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.test.ts +++ b/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.test.ts @@ -1,16 +1,17 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError, UnauthorizedError, } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { deleteCaseNoteInteractor } from './deleteCaseNoteInteractor'; +import { mockJudgeUser } from '@shared/test/mockAuthUsers'; describe('deleteCaseNoteInteractor', () => { let mockLock; + let mockUser: AuthUser; beforeAll(() => { applicationContext @@ -20,22 +21,20 @@ describe('deleteCaseNoteInteractor', () => { beforeEach(() => { mockLock = undefined; - const mockUser = new User({ - name: 'Judge Colvin', - role: ROLES.judge, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - applicationContext.getCurrentUser.mockReturnValue(mockUser); + mockUser = mockJudgeUser; }); it('throws an error if the user is not valid or authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - + mockUser = {} as AuthUser; let error; try { - await deleteCaseNoteInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + await deleteCaseNoteInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockUser, + ); } catch (err) { error = err; } @@ -62,9 +61,13 @@ describe('deleteCaseNoteInteractor', () => { let result; try { - result = await deleteCaseNoteInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + result = await deleteCaseNoteInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockUser, + ); } catch (e) { error = e; } @@ -84,9 +87,13 @@ describe('deleteCaseNoteInteractor', () => { mockLock = MOCK_LOCK; await expect( - deleteCaseNoteInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }), + deleteCaseNoteInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -95,9 +102,13 @@ describe('deleteCaseNoteInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await deleteCaseNoteInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - }); + await deleteCaseNoteInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + }, + mockUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.ts b/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.ts index 0191920b3a1..48c7128c62f 100644 --- a/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.ts +++ b/web-api/src/business/useCases/caseNote/deleteCaseNoteInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -18,10 +19,9 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const deleteCaseNote = async ( applicationContext: ServerApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_NOTES)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_NOTES)) { throw new UnauthorizedError('Unauthorized'); } @@ -38,10 +38,11 @@ export const deleteCaseNote = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseRecord, }); - return new Case(result, { authorizedUser: user }).validate().toRawObject(); + return new Case(result, { authorizedUser }).validate().toRawObject(); }; export const deleteCaseNoteInteractor = withLocking( diff --git a/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts index 62554b4264d..400a349a813 100644 --- a/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const deleteCaseNoteLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteCaseNoteInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const deleteCaseNoteLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext.getUseCases().deleteCaseNoteInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 44d0f5b9fc7927a83025f5bc28a958333ccb5440 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Tue, 16 Jul 2024 10:49:54 -0700 Subject: [PATCH 226/523] 10417: remove appcontext.getCurrentUser from deleteUserCaseNoteInteractor --- .../deleteUserCaseNoteInteractor.test.ts | 58 +++++++++++-------- .../caseNote/deleteUserCaseNoteInteractor.ts | 10 ++-- .../caseNote/deleteUserCaseNoteLambda.ts | 28 ++++++--- 3 files changed, 61 insertions(+), 35 deletions(-) diff --git a/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.ts b/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.ts index f819cabc826..6f727ce2669 100644 --- a/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.ts +++ b/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.ts @@ -1,31 +1,40 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { deleteUserCaseNoteInteractor } from './deleteUserCaseNoteInteractor'; +import { mockJudgeUser } from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('deleteUserCaseNoteInteractor', () => { it('throws an error if the user is not valid or authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); + // applicationContext.getCurrentUser.mockReturnValue({}); + let user = {} as UnknownAuthUser; await expect( - deleteUserCaseNoteInteractor(applicationContext, { - docketNumber: '123-45', - }), + deleteUserCaseNoteInteractor( + applicationContext, + { + docketNumber: '123-45', + }, + user, + ), ).rejects.toThrow(new UnauthorizedError('Unauthorized')); }); it('deletes a case note', async () => { const mockUser = new User({ + email: 'email@example.com', name: 'Judge Colvin', role: ROLES.judge, section: 'colvinChambers', userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - applicationContext.getCurrentUser.mockReturnValue( - omit(mockUser, 'section'), - ); + }) as UnknownAuthUser; + + // applicationContext.getCurrentUser.mockReturnValue( + // omit(mockUser, 'section'), + // ); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(mockUser); @@ -37,23 +46,22 @@ describe('deleteUserCaseNoteInteractor', () => { userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); - const caseNote = await deleteUserCaseNoteInteractor(applicationContext, { - docketNumber: '123-45', - }); + const caseNote = await deleteUserCaseNoteInteractor( + applicationContext, + { + docketNumber: '123-45', + }, + omit(mockUser, 'section'), + ); expect(caseNote).toBeDefined(); }); it('deletes a case note associated with the current userId when there is no associated judge', async () => { - const mockUser = new User({ - name: 'Judge Colvin', - role: ROLES.judge, + const mockUser = { + ...mockJudgeUser, section: 'colvinChambers', - userId: '123456', - }); - applicationContext.getCurrentUser.mockReturnValue( - omit(mockUser, 'section'), - ); + } as UnknownAuthUser; applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(mockUser); @@ -61,13 +69,17 @@ describe('deleteUserCaseNoteInteractor', () => { applicationContext .getUseCaseHelpers() .getJudgeInSectionHelper.mockReturnValue(null); - await deleteUserCaseNoteInteractor(applicationContext, { - docketNumber: '123-45', - }); + await deleteUserCaseNoteInteractor( + applicationContext, + { + docketNumber: '123-45', + }, + omit(mockUser, 'section'), + ); expect( applicationContext.getPersistenceGateway().deleteUserCaseNote.mock .calls[0][0].userId, - ).toEqual('123456'); + ).toEqual(mockJudgeUser.userId); }); }); diff --git a/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.ts b/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.ts index 30f1af0481e..65809d66eaf 100644 --- a/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.ts +++ b/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * deleteUserCaseNoteInteractor @@ -16,17 +17,18 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const deleteUserCaseNoteInteractor = async ( applicationContext: ServerApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY) + ) { throw new UnauthorizedError('Unauthorized'); } const userId = await applicationContext .getUseCaseHelpers() .getUserIdForNote(applicationContext, { - userIdMakingRequest: user.userId, + userIdMakingRequest: authorizedUser.userId, }); return await applicationContext.getPersistenceGateway().deleteUserCaseNote({ diff --git a/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts index eaa8d5efdf6..e3607fdca61 100644 --- a/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const deleteUserCaseNoteLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteUserCaseNoteInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const deleteUserCaseNoteLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .deleteUserCaseNoteInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 484dcd585f7c3d5a47ca9007a86f8c77100d7342 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Tue, 16 Jul 2024 11:29:49 -0700 Subject: [PATCH 227/523] 10417: remove appcontext.getCurrentUser from getUserCaseNoteForCasesInteractor --- .../getUserCaseNoteForCasesInteractor.test.ts | 68 ++++++++++--------- .../getUserCaseNoteForCasesInteractor.ts | 16 ++--- .../caseNote/getUserCaseNoteForCasesLambda.ts | 28 +++++--- 3 files changed, 61 insertions(+), 51 deletions(-) diff --git a/web-api/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.test.ts b/web-api/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.test.ts index 81df6e33e92..31f054dfec4 100644 --- a/web-api/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.test.ts +++ b/web-api/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.test.ts @@ -1,13 +1,13 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getUserCaseNoteForCasesInteractor } from './getUserCaseNoteForCasesInteractor'; +import { mockJudgeUser } from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('getUserCaseNoteForCasesInteractor', () => { - let mockCurrentUser; + let mockCurrentUser: UnknownAuthUser; let mockNote; const MOCK_NOTE = { @@ -17,17 +17,13 @@ describe('getUserCaseNoteForCasesInteractor', () => { }; const mockJudge = { - role: ROLES.judge, + ...mockJudgeUser, section: 'colvinChambers', - userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', - }; + } as UnknownAuthUser; beforeEach(() => { mockCurrentUser = mockJudge; mockNote = MOCK_NOTE; - applicationContext.getCurrentUser.mockImplementation(() => - omit(new User(mockCurrentUser), 'section'), - ); applicationContext .getPersistenceGateway() .getUserById.mockImplementation(() => mockCurrentUser); @@ -43,11 +39,15 @@ describe('getUserCaseNoteForCasesInteractor', () => { mockCurrentUser = { role: 'unauthorizedRole', userId: 'unauthorizedUser', - }; + } as unknown as UnknownAuthUser; await expect( - getUserCaseNoteForCasesInteractor(applicationContext, { - docketNumbers: [MOCK_NOTE.docketNumber], - }), + getUserCaseNoteForCasesInteractor( + applicationContext, + { + docketNumbers: [MOCK_NOTE.docketNumber], + }, + omit(mockCurrentUser, 'section'), + ), ).rejects.toThrow(UnauthorizedError); }); @@ -57,42 +57,48 @@ describe('getUserCaseNoteForCasesInteractor', () => { .getUserCaseNoteForCases.mockResolvedValue([omit(MOCK_NOTE, 'userId')]); await expect( - getUserCaseNoteForCasesInteractor(applicationContext, { - docketNumbers: [MOCK_NOTE.docketNumber], - }), + getUserCaseNoteForCasesInteractor( + applicationContext, + { + docketNumbers: [MOCK_NOTE.docketNumber], + }, + mockCurrentUser, + ), ).rejects.toThrow('The UserCaseNote entity was invalid'); }); it('correctly returns data from persistence', async () => { - const result = await getUserCaseNoteForCasesInteractor(applicationContext, { - docketNumbers: [MOCK_NOTE.docketNumber], - }); + const result = await getUserCaseNoteForCasesInteractor( + applicationContext, + { + docketNumbers: [MOCK_NOTE.docketNumber], + }, + mockCurrentUser, + ); expect(result).toMatchObject([MOCK_NOTE]); }); it('uses the current user userId when there is no associated judge', async () => { const userIdToExpect = 'f922e1fc-567f-4f7d-b1f5-c9eec1567643'; - const mockUser = new User({ - name: 'Judge Colvin', - role: ROLES.judge, - section: 'colvinChambers', + const mockUser = { + ...mockJudge, userId: userIdToExpect, - }); - applicationContext.getCurrentUser.mockImplementation(() => - omit(mockUser, 'section'), - ); + } as UnknownAuthUser; applicationContext .getPersistenceGateway() .getUserById.mockImplementation(() => mockUser); - applicationContext.getCurrentUser.mockReturnValue(mockUser); applicationContext .getUseCaseHelpers() .getJudgeInSectionHelper.mockReturnValue(null); - await getUserCaseNoteForCasesInteractor(applicationContext, { - docketNumbers: [MOCK_NOTE.docketNumber], - }); + await getUserCaseNoteForCasesInteractor( + applicationContext, + { + docketNumbers: [MOCK_NOTE.docketNumber], + }, + omit(mockUser, 'section'), + ); expect( applicationContext.getPersistenceGateway().getUserCaseNoteForCases.mock diff --git a/web-api/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.ts b/web-api/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.ts index 826afc0bd44..91257ab2877 100644 --- a/web-api/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.ts +++ b/web-api/src/business/useCases/caseNote/getUserCaseNoteForCasesInteractor.ts @@ -3,30 +3,22 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { UserCaseNote } from '../../../../../shared/src/business/entities/notes/UserCaseNote'; -/** - * getUserCaseNoteForCasesInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.docketNumbers the docket numbers of the cases to get notes for - * @returns {object} the case note object if one is found - */ export const getUserCaseNoteForCasesInteractor = async ( applicationContext, { docketNumbers }: { docketNumbers: string[] }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } const userId = await applicationContext .getUseCaseHelpers() .getUserIdForNote(applicationContext, { - userIdMakingRequest: user.userId, + userIdMakingRequest: authorizedUser.userId, }); const caseNotes = await applicationContext diff --git a/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts b/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts index ba2ffd2dc07..274ea24cb25 100644 --- a/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts +++ b/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getUserCaseNoteForCasesLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getUserCaseNoteForCasesInteractor(applicationContext, { - docketNumbers: JSON.parse(event.body), - }); - }); +export const getUserCaseNoteForCasesLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getUserCaseNoteForCasesInteractor( + applicationContext, + { + docketNumbers: JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From c801e0a8114b7aba8cae8fc69d5d9d54fcf43178 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Tue, 16 Jul 2024 12:16:21 -0700 Subject: [PATCH 228/523] 10417: remove appcontext.getCurrentUser from updateUserCaseNoteInteractor --- .../updateUserCaseNoteInteractor.test.ts | 65 ++++++++++--------- .../caseNote/updateUserCaseNoteInteractor.ts | 19 ++---- .../caseNote/updateUserCaseNoteLambda.ts | 36 ++++++---- 3 files changed, 64 insertions(+), 56 deletions(-) diff --git a/web-api/src/business/useCases/caseNote/updateUserCaseNoteInteractor.test.ts b/web-api/src/business/useCases/caseNote/updateUserCaseNoteInteractor.test.ts index 1e6c6e4c308..d907227899e 100644 --- a/web-api/src/business/useCases/caseNote/updateUserCaseNoteInteractor.test.ts +++ b/web-api/src/business/useCases/caseNote/updateUserCaseNoteInteractor.test.ts @@ -1,7 +1,8 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockJudgeUser } from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; import { updateUserCaseNoteInteractor } from './updateUserCaseNoteInteractor'; @@ -13,26 +14,23 @@ describe('updateUserCaseNoteInteractor', () => { }; it('throws an error if the user is not valid or authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - updateUserCaseNoteInteractor(applicationContext, { - docketNumber: mockCaseNote.docketNumber, - notes: mockCaseNote.notes, - }), + updateUserCaseNoteInteractor( + applicationContext, + { + docketNumber: mockCaseNote.docketNumber, + notes: mockCaseNote.notes, + }, + {} as UnknownAuthUser, + ), ).rejects.toThrow(new UnauthorizedError('Unauthorized')); }); it('updates a case note', async () => { - const mockUser = new User({ - name: 'Judge Colvin', - role: ROLES.judge, + const mockUser = { + ...mockJudgeUser, section: 'colvinChambers', - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - applicationContext.getCurrentUser.mockImplementation(() => - omit(mockUser, 'section'), - ); + } as UnknownAuthUser; applicationContext .getPersistenceGateway() .getUserById.mockImplementation(() => mockUser); @@ -43,28 +41,29 @@ describe('updateUserCaseNoteInteractor', () => { .getUseCaseHelpers() .getJudgeInSectionHelper.mockReturnValue({ role: ROLES.judge, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', + userId: mockJudgeUser.userId, }); - const caseNote = await updateUserCaseNoteInteractor(applicationContext, { - docketNumber: mockCaseNote.docketNumber, - notes: mockCaseNote.notes, - }); + const caseNote = await updateUserCaseNoteInteractor( + applicationContext, + { + docketNumber: mockCaseNote.docketNumber, + notes: mockCaseNote.notes, + }, + omit(mockUser, 'section'), + ); expect(caseNote).toBeDefined(); }); it('updates a case note associated with the current userId when there is no associated judge', async () => { const userIdToExpect = 'f922e1fc-567f-4f7d-b1f5-c9eec1567643'; - const mockUser = new User({ - name: 'Judge Colvin', - role: ROLES.judge, + const mockUser = { + ...mockJudgeUser, section: 'colvinChambers', userId: userIdToExpect, - }); - applicationContext.getCurrentUser.mockImplementation(() => - omit(mockUser, 'section'), - ); + } as UnknownAuthUser; + applicationContext .getPersistenceGateway() .getUserById.mockImplementation(() => mockUser); @@ -73,10 +72,14 @@ describe('updateUserCaseNoteInteractor', () => { .getUseCaseHelpers() .getJudgeInSectionHelper.mockReturnValue(null); - await updateUserCaseNoteInteractor(applicationContext, { - docketNumber: mockCaseNote.docketNumber, - notes: mockCaseNote.notes, - }); + await updateUserCaseNoteInteractor( + applicationContext, + { + docketNumber: mockCaseNote.docketNumber, + notes: mockCaseNote.notes, + }, + omit(mockUser, 'section'), + ); expect( applicationContext.getPersistenceGateway().updateUserCaseNote.mock diff --git a/web-api/src/business/useCases/caseNote/updateUserCaseNoteInteractor.ts b/web-api/src/business/useCases/caseNote/updateUserCaseNoteInteractor.ts index 7a16ad63efa..b4894a0a629 100644 --- a/web-api/src/business/useCases/caseNote/updateUserCaseNoteInteractor.ts +++ b/web-api/src/business/useCases/caseNote/updateUserCaseNoteInteractor.ts @@ -3,31 +3,24 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { UserCaseNote } from '../../../../../shared/src/business/entities/notes/UserCaseNote'; -/** - * updateUserCaseNoteInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.docketNumber the docket number of the case to update notes - * @param {string} providers.notes the notes to update - * @returns {object} the updated case note returned from persistence - */ export const updateUserCaseNoteInteractor = async ( applicationContext, { docketNumber, notes }: { docketNumber: string; notes: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY) + ) { throw new UnauthorizedError('Unauthorized'); } const userId = await applicationContext .getUseCaseHelpers() .getUserIdForNote(applicationContext, { - userIdMakingRequest: user.userId, + userIdMakingRequest: authorizedUser.userId, }); const caseNoteEntity = new UserCaseNote({ diff --git a/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts index 68bdad9a9ad..9072eb3447f 100644 --- a/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,16 +7,27 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateUserCaseNoteLambda = event => - genericHandler(event, async ({ applicationContext }) => { - const lambdaArguments = { - ...event.pathParameters, - ...JSON.parse(event.body), - }; +export const updateUserCaseNoteLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + const lambdaArguments = { + ...event.pathParameters, + ...JSON.parse(event.body), + }; - return await applicationContext - .getUseCases() - .updateUserCaseNoteInteractor(applicationContext, { - ...lambdaArguments, - }); - }); + return await applicationContext + .getUseCases() + .updateUserCaseNoteInteractor( + applicationContext, + { + ...lambdaArguments, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 976bd932b597680d8ca56d92150d57d5e8ca620e Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Tue, 16 Jul 2024 14:10:15 -0700 Subject: [PATCH 229/523] 10417: remove appcontext.getCurrentUser from getUserCaseNoteInteractor --- .../getUserCaseNoteInteractor.test.ts | 97 ++++++++++--------- .../caseNote/getUserCaseNoteInteractor.ts | 10 +- .../lambdas/caseNote/getUserCaseNoteLambda.ts | 23 +++-- 3 files changed, 71 insertions(+), 59 deletions(-) diff --git a/web-api/src/business/useCases/caseNote/getUserCaseNoteInteractor.test.ts b/web-api/src/business/useCases/caseNote/getUserCaseNoteInteractor.test.ts index 1011b3736ec..c1e25eacca5 100644 --- a/web-api/src/business/useCases/caseNote/getUserCaseNoteInteractor.test.ts +++ b/web-api/src/business/useCases/caseNote/getUserCaseNoteInteractor.test.ts @@ -1,33 +1,25 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getUserCaseNoteInteractor } from './getUserCaseNoteInteractor'; +import { mockJudgeUser } from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('Get case note', () => { const MOCK_NOTE = { docketNumber: MOCK_CASE.docketNumber, notes: 'something', - userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', + userId: mockJudgeUser.userId, }; const mockUnauthorizedUser = { role: 'unauthorizedRole', userId: 'unauthorizedUser', - }; - - const mockJudge = { - role: ROLES.judge, - section: 'colvinChambers', - userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', - }; + } as unknown as UnknownAuthUser; it('throws error if user is unauthorized', async () => { - applicationContext.getCurrentUser.mockImplementation(() => - omit(new User(mockUnauthorizedUser), 'section'), - ); applicationContext .getPersistenceGateway() .getUserById.mockImplementation(() => new User(mockUnauthorizedUser)); @@ -39,61 +31,64 @@ describe('Get case note', () => { .getJudgeInSectionHelper.mockReturnValue(null); await expect( - getUserCaseNoteInteractor(applicationContext, { - docketNumber: MOCK_NOTE.docketNumber, - }), + getUserCaseNoteInteractor( + applicationContext, + { + docketNumber: MOCK_NOTE.docketNumber, + }, + mockUnauthorizedUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('throws an error if the entity returned from persistence is invalid', async () => { - applicationContext.getCurrentUser.mockImplementation(() => - omit(new User(mockJudge), 'section'), - ); applicationContext .getPersistenceGateway() - .getUserById.mockImplementation(() => new User(mockJudge)); + .getUserById.mockImplementation(() => new User(mockJudgeUser)); applicationContext .getPersistenceGateway() .getUserCaseNote.mockResolvedValue(omit(MOCK_NOTE, 'userId')); applicationContext .getUseCaseHelpers() - .getJudgeInSectionHelper.mockReturnValue(mockJudge); + .getJudgeInSectionHelper.mockReturnValue(mockJudgeUser); await expect( - getUserCaseNoteInteractor(applicationContext, { - docketNumber: MOCK_NOTE.docketNumber, - }), + getUserCaseNoteInteractor( + applicationContext, + { + docketNumber: MOCK_NOTE.docketNumber, + }, + omit(mockJudgeUser, 'section'), + ), ).rejects.toThrow('The UserCaseNote entity was invalid'); }); it('correctly returns data from persistence if a judgeUser exists', async () => { - applicationContext.getCurrentUser.mockImplementation(() => - omit(new User(mockJudge), 'section'), - ); applicationContext .getPersistenceGateway() - .getUserById.mockImplementation(() => new User(mockJudge)); + .getUserById.mockImplementation(() => new User(mockJudgeUser)); applicationContext .getPersistenceGateway() .getUserCaseNote.mockResolvedValue(MOCK_NOTE); applicationContext .getUseCaseHelpers() - .getJudgeInSectionHelper.mockReturnValue(mockJudge); + .getJudgeInSectionHelper.mockReturnValue(mockJudgeUser); - const result = await getUserCaseNoteInteractor(applicationContext, { - docketNumber: MOCK_NOTE.docketNumber, - }); + const result = await getUserCaseNoteInteractor( + applicationContext, + { + docketNumber: MOCK_NOTE.docketNumber, + }, + omit(mockJudgeUser, 'section'), + ); expect(result).toMatchObject(MOCK_NOTE); }); it('correctly returns data from persistence for the current user if a judgeUser does not exist', async () => { - applicationContext.getCurrentUser.mockImplementation(() => - omit(new User(mockJudge), 'section'), - ); applicationContext .getPersistenceGateway() - .getUserById.mockImplementation(() => new User(mockJudge)); + .getUserById.mockImplementation(() => new User(mockJudgeUser)); applicationContext .getPersistenceGateway() .getUserCaseNote.mockResolvedValue(MOCK_NOTE); @@ -101,30 +96,38 @@ describe('Get case note', () => { .getUseCaseHelpers() .getJudgeInSectionHelper.mockReturnValue(null); - const result = await getUserCaseNoteInteractor(applicationContext, { - docketNumber: MOCK_NOTE.docketNumber, - }); + const result = await getUserCaseNoteInteractor( + applicationContext, + { + docketNumber: MOCK_NOTE.docketNumber, + }, + mockJudgeUser, + ); - expect(result).toMatchObject({ ...MOCK_NOTE, userId: mockJudge.userId }); + expect(result).toMatchObject({ + ...MOCK_NOTE, + userId: mockJudgeUser.userId, + }); }); it('does not return anything if nothing is returned from persistence', async () => { - applicationContext.getCurrentUser.mockImplementation(() => - omit(new User(mockJudge), 'section'), - ); applicationContext .getPersistenceGateway() - .getUserById.mockImplementation(() => new User(mockJudge)); + .getUserById.mockImplementation(() => new User(mockJudgeUser)); applicationContext .getPersistenceGateway() .getUserCaseNote.mockReturnValue(null); applicationContext .getUseCaseHelpers() - .getJudgeInSectionHelper.mockReturnValue(mockJudge); + .getJudgeInSectionHelper.mockReturnValue(mockJudgeUser); - const result = await getUserCaseNoteInteractor(applicationContext, { - docketNumber: MOCK_NOTE.docketNumber, - }); + const result = await getUserCaseNoteInteractor( + applicationContext, + { + docketNumber: MOCK_NOTE.docketNumber, + }, + mockJudgeUser, + ); expect(result).toEqual(undefined); }); diff --git a/web-api/src/business/useCases/caseNote/getUserCaseNoteInteractor.ts b/web-api/src/business/useCases/caseNote/getUserCaseNoteInteractor.ts index 91f1adb7429..d7c1c37af7d 100644 --- a/web-api/src/business/useCases/caseNote/getUserCaseNoteInteractor.ts +++ b/web-api/src/business/useCases/caseNote/getUserCaseNoteInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { UserCaseNote } from '../../../../../shared/src/business/entities/notes/UserCaseNote'; /** @@ -17,17 +18,18 @@ import { UserCaseNote } from '../../../../../shared/src/business/entities/notes/ export const getUserCaseNoteInteractor = async ( applicationContext: ServerApplicationContext, { docketNumber }: { docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY) + ) { throw new UnauthorizedError('Unauthorized'); } const userId = await applicationContext .getUseCaseHelpers() .getUserIdForNote(applicationContext, { - userIdMakingRequest: user.userId, + userIdMakingRequest: authorizedUser.userId, }); const caseNote = await applicationContext diff --git a/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts index c5b62cff9ac..7fa888effdf 100644 --- a/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getUserCaseNoteLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getUserCaseNoteInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const getUserCaseNoteLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext.getUseCases().getUserCaseNoteInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 99377da9c7bc389f5bb4a0b1e9e9abf0c5b0023b Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Tue, 16 Jul 2024 15:50:04 -0700 Subject: [PATCH 230/523] 10417: remove appcontext.getCurrentUser from deleteDeficiencyStatisticInteractor --- ...eleteDeficiencyStatisticInteractor.test.ts | 61 +++++++++++-------- .../deleteDeficiencyStatisticInteractor.ts | 13 ++-- .../cases/deleteDeficiencyStatisticLambda.ts | 28 ++++++--- 3 files changed, 62 insertions(+), 40 deletions(-) diff --git a/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.test.ts b/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.test.ts index 29b461e5c40..f8093b119c5 100644 --- a/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.test.ts +++ b/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.test.ts @@ -1,12 +1,11 @@ -import { - CASE_TYPES_MAP, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { CASE_TYPES_MAP } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { deleteDeficiencyStatisticInteractor } from './deleteDeficiencyStatisticInteractor'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('deleteDeficiencyStatisticInteractor', () => { const statisticId = 'f7a1cdb5-f534-4d12-a046-86ca3b46ddc4'; @@ -30,10 +29,6 @@ describe('deleteDeficiencyStatisticInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); applicationContext .getPersistenceGateway() @@ -43,12 +38,14 @@ describe('deleteDeficiencyStatisticInteractor', () => { }); it('should throw an error if the user is unauthorized to update case statistics', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - deleteDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - } as any), + deleteDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + } as any, + {} as unknown as UnknownAuthUser, + ), ).rejects.toThrow('Unauthorized for editing statistics'); }); @@ -59,6 +56,7 @@ describe('deleteDeficiencyStatisticInteractor', () => { docketNumber: MOCK_CASE.docketNumber, statisticId, }, + mockDocketClerkUser, ); expect(result).toMatchObject({ statistics: [], @@ -79,6 +77,7 @@ describe('deleteDeficiencyStatisticInteractor', () => { docketNumber: MOCK_CASE.docketNumber, statisticId: '8b864301-a0d9-43aa-8029-e1a0ed8ad4c9', }, + mockDocketClerkUser, ); expect(result).toMatchObject({ statistics: [statistic], @@ -105,10 +104,14 @@ describe('deleteDeficiencyStatisticInteractor', () => { ); await expect( - deleteDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - statisticId: statistic.statisticId, - }), + deleteDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + statisticId: statistic.statisticId, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('The Case entity was invalid'); expect( applicationContext.getPersistenceGateway().updateCase, @@ -119,10 +122,14 @@ describe('deleteDeficiencyStatisticInteractor', () => { mockLock = MOCK_LOCK; await expect( - deleteDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - statisticId: '8b864301-a0d9-43aa-8029-e1a0ed8ad4c9', - }), + deleteDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + statisticId: '8b864301-a0d9-43aa-8029-e1a0ed8ad4c9', + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -131,10 +138,14 @@ describe('deleteDeficiencyStatisticInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await deleteDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - statisticId: '8b864301-a0d9-43aa-8029-e1a0ed8ad4c9', - }); + await deleteDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + statisticId: '8b864301-a0d9-43aa-8029-e1a0ed8ad4c9', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.ts b/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.ts index fcac8f0a09c..0f920830691 100644 --- a/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -19,10 +20,9 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const deleteDeficiencyStatistic = async ( applicationContext: ServerApplicationContext, { docketNumber, statisticId }: { docketNumber: string; statisticId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS)) { throw new UnauthorizedError('Unauthorized for editing statistics'); } @@ -30,19 +30,18 @@ export const deleteDeficiencyStatistic = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const newCase = new Case(oldCase, { authorizedUser: user }); + const newCase = new Case(oldCase, { authorizedUser }); newCase.deleteStatistic(statisticId); const updatedCase = await applicationContext .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: newCase, }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const deleteDeficiencyStatisticInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts b/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts index dc4e82af4fb..e203eee984a 100644 --- a/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts +++ b/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const deleteDeficiencyStatisticLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteDeficiencyStatisticInteractor(applicationContext, { - ...event.pathParameters, - }); - }); +export const deleteDeficiencyStatisticLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .deleteDeficiencyStatisticInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 7e2462a75622959e1a64f0a2b01533c04d870ac6 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Wed, 17 Jul 2024 11:49:21 -0700 Subject: [PATCH 231/523] 10417: remove appcontext.getCurrentUser from updateDeficiencyStatisticInteractor --- ...pdateDeficiencyStatisticInteractor.test.ts | 47 ++++++++++++------- .../updateDeficiencyStatisticInteractor.ts | 13 +++-- .../cases/updateDeficiencyStatisticLambda.ts | 30 ++++++++---- 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.test.ts b/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.test.ts index 71e158f54e3..d8ea74fb509 100644 --- a/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.test.ts +++ b/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.test.ts @@ -1,8 +1,9 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { updateDeficiencyStatisticInteractor } from './updateDeficiencyStatisticInteractor'; describe('updateDeficiencyStatisticInteractor', () => { @@ -30,6 +31,7 @@ describe('updateDeficiencyStatisticInteractor', () => { yearOrPeriod: 'Year', }; let mockLock; + let authorizedUser: UnknownAuthUser; beforeAll(() => { applicationContext @@ -39,10 +41,7 @@ describe('updateDeficiencyStatisticInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); + authorizedUser = mockDocketClerkUser; applicationContext .getPersistenceGateway() @@ -52,12 +51,16 @@ describe('updateDeficiencyStatisticInteractor', () => { }); it('should throw an error if the user is unauthorized to update case statistics', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); + authorizedUser = {} as unknown as UnknownAuthUser; await expect( - updateDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - } as any), + updateDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + } as any, + authorizedUser, + ), ).rejects.toThrow('Unauthorized for editing statistics'); }); @@ -73,6 +76,7 @@ describe('updateDeficiencyStatisticInteractor', () => { docketNumber: MOCK_CASE.docketNumber, ...statisticToUpdate, } as any, + authorizedUser, ); expect(result).toMatchObject({ statistics: [statisticToUpdate], @@ -92,6 +96,7 @@ describe('updateDeficiencyStatisticInteractor', () => { docketNumber: MOCK_CASE.docketNumber, ...statisticToUpdate, } as any, + authorizedUser, ); expect(result).toMatchObject({ statistics: [statistic], @@ -102,10 +107,14 @@ describe('updateDeficiencyStatisticInteractor', () => { mockLock = MOCK_LOCK; await expect( - updateDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - ...statistic, - } as any), + updateDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + ...statistic, + } as any, + authorizedUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -114,10 +123,14 @@ describe('updateDeficiencyStatisticInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await updateDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - ...statistic, - } as any); + await updateDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + ...statistic, + } as any, + authorizedUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts b/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts index 20a847dcbfc..33230cc7959 100644 --- a/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor.ts @@ -6,6 +6,7 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { Statistic } from '../../../../../shared/src/business/entities/Statistic'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -54,10 +55,9 @@ export const updateDeficiencyStatistic = async ( year: string; yearOrPeriod: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS)) { throw new UnauthorizedError('Unauthorized for editing statistics'); } @@ -77,19 +77,18 @@ export const updateDeficiencyStatistic = async ( yearOrPeriod, }).validate(); - const newCase = new Case(oldCase, { authorizedUser: user }); + const newCase = new Case(oldCase, { authorizedUser }); newCase.updateStatistic(statisticEntity, statisticId); const updatedCase = await applicationContext .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: newCase, }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const updateDeficiencyStatisticInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts b/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts index b344d0505fa..e5e3e3f9419 100644 --- a/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts +++ b/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +7,23 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateDeficiencyStatisticLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateDeficiencyStatisticInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); +export const updateDeficiencyStatisticLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => + genericHandler( + event, + async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .updateDeficiencyStatisticInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }, + authorizedUser, + ); From 67c8c3e68f0204b3e3588205b74f147b5b6d11b7 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 14:06:01 -0500 Subject: [PATCH 232/523] 10417: stop passing user to genericHandler for backwards compatibility --- docs/remove-get-current-user.md | 1 - web-api/src/genericHandler.ts | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index 790b2ae1f81..a8b79cd274a 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -74,6 +74,5 @@ export const addPetitionerToCaseLambda = ( authorizedUser, ); }, - authorizedUser, ); ``` \ No newline at end of file diff --git a/web-api/src/genericHandler.ts b/web-api/src/genericHandler.ts index d68fb00a748..156861f1caa 100644 --- a/web-api/src/genericHandler.ts +++ b/web-api/src/genericHandler.ts @@ -78,19 +78,15 @@ export const genericHandler = ( applicationContext: ServerApplicationContext; clientConnectionId?: string; }) => any, - user: UnknownAuthUser, options: { bypassMaintenanceCheck?: boolean; logResults?: boolean; } = {}, ) => { return handle(awsEvent, async () => { - const deprecatedUser = getUserFromAuthHeader(awsEvent); // TODO 10417: remove getting user here. Should be passed in. + const user = getUserFromAuthHeader(awsEvent); // TODO 10417: remove getting user here. Should be passed in. const clientConnectionId = getConnectionIdFromEvent(awsEvent); - const applicationContext = createApplicationContext( - deprecatedUser, - awsEvent.logger, - ); + const applicationContext = createApplicationContext(user, awsEvent.logger); delete awsEvent.logger; From 9cd84cc674b58974989299829dc9c4dd1f01bf2a Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Wed, 17 Jul 2024 12:12:22 -0700 Subject: [PATCH 233/523] 10417: updated lambdas to use 2-arg genericHandler call instead of 3-arg --- .../caseDeadline/createCaseDeadlineLambda.ts | 24 +++++-------- .../caseDeadline/deleteCaseDeadlineLambda.ts | 24 +++++-------- .../caseDeadline/updateCaseDeadlineLambda.ts | 24 +++++-------- .../lambdas/caseNote/deleteCaseNoteLambda.ts | 22 +++++------- .../caseNote/deleteUserCaseNoteLambda.ts | 24 +++++-------- .../caseNote/getUserCaseNoteForCasesLambda.ts | 26 ++++++-------- .../lambdas/caseNote/getUserCaseNoteLambda.ts | 22 +++++------- .../caseNote/updateUserCaseNoteLambda.ts | 32 +++++++---------- .../cases/deleteDeficiencyStatisticLambda.ts | 26 ++++++-------- .../cases/removeConsolidatedCasesLambda.ts | 34 ++++++++----------- .../cases/updateDeficiencyStatisticLambda.ts | 28 +++++++-------- .../reports/getCaseInventoryReportLambda.ts | 26 ++++++-------- 12 files changed, 127 insertions(+), 185 deletions(-) diff --git a/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts b/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts index 3255bf6929e..d2b82d7d6cd 100644 --- a/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts +++ b/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts @@ -11,18 +11,12 @@ export const createCaseDeadlineLambda = ( event, authorizedUser: UnknownAuthUser, ): Promise => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createCaseDeadlineInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext.getUseCases().createCaseDeadlineInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseDeadline/deleteCaseDeadlineLambda.ts b/web-api/src/lambdas/caseDeadline/deleteCaseDeadlineLambda.ts index cd68e6d2388..3ea5d69a110 100644 --- a/web-api/src/lambdas/caseDeadline/deleteCaseDeadlineLambda.ts +++ b/web-api/src/lambdas/caseDeadline/deleteCaseDeadlineLambda.ts @@ -11,18 +11,12 @@ export const deleteCaseDeadlineLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteCaseDeadlineInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext.getUseCases().deleteCaseDeadlineInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts b/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts index a924eee9890..126c3737416 100644 --- a/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts +++ b/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts @@ -11,18 +11,12 @@ export const updateCaseDeadlineLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCaseDeadlineInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext.getUseCases().updateCaseDeadlineInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts index 400a349a813..02882301b80 100644 --- a/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts @@ -8,16 +8,12 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const deleteCaseNoteLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext.getUseCases().deleteCaseNoteInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext.getUseCases().deleteCaseNoteInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts index e3607fdca61..df961bee972 100644 --- a/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts @@ -11,18 +11,12 @@ export const deleteUserCaseNoteLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteUserCaseNoteInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext.getUseCases().deleteUserCaseNoteInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts b/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts index 274ea24cb25..10a2927d86c 100644 --- a/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts +++ b/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts @@ -11,18 +11,14 @@ export const getUserCaseNoteForCasesLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getUserCaseNoteForCasesInteractor( - applicationContext, - { - docketNumbers: JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getUserCaseNoteForCasesInteractor( + applicationContext, + { + docketNumbers: JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts index 7fa888effdf..84deccf1433 100644 --- a/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts @@ -8,16 +8,12 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getUserCaseNoteLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext.getUseCases().getUserCaseNoteInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext.getUseCases().getUserCaseNoteInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts index 9072eb3447f..205d45a72ae 100644 --- a/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts @@ -11,23 +11,17 @@ export const updateUserCaseNoteLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const lambdaArguments = { - ...event.pathParameters, - ...JSON.parse(event.body), - }; + genericHandler(event, async ({ applicationContext }) => { + const lambdaArguments = { + ...event.pathParameters, + ...JSON.parse(event.body), + }; - return await applicationContext - .getUseCases() - .updateUserCaseNoteInteractor( - applicationContext, - { - ...lambdaArguments, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await applicationContext.getUseCases().updateUserCaseNoteInteractor( + applicationContext, + { + ...lambdaArguments, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts b/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts index e203eee984a..22effcd845d 100644 --- a/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts +++ b/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts @@ -11,18 +11,14 @@ export const deleteDeficiencyStatisticLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteDeficiencyStatisticInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .deleteDeficiencyStatisticInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts b/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts index ea6ace08a0a..e9dcc2c935a 100644 --- a/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts +++ b/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts @@ -11,23 +11,19 @@ export const removeConsolidatedCasesLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const docketNumbersToRemove = ( - event.queryStringParameters.docketNumbersToRemove || '' - ).split(','); + genericHandler(event, async ({ applicationContext }) => { + const docketNumbersToRemove = ( + event.queryStringParameters.docketNumbersToRemove || '' + ).split(','); - return await applicationContext - .getUseCases() - .removeConsolidatedCasesInteractor( - applicationContext, - { - ...event.pathParameters, - docketNumbersToRemove, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await applicationContext + .getUseCases() + .removeConsolidatedCasesInteractor( + applicationContext, + { + ...event.pathParameters, + docketNumbersToRemove, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts b/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts index e5e3e3f9419..ac512fe0082 100644 --- a/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts +++ b/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts @@ -11,19 +11,15 @@ export const updateDeficiencyStatisticLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateDeficiencyStatisticInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .updateDeficiencyStatisticInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts b/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts index 161ee030272..a50a66f80e7 100644 --- a/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts +++ b/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts @@ -11,18 +11,14 @@ export const getCaseInventoryReportLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCaseInventoryReportInteractor( - applicationContext, - { - ...event.queryStringParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .getCaseInventoryReportInteractor( + applicationContext, + { + ...event.queryStringParameters, + }, + authorizedUser, + ); + }); From 360741fbd750a24253b89ab729a1d0e89896e49b Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Wed, 17 Jul 2024 16:13:49 -0400 Subject: [PATCH 234/523] 10417 rm getCurrentUser from fileDocumentHelper --- .../computeds/fileDocumentHelper.test.ts | 188 ++++++++++++------ .../presenter/computeds/fileDocumentHelper.ts | 2 +- 2 files changed, 130 insertions(+), 60 deletions(-) diff --git a/web-client/src/presenter/computeds/fileDocumentHelper.test.ts b/web-client/src/presenter/computeds/fileDocumentHelper.test.ts index 4cfdd2d89d1..fd101749915 100644 --- a/web-client/src/presenter/computeds/fileDocumentHelper.test.ts +++ b/web-client/src/presenter/computeds/fileDocumentHelper.test.ts @@ -24,7 +24,7 @@ describe('fileDocumentHelper', () => { validationErrors: {}, }; - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); + //applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); const fileDocumentHelper = withAppContextDecorator( fileDocumentHelperComputed, @@ -36,7 +36,11 @@ describe('fileDocumentHelper', () => { }); it('returns correct values when documentType is undefined', () => { - let testState = { ...state, form: { documentType: undefined } }; + let testState = { + ...state, + form: { documentType: undefined }, + user: docketClerkUser, + }; const expected = { isSecondaryDocumentUploadOptional: false, @@ -54,7 +58,9 @@ describe('fileDocumentHelper', () => { }); it('returns a correctly-formatted list of supporting documents', () => { - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.supportingDocumentTypeList.length > 0).toBeTruthy(); expect( @@ -64,13 +70,17 @@ describe('fileDocumentHelper', () => { it('has optional secondary document upload when motion for leave to file', () => { state.form = { documentType: 'Motion for Leave to File' }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.isSecondaryDocumentUploadOptional).toBeTruthy(); }); it('does not show secondary inclusions if document type is motion for leave to file and a secondary document has not been selected', () => { state.form = { documentType: 'Motion for Leave to File' }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showSecondaryDocumentInclusionsForm).toBeFalsy(); }); @@ -79,13 +89,17 @@ describe('fileDocumentHelper', () => { documentType: 'Motion for Leave to File', secondaryDocumentFile: 'something', }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showSecondaryDocumentInclusionsForm).toBeTruthy(); }); it('shows primary objection if primary document type is a motion', () => { state.form = { documentType: 'Motion for Leave to File' }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.primaryDocument.showObjection).toBeTruthy(); }); @@ -96,7 +110,9 @@ describe('fileDocumentHelper', () => { documentType: 'Motion for Continuance', }, }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.primaryDocument.showObjection).toBeTruthy(); expect(result.secondaryDocument.showObjection).toBeFalsy(); }); @@ -109,7 +125,9 @@ describe('fileDocumentHelper', () => { }, secondaryDocumentFile: 'something', }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.primaryDocument.showObjection).toBeTruthy(); expect(result.secondaryDocument.showObjection).toBeTruthy(); }); @@ -118,7 +136,9 @@ describe('fileDocumentHelper', () => { state.form = { documentType: 'Supplemental Brief', }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.primaryDocument.showObjection).toBeFalsy(); expect(result.secondaryDocument.showObjection).toBeFalsy(); }); @@ -130,7 +150,9 @@ describe('fileDocumentHelper', () => { documentType: 'Supplemental Brief', }, }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.primaryDocument.showObjection).toBeTruthy(); expect(result.secondaryDocument.showObjection).toBeFalsy(); }); @@ -142,20 +164,26 @@ describe('fileDocumentHelper', () => { secondaryDocumentFile: { some: 'file' }, }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showPrimaryDocumentValid).toBeTruthy(); expect(result.showSecondaryDocumentValid).toBeTruthy(); }); it('shows secondary party for petitionerSpouse or petitionerDeceasedSpouse', () => { state.caseDetail.partyType = PARTY_TYPES.petitionerSpouse; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showSecondaryParty).toBeTruthy(); }); it('generates correctly formatted service date', () => { state.form.certificateOfServiceDate = '2012-05-31'; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.certificateOfServiceDateFormatted).toEqual('05/31/12'); }); @@ -164,20 +192,26 @@ describe('fileDocumentHelper', () => { certificateOfService: true, certificateOfServiceDate: '2012-06-30', }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.secondaryDocument.certificateOfServiceDateFormatted).toEqual( '06/30/12', ); }); it('does not generate a formatted service date if a service date is not entered on the form', () => { - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.certificateOfServiceDateFormatted).toBeUndefined(); }); it('does not generate a formatted service date for secondary document if a service date is not entered on the form', () => { state.form.secondaryDocument = undefined; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect( result.secondaryDocument.certificateOfServiceDateFormatted, ).toBeUndefined(); @@ -186,25 +220,33 @@ describe('fileDocumentHelper', () => { it('shows Filing Includes on review page if certificateOfService is true', () => { state.form.certificateOfService = true; state.form.certificateOfServiceDate = '2018-01-01'; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showFilingIncludes).toEqual(true); }); it('does not show Filing Includes if certOfService and attachments are false', () => { state.form.certificateOfService = false; state.form.attachments = false; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showFilingIncludes).toEqual(false); }); it('does not show party validation error if none of the party validation errors exists', () => { - const result = runCompute(fileDocumentHelper, { state }); + const result = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.partyValidationError).toBeUndefined(); }); it('shows party validation error if any one of the party validation errors exists', () => { state.validationErrors = { filers: 'You did something bad.' }; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.partyValidationError).toEqual('You did something bad.'); }); @@ -215,7 +257,9 @@ describe('fileDocumentHelper', () => { }); it('shows Add Supporting Document button and not limit reached message when supportingDocuments is undefined', () => { - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showAddSupportingDocuments).toBeTruthy(); expect(result.showAddSupportingDocumentsLimitReached).toBeFalsy(); }); @@ -227,7 +271,9 @@ describe('fileDocumentHelper', () => { { id: '3' }, { id: '4' }, ]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showAddSupportingDocuments).toBeTruthy(); expect(result.showAddSupportingDocumentsLimitReached).toBeFalsy(); }); @@ -240,7 +286,9 @@ describe('fileDocumentHelper', () => { { id: '4' }, { id: '5' }, ]; - let result: any = runCompute(fileDocumentHelper, { state }); + let result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showAddSupportingDocuments).toBeFalsy(); expect(result.showAddSupportingDocumentsLimitReached).toBeTruthy(); state.form.supportingDocuments = [ @@ -251,14 +299,18 @@ describe('fileDocumentHelper', () => { { id: '5' }, { id: '6' }, ]; - result = runCompute(fileDocumentHelper, { state }); + result = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showAddSupportingDocuments).toBeFalsy(); expect(result.showAddSupportingDocumentsLimitReached).toBeTruthy(); }); it('upload and free text not shown if no type selected', () => { state.form.supportingDocuments = [{ supportingDocument: '' }]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect( result.supportingDocuments[0].showSupportingDocumentFreeText, ).toBeFalsy(); @@ -271,7 +323,9 @@ describe('fileDocumentHelper', () => { state.form.supportingDocuments = [ { supportingDocument: 'Some Document type' }, ]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect( result.supportingDocuments[0].showSupportingDocumentFreeText, ).toBeFalsy(); @@ -284,7 +338,9 @@ describe('fileDocumentHelper', () => { state.form.supportingDocuments = [ { supportingDocument: 'Affidavit in Support' }, ]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect( result.supportingDocuments[0].showSupportingDocumentFreeText, ).toBeTruthy(); @@ -295,7 +351,9 @@ describe('fileDocumentHelper', () => { it('filing includes is shown if attachments is true', () => { state.form.supportingDocuments = [{ attachments: true }]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.supportingDocuments[0].showFilingIncludes).toBeTruthy(); }); @@ -306,7 +364,9 @@ describe('fileDocumentHelper', () => { certificateOfServiceDate: '2019-01-01', }, ]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.supportingDocuments[0].showFilingIncludes).toBeTruthy(); expect( result.supportingDocuments[0].certificateOfServiceDateFormatted, @@ -315,7 +375,9 @@ describe('fileDocumentHelper', () => { describe('for secondary supporting document', () => { it('shows Add Secondary Supporting Document button and not limit reached message when secondarySupportingDocuments is undefined', () => { - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showAddSecondarySupportingDocuments).toBeTruthy(); expect( result.showAddSecondarySupportingDocumentsLimitReached, @@ -324,7 +386,9 @@ describe('fileDocumentHelper', () => { it('does not show Add Secondary Supporting Document button or limit reached message when primary document type is Motion for Leave to File and secondary file is not selected', () => { state.form.documentType = 'Motion for Leave to File'; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showAddSecondarySupportingDocuments).toBeFalsy(); expect( result.showAddSecondarySupportingDocumentsLimitReached, @@ -338,7 +402,9 @@ describe('fileDocumentHelper', () => { { id: '3' }, { id: '4' }, ]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showAddSecondarySupportingDocuments).toBeTruthy(); expect( result.showAddSecondarySupportingDocumentsLimitReached, @@ -353,7 +419,9 @@ describe('fileDocumentHelper', () => { { id: '4' }, { id: '5' }, ]; - let result: any = runCompute(fileDocumentHelper, { state }); + let result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showAddSecondarySupportingDocuments).toBeFalsy(); expect( result.showAddSecondarySupportingDocumentsLimitReached, @@ -366,7 +434,9 @@ describe('fileDocumentHelper', () => { { id: '5' }, { id: '6' }, ]; - result = runCompute(fileDocumentHelper, { state }); + result = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect(result.showAddSecondarySupportingDocuments).toBeFalsy(); expect( result.showAddSecondarySupportingDocumentsLimitReached, @@ -375,7 +445,9 @@ describe('fileDocumentHelper', () => { it('upload and free text not shown if no type selected', () => { state.form.secondarySupportingDocuments = [{ supportingDocument: '' }]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect( result.secondarySupportingDocuments[0].showSupportingDocumentFreeText, ).toBeFalsy(); @@ -388,7 +460,9 @@ describe('fileDocumentHelper', () => { state.form.secondarySupportingDocuments = [ { supportingDocument: 'Declaration of Undying Love' }, ]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect( result.secondarySupportingDocuments[0].showSupportingDocumentFreeText, ).toBeFalsy(); @@ -401,7 +475,9 @@ describe('fileDocumentHelper', () => { state.form.secondarySupportingDocuments = [ { supportingDocument: 'Affidavit in Support' }, ]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect( result.secondarySupportingDocuments[0].showSupportingDocumentFreeText, ).toBeTruthy(); @@ -412,7 +488,9 @@ describe('fileDocumentHelper', () => { it('filing includes is shown if attachments is true', () => { state.form.secondarySupportingDocuments = [{ attachments: true }]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect( result.secondarySupportingDocuments[0].showFilingIncludes, ).toBeTruthy(); @@ -425,7 +503,9 @@ describe('fileDocumentHelper', () => { certificateOfServiceDate: '2019-01-01', }, ]; - const result: any = runCompute(fileDocumentHelper, { state }); + const result: any = runCompute(fileDocumentHelper, { + state: { ...state, user: docketClerkUser }, + }); expect( result.secondarySupportingDocuments[0].showFilingIncludes, ).toBeTruthy(); @@ -474,7 +554,7 @@ describe('fileDocumentHelper', () => { it('should be set to the names of all filing petitioners and their titles', () => { const { formattedFilingParties } = runCompute(fileDocumentHelper, { - state, + state: { ...state, user: docketClerkUser }, }); expect(formattedFilingParties).toEqual([ @@ -492,7 +572,7 @@ describe('fileDocumentHelper', () => { }; const { EARedactionAcknowledgement } = runCompute(fileDocumentHelper, { - state, + state: { ...state, user: docketClerkUser }, }); expect(EARedactionAcknowledgement).toEqual(true); @@ -505,7 +585,7 @@ describe('fileDocumentHelper', () => { }; const { EARedactionAcknowledgement } = runCompute(fileDocumentHelper, { - state, + state: { ...state, user: docketClerkUser }, }); expect(EARedactionAcknowledgement).toEqual(false); @@ -518,7 +598,7 @@ describe('fileDocumentHelper', () => { }; const { EARedactionAcknowledgement } = runCompute(fileDocumentHelper, { - state, + state: { ...state, user: docketClerkUser }, }); expect(EARedactionAcknowledgement).toEqual(false); @@ -532,7 +612,7 @@ describe('fileDocumentHelper', () => { }; const { isAutoGenerated } = runCompute(fileDocumentHelper, { - state, + state: { ...state, user: docketClerkUser }, }); expect(isAutoGenerated).toEqual(true); @@ -541,8 +621,6 @@ describe('fileDocumentHelper', () => { describe('showGenerationTypeForm', () => { it('should set showGenerationTypeForm to true if showGenerationType returns true', () => { - applicationContext.getCurrentUser.mockReturnValue(irsPractitionerUser); - state.form = { eventCode: 'EA', generationType: GENERATION_TYPES.AUTO, @@ -557,7 +635,7 @@ describe('fileDocumentHelper', () => { }; const { showGenerationTypeForm } = runCompute(fileDocumentHelper, { - state, + state: { ...state, user: irsPractitionerUser }, }); expect(showGenerationTypeForm).toEqual(true); @@ -565,10 +643,6 @@ describe('fileDocumentHelper', () => { }); describe('showPartiesFiling', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(irsPractitionerUser); - }); - it('should set showPartiesFiling to false if IRS practitioner is filing first IRS document', () => { state.form = { generationType: GENERATION_TYPES.AUTO, @@ -583,7 +657,7 @@ describe('fileDocumentHelper', () => { }; const { showPartiesFiling } = runCompute(fileDocumentHelper, { - state, + state: { ...state, user: irsPractitionerUser }, }); expect(showPartiesFiling).toEqual(false); @@ -608,7 +682,7 @@ describe('fileDocumentHelper', () => { }; const { showPartiesFiling } = runCompute(fileDocumentHelper, { - state, + state: { ...state, user: docketClerkUser }, }); expect(showPartiesFiling).toEqual(true); @@ -617,10 +691,6 @@ describe('fileDocumentHelper', () => { describe('showPartiesFiling', () => { it('should set showPartiesFiling to true if private practitioner is filing a document', () => { - applicationContext.getCurrentUser.mockReturnValue( - privatePractitionerUser, - ); - state.form = { generationType: GENERATION_TYPES.AUTO, }; @@ -634,7 +704,7 @@ describe('fileDocumentHelper', () => { }; const { showPartiesFiling } = runCompute(fileDocumentHelper, { - state, + state: { ...state, user: privatePractitionerUser }, }); expect(showPartiesFiling).toEqual(true); diff --git a/web-client/src/presenter/computeds/fileDocumentHelper.ts b/web-client/src/presenter/computeds/fileDocumentHelper.ts index f81d9cd372a..1e4dfdd732b 100644 --- a/web-client/src/presenter/computeds/fileDocumentHelper.ts +++ b/web-client/src/presenter/computeds/fileDocumentHelper.ts @@ -87,7 +87,7 @@ export const fileDocumentHelper = ( const EARedactionAcknowledgement = form.generationType === GENERATION_TYPES.MANUAL && form.eventCode === 'EA'; - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const showGenerationTypeForm = showGenerationType( user, form.eventCode, From d4a05fe5bdb1f364af0b4e38ee5b1632207557f0 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 15:28:33 -0500 Subject: [PATCH 235/523] 10417: remove getCurrentUser from formattedTrialSessionDetails --- .../formattedTrialSessionDetails.test.ts | 29 +++++++++++++++++-- .../computeds/formattedTrialSessionDetails.ts | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts index a8b94eab28b..8e638492fd8 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts @@ -11,6 +11,7 @@ import { judgeUser, } from '../../../../shared/src/test/mockUsers'; import { formattedTrialSessionDetails as formattedTrialSessionDetailsComputed } from './formattedTrialSessionDetails'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -63,6 +64,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -77,6 +79,7 @@ describe('formattedTrialSessionDetails', () => { let result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -89,6 +92,7 @@ describe('formattedTrialSessionDetails', () => { result = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -120,6 +124,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -134,6 +139,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -146,6 +152,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -163,6 +170,7 @@ describe('formattedTrialSessionDetails', () => { isCalendared: false, startDate: PAST_DATE, }, + user: mockDocketClerkUser, }, }); expect(result).toMatchObject({ @@ -180,6 +188,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -198,6 +207,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -216,6 +226,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -234,6 +245,7 @@ describe('formattedTrialSessionDetails', () => { sessionStatus: SESSION_STATUS_GROUPS.open, startDate: PAST_DATE, }, + user: mockDocketClerkUser, }, }); expect(result).toMatchObject({ @@ -251,6 +263,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -271,6 +284,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -286,11 +300,10 @@ describe('formattedTrialSessionDetails', () => { startDate: FUTURE_DATE, }; - applicationContext.getCurrentUser.mockReturnValue(colvinsChambersUser); - const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: colvinsChambersUser, }, }); @@ -309,6 +322,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -330,6 +344,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -347,6 +362,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -364,6 +380,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); expect(result.canClose).toBe(false); @@ -380,6 +397,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -397,6 +415,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -414,6 +433,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, + user: mockDocketClerkUser, }, }); @@ -433,6 +453,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, + user: mockDocketClerkUser, }, }); @@ -454,6 +475,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, + user: mockDocketClerkUser, }, }); @@ -475,6 +497,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, + user: mockDocketClerkUser, }, }); @@ -494,6 +517,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, + user: mockDocketClerkUser, }, }); @@ -514,6 +538,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, + user: mockDocketClerkUser, }, }, ); diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts index c180ea278a0..8f9ec569885 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts @@ -86,7 +86,7 @@ export const formattedTrialSessionDetails = ( .getUtilities() .formatNow(DATE_FORMATS.YYYYMMDD); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const isChambersUser = user.role === USER_ROLES.chambers; const trialDateInFuture = trialDateFormatted > nowDateFormatted; From 294a2fbc48d57f9e84aca21dc28bc6fe8ebf7403 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 15:38:26 -0500 Subject: [PATCH 236/523] 10417 remove getCurrentUser from formattedTrialSessions --- .../computeds/formattedTrialSessions.test.ts | 58 +++++++++---------- .../computeds/formattedTrialSessions.ts | 2 +- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.test.ts b/web-client/src/presenter/computeds/formattedTrialSessions.test.ts index ac69abb0f98..0d3890e5af3 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessions.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessions.test.ts @@ -6,6 +6,10 @@ import { import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { formatTrialSessionDisplayOptions } from './addToTrialSessionModalHelper'; import { formattedTrialSessions as formattedTrialSessionsComputed } from './formattedTrialSessions'; +import { + mockJudgeUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; jest.mock('./addToTrialSessionModalHelper.ts'); @@ -20,7 +24,6 @@ const formattedTrialSessions = withAppContextDecorator( formattedTrialSessionsComputed, { ...applicationContext, - getCurrentUser: () => currentUser, }, ); @@ -29,12 +32,6 @@ const getStartOfWeek = date => { }; let nextYear; -let currentUser = {}; - -const testJudgeUser = { - role: ROLES.judge, - userId: '1', -}; const testTrialClerkUser = { role: ROLES.trialClerk, @@ -43,7 +40,7 @@ const testTrialClerkUser = { const baseState = { constants: { USER_ROLES: ROLES }, - judgeUser: testJudgeUser, + judgeUser: mockJudgeUser, }; let TRIAL_SESSIONS_LIST: any[] = []; @@ -54,12 +51,11 @@ describe('formattedTrialSessions', () => { }); beforeEach(() => { - currentUser = testJudgeUser; TRIAL_SESSIONS_LIST = [ { caseOrder: [], isCalendared: true, - judge: { name: '1', userId: '1' }, + judge: { name: mockJudgeUser.name, userId: mockJudgeUser.userId }, proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, sessionStatus: 'Open', sessionType: SESSION_TYPES.regular, @@ -177,6 +173,7 @@ describe('formattedTrialSessions', () => { state: { ...baseState, trialSessions: TRIAL_SESSIONS_LIST, + user: mockJudgeUser, }, }); } catch (err) { @@ -190,7 +187,7 @@ describe('formattedTrialSessions', () => { state: { ...baseState, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); @@ -208,9 +205,11 @@ describe('formattedTrialSessions', () => { const result = runCompute(formattedTrialSessions, { state: { ...baseState, - screenMetadata: { trialSessionFilters: { judge: { userId: '1' } } }, + screenMetadata: { + trialSessionFilters: { judge: { userId: mockJudgeUser.userId } }, + }, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); expect(result.formattedSessions.length).toBe(1); @@ -227,7 +226,7 @@ describe('formattedTrialSessions', () => { }, }, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); const flattenedSessions = result.formattedSessions.flatMap( @@ -242,7 +241,7 @@ describe('formattedTrialSessions', () => { ...baseState, screenMetadata: { trialSessionFilters: { judge: { userId: '' } } }, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); expect(result.formattedSessions.length).toBe(4); @@ -261,7 +260,7 @@ describe('formattedTrialSessions', () => { trialSessionFilters: { judge: { userId: 'unassigned' } }, }, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); @@ -278,7 +277,7 @@ describe('formattedTrialSessions', () => { ...baseState, form, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); expect(result.sessionsByTerm.length).toEqual(0); @@ -290,7 +289,7 @@ describe('formattedTrialSessions', () => { ...baseState, form, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); expect(result.sessionsByTerm.length).toEqual(1); @@ -302,7 +301,7 @@ describe('formattedTrialSessions', () => { ...baseState, form, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); expect(result.sessionsByTerm.length).toEqual(0); @@ -317,7 +316,7 @@ describe('formattedTrialSessions', () => { term: 'Winter', }, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); @@ -417,7 +416,7 @@ describe('formattedTrialSessions', () => { term: 'Winter', }, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); @@ -433,7 +432,7 @@ describe('formattedTrialSessions', () => { }, trialSession: { trialSessionId: TRIAL_SESSIONS_LIST[1].trialSessionId }, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); @@ -451,7 +450,7 @@ describe('formattedTrialSessions', () => { ...baseState, judgeUser: undefined, trialSessions: TRIAL_SESSIONS_LIST, - user: { role: ROLES.petitionsClerk, userId: '1' }, + user: mockPetitionsClerkUser, }, }); @@ -463,7 +462,7 @@ describe('formattedTrialSessions', () => { userIsAssignedToSession: false, }, { - judge: { name: '1', userId: '1' }, + judge: { name: mockJudgeUser.name, userId: mockJudgeUser.userId }, userIsAssignedToSession: false, }, { @@ -499,7 +498,7 @@ describe('formattedTrialSessions', () => { state: { ...baseState, trialSessions: TRIAL_SESSIONS_LIST, - user: testJudgeUser, + user: mockJudgeUser, }, }); expect(result.formattedSessions).toMatchObject([ @@ -511,7 +510,7 @@ describe('formattedTrialSessions', () => { userIsAssignedToSession: false, }, { - judge: { name: '1', userId: '1' }, + judge: { name: mockJudgeUser.name, userId: mockJudgeUser.userId }, userIsAssignedToSession: true, }, { @@ -577,13 +576,12 @@ describe('formattedTrialSessions', () => { }); it('sets userIsAssignedToSession true for sessions the current trial clerk user is assigned to', () => { - currentUser = testTrialClerkUser; - const result = runCompute(formattedTrialSessions, { state: { ...baseState, judgeUser: undefined, trialSessions: TRIAL_SESSIONS_LIST, + user: testTrialClerkUser, }, }); @@ -595,7 +593,7 @@ describe('formattedTrialSessions', () => { userIsAssignedToSession: false, }, { - judge: { name: '1', userId: '1' }, + judge: { name: mockJudgeUser.name, userId: mockJudgeUser.userId }, userIsAssignedToSession: false, }, { @@ -642,7 +640,7 @@ describe('formattedTrialSessions', () => { trialLocation: 'Jacksonville, FL', }, ], - user: { role: ROLES.petitionsClerk, userId: '1' }, + user: mockPetitionsClerkUser, }, }); expect(result.formattedSessions).toMatchObject([ diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.ts b/web-client/src/presenter/computeds/formattedTrialSessions.ts index 24834e754db..e33ec8d5669 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessions.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessions.ts @@ -184,7 +184,7 @@ export const formattedTrialSessions = ( ): any => { const judgeId = get(state.judgeUser.userId); const currentTrialSessionId = get(state.trialSession.trialSessionId); - const currentUser = applicationContext.getCurrentUser(); + const currentUser = get(state.user); const trialSessionFilters = pickBy( omit(get(state.screenMetadata.trialSessionFilters), 'status'), From 34aea21c05e4df365291652d8e531cd6b15df5c6 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 16:00:17 -0500 Subject: [PATCH 237/523] 10417 remove getCurrentUser from workQueueHelper --- .../computeds/workQueueHelper.test.ts | 182 ++++++------------ .../presenter/computeds/workQueueHelper.ts | 2 +- 2 files changed, 56 insertions(+), 128 deletions(-) diff --git a/web-client/src/presenter/computeds/workQueueHelper.test.ts b/web-client/src/presenter/computeds/workQueueHelper.test.ts index 9d2d4262682..1a3105eada7 100644 --- a/web-client/src/presenter/computeds/workQueueHelper.test.ts +++ b/web-client/src/presenter/computeds/workQueueHelper.test.ts @@ -1,24 +1,23 @@ -import { - DOCKET_SECTION, - ROLES, -} from '../../../../shared/src/business/entities/EntityConstants'; +import { DOCKET_SECTION } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../applicationContext'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; +import { + mockAdcUser, + mockCaseServicesSupervisorUser, + mockChambersUser, + mockDocketClerkUser, + mockJudgeUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../../src/withAppContext'; import { workQueueHelper as workQueueHelperComputed } from './workQueueHelper'; -let globalUser; - const workQueueHelper = withAppContextDecorator(workQueueHelperComputed, { ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, }); const getBaseState = user => { - globalUser = user; return { permissions: getUserPermissions(user), }; @@ -26,14 +25,11 @@ const getBaseState = user => { describe('workQueueHelper', () => { it('returns the expected state when selected work items are set', () => { - const user = { - role: ROLES.petitionsClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockPetitionsClerkUser), selectedWorkItems: [true], + user: mockPetitionsClerkUser, workQueueToDisplay: { box: 'inbox', queue: 'section' }, }, }); @@ -48,14 +44,11 @@ describe('workQueueHelper', () => { }); it('returns the expected state when selected work items are not set', () => { - const user = { - role: ROLES.petitionsClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockPetitionsClerkUser), selectedWorkItems: [], + user: mockPetitionsClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -70,14 +63,11 @@ describe('workQueueHelper', () => { }); it('returns My Document QC for workQueueTitle if showing individual non-internal work queue', () => { - const user = { - role: ROLES.petitionsClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockPetitionsClerkUser), selectedWorkItems: [], + user: mockPetitionsClerkUser, workQueueToDisplay: { queue: 'my', }, @@ -89,14 +79,11 @@ describe('workQueueHelper', () => { }); it('returns Document QC for workQueueTitle if showing section non-internal work queue and current user is not a docket or petitions clerk', () => { - const user = { - role: ROLES.adc, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockAdcUser), selectedWorkItems: [], + user: mockAdcUser, workQueueToDisplay: { queue: 'section', }, @@ -108,14 +95,11 @@ describe('workQueueHelper', () => { }); it('returns Section Document QC for workQueueTitle if showing section non-internal work queue and current user is a docket clerk', () => { - const user = { - role: ROLES.docketClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockDocketClerkUser), selectedWorkItems: [], + user: mockDocketClerkUser, workQueueToDisplay: { queue: 'section', }, @@ -127,15 +111,11 @@ describe('workQueueHelper', () => { }); it('should set workQueueTitle to a capitalized section specific title when the user is caseServicesSupervisor and workQueueToDisplay.section exists', () => { - const user = { - role: ROLES.caseServicesSupervisor, - userId: '117c6e9c-3940-4693-8bc8-0b2a7ed59b06', - }; - let result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockCaseServicesSupervisorUser), selectedWorkItems: [], + user: mockCaseServicesSupervisorUser, workQueueToDisplay: { queue: 'section', section: DOCKET_SECTION, @@ -147,15 +127,11 @@ describe('workQueueHelper', () => { }); it('should set workQueueTitle to "My Document QC" when the user is caseServicesSupervisor and workQueueToDisplay.section does not exist', () => { - const user = { - role: ROLES.caseServicesSupervisor, - userId: '117c6e9c-3940-4693-8bc8-0b2a7ed59b06', - }; - let result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockCaseServicesSupervisorUser), selectedWorkItems: [], + user: mockCaseServicesSupervisorUser, workQueueToDisplay: { queue: 'section', }, @@ -166,14 +142,11 @@ describe('workQueueHelper', () => { }); it('shows the start a case button when role is petitions clerk', () => { - const user = { - role: ROLES.petitionsClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockPetitionsClerkUser), selectedWorkItems: [], + user: mockPetitionsClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -183,14 +156,11 @@ describe('workQueueHelper', () => { }); it('does not show the start a case button when role is docket clerk', () => { - const user = { - role: ROLES.docketClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockDocketClerkUser), selectedWorkItems: [], + user: mockDocketClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -200,14 +170,11 @@ describe('workQueueHelper', () => { }); it('shows the case status column when role is judge', () => { - const user = { - role: ROLES.judge, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockJudgeUser), selectedWorkItems: [], + user: mockJudgeUser, workQueueToDisplay: { box: 'inbox', queue: 'my' }, }, }); @@ -215,14 +182,11 @@ describe('workQueueHelper', () => { }); it('shows the case status column when role is chambers', () => { - const user = { - role: ROLES.chambers, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockChambersUser), selectedWorkItems: [], + user: mockChambersUser, workQueueToDisplay: { box: 'inbox', queue: 'my' }, }, }); @@ -230,14 +194,11 @@ describe('workQueueHelper', () => { }); it('shows the from column when role is judge', () => { - const user = { - role: ROLES.judge, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockJudgeUser), selectedWorkItems: [], + user: mockJudgeUser, workQueueToDisplay: { box: 'inbox', queue: 'my' }, }, }); @@ -245,14 +206,11 @@ describe('workQueueHelper', () => { }); it('shows the from column when role is chambers', () => { - const user = { - role: ROLES.chambers, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockChambersUser), selectedWorkItems: [], + user: mockChambersUser, workQueueToDisplay: { box: 'inbox', queue: 'my' }, }, }); @@ -260,14 +218,11 @@ describe('workQueueHelper', () => { }); it('shows in progress petitions for a petitionsclerk', () => { - const user = { - role: ROLES.petitionsClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockPetitionsClerkUser), selectedWorkItems: [], + user: mockPetitionsClerkUser, workQueueToDisplay: { box: 'inProgress', queue: 'section', @@ -280,14 +235,11 @@ describe('workQueueHelper', () => { }); it('should return expected flags when user is the case services supervisor', () => { - const user = { - role: ROLES.caseServicesSupervisor, - userId: 'ed60ccc5-798c-4f9d-afed-f68f13f7c29b', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockCaseServicesSupervisorUser), selectedWorkItems: [], + user: mockCaseServicesSupervisorUser, workQueueToDisplay: { box: 'inProgress', queue: 'section', @@ -304,15 +256,12 @@ describe('workQueueHelper', () => { }); it('returns the individualInboxCount for the work queue based on the value of state.individualInboxCount', () => { - const user = { - role: ROLES.docketClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockDocketClerkUser), individualInboxCount: 3, selectedWorkItems: [], + user: mockDocketClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -320,15 +269,12 @@ describe('workQueueHelper', () => { }); it('returns the individualInProgressCount for the work queue based on the value of state.individualInProgressCount', () => { - const user = { - role: ROLES.docketClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockDocketClerkUser), individualInProgressCount: 10, selectedWorkItems: [], + user: mockDocketClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -336,15 +282,12 @@ describe('workQueueHelper', () => { }); it('returns the sectionInboxCount for the work queue based on the value of state.sectionInboxCount', () => { - const user = { - role: ROLES.docketClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockDocketClerkUser), sectionInboxCount: 3, selectedWorkItems: [], + user: mockDocketClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -352,15 +295,12 @@ describe('workQueueHelper', () => { }); it('returns the sectionInProgressCount for the work queue based on the value of state.sectionInProgressCount', () => { - const user = { - role: ROLES.docketClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockDocketClerkUser), sectionInProgressCount: 10, selectedWorkItems: [], + user: mockDocketClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -368,18 +308,15 @@ describe('workQueueHelper', () => { }); it('should return the correct document qc queue path URL based on the box and queue type provided', () => { - const user = { - role: ROLES.docketClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; const mockQueue = 'test'; const mockBox = 'my'; const result = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockDocketClerkUser), sectionInProgressCount: 10, selectedWorkItems: [], + user: mockDocketClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -390,19 +327,13 @@ describe('workQueueHelper', () => { }); describe('documentQCNavigationPath', () => { - let user; - beforeEach(() => { - user = { - role: ROLES.docketClerk, - userId: '9d7fd667-42a4-4bd0-9ec7-89d2673cf8b1', - }; - }); it('should construct a path based on the queue and box values passed in', () => { const { documentQCNavigationPath } = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockDocketClerkUser), sectionInProgressCount: 10, selectedWorkItems: [], + user: mockDocketClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -415,9 +346,10 @@ describe('workQueueHelper', () => { it('should construct a path based on the queue box, and section values when section is defined', () => { const { documentQCNavigationPath } = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockDocketClerkUser), sectionInProgressCount: 10, selectedWorkItems: [], + user: mockDocketClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my', @@ -436,16 +368,12 @@ describe('workQueueHelper', () => { }); it('showSwitchToMyDocQCLink should be false when the user is a case services supervisor', () => { - user = { - role: ROLES.caseServicesSupervisor, - userId: '117c6e9c-3940-4693-8bc8-0b2a7ed59b06', - }; - const { showSwitchToMyDocQCLink } = runCompute(workQueueHelper, { state: { - ...getBaseState(user), + ...getBaseState(mockCaseServicesSupervisorUser), sectionInProgressCount: 10, selectedWorkItems: [], + user: mockCaseServicesSupervisorUser, workQueueToDisplay: { box: 'outbox', queue: 'my', diff --git a/web-client/src/presenter/computeds/workQueueHelper.ts b/web-client/src/presenter/computeds/workQueueHelper.ts index d29e6bd65c8..b256aa4ad61 100644 --- a/web-client/src/presenter/computeds/workQueueHelper.ts +++ b/web-client/src/presenter/computeds/workQueueHelper.ts @@ -9,7 +9,7 @@ export const workQueueHelper = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const selectedWorkItems = get(state.selectedWorkItems); const workQueueToDisplay = get(state.workQueueToDisplay); const { USER_ROLES } = applicationContext.getConstants(); From ac46bba16000a585cfac7d18260c088c386445b8 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 16:03:28 -0500 Subject: [PATCH 238/523] 10417 Remove getCurrentUser from trialSessionsSummaryHelper --- .../trialSessionsSummaryHelper.test.ts | 30 +++++-------------- .../computeds/trialSessionsSummaryHelper.ts | 2 +- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.ts index 1421581c7d7..73bb54e0a77 100644 --- a/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.ts @@ -1,54 +1,40 @@ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; +import { mockChambersUser, mockJudgeUser } from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { trialSessionsSummaryHelper as trialSessionsSummaryHelperComputed } from './trialSessionsSummaryHelper'; import { withAppContextDecorator } from '../../withAppContext'; -let currentUser; - -const judgeId = '733777c2-cb31-44c6-afce-f7bc1a3f613b'; -const chambersId = 'a5ac202c-4e96-46f2-8968-2749ea845143'; - const trialSessionsSummaryHelper = withAppContextDecorator( trialSessionsSummaryHelperComputed, { getConstants: () => ({ USER_ROLES: ROLES, }), - getCurrentUser: () => currentUser, }, ); describe('trialSessionsSummaryHelper', () => { - beforeEach(() => { - currentUser = { - role: ROLES.judge, - userId: judgeId, - }; - }); - it('should return the judeUserId as the logged in user when that user is a judge', () => { const result = runCompute(trialSessionsSummaryHelper, { - state: {}, + state: { + user: mockJudgeUser, + }, }); - expect(result.judgeUserId).toEqual(judgeId); + expect(result.judgeUserId).toEqual(mockJudgeUser.userId); }); it('should return the judeUserId as the chambers judge associated with the logged in user', () => { - currentUser = { - role: ROLES.chambers, - userId: chambersId, - }; - const result = runCompute(trialSessionsSummaryHelper, { state: { judgeUser: { role: ROLES.judge, - userId: judgeId, + userId: mockJudgeUser.userId, }, + user: mockChambersUser, }, }); - expect(result.judgeUserId).toEqual(judgeId); + expect(result.judgeUserId).toEqual(mockJudgeUser.userId); }); }); diff --git a/web-client/src/presenter/computeds/trialSessionsSummaryHelper.ts b/web-client/src/presenter/computeds/trialSessionsSummaryHelper.ts index 9de16ce2954..fcc5ca8f46d 100644 --- a/web-client/src/presenter/computeds/trialSessionsSummaryHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsSummaryHelper.ts @@ -6,7 +6,7 @@ export const trialSessionsSummaryHelper = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const { role, userId } = applicationContext.getCurrentUser(); + const { role, userId } = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); const chambersJudgeUser = get(state.judgeUser); const isChambersUser = role === USER_ROLES.chambers; From 74deb2a54c4cbfd9bd26b988c467dccb34773c22 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Wed, 17 Jul 2024 14:08:40 -0700 Subject: [PATCH 239/523] 10417: making authorizedUser parameter in updateCaseAndAssociations optional until refactor complete --- .../caseAssociation/updateCaseAndAssociations.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts index bac9075cdf0..4830cab1322 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts @@ -447,9 +447,14 @@ export const updateCaseAndAssociations = async ({ caseToUpdate, }: { applicationContext: ServerApplicationContext; - authorizedUser: AuthUser; + // TODO 10417: making authorizedUser an optional property for now. Make required when when updateCaseAndAssociations references are refactored. + authorizedUser?: AuthUser; caseToUpdate: any; }): Promise => { + // TODO 10417: remove this if-block when updateCaseAndAssociations references are refactored + if (!authorizedUser) { + authorizedUser = applicationContext.getCurrentUser(); + } const caseEntity: Case = caseToUpdate.validate ? caseToUpdate : new Case(caseToUpdate, { From 9595b75f4424b3df05fb0026243ae5ce2d3f86dc Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 16:13:40 -0500 Subject: [PATCH 240/523] 10417 remove getCurrentUser from trialSessionHeaderHelper --- .../trialSessionHeaderHelper.test.ts | 76 ++++++++++--------- .../computeds/trialSessionHeaderHelper.ts | 2 +- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.ts b/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.ts index 56db35a9dde..abb07fa8dee 100644 --- a/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.ts @@ -1,7 +1,11 @@ import { MOCK_TRIAL_REGULAR } from '@shared/test/mockTrial'; import { TRIAL_SESSION_SCOPE_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; -import { judgeUser, trialClerkUser } from '@shared/test/mockUsers'; +import { + mockDocketClerkUser, + mockJudgeUser, + mockTrialClerkUser, +} from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { trialSessionHeaderHelper as trialSessionHeaderHelperComputed } from './trialSessionHeaderHelper'; import { withAppContextDecorator } from '../../withAppContext'; @@ -30,7 +34,9 @@ describe('trialSessionHeaderHelper', () => { }); it('should not throw an error when state.trialSession is undefined', () => { - expect(() => runCompute(trialSessionHeaderHelper, {} as any)).not.toThrow(); + expect(() => + runCompute(trialSessionHeaderHelper, { user: {} } as any), + ).not.toThrow(); }); describe('isStandaloneSession', () => { @@ -41,7 +47,7 @@ describe('trialSessionHeaderHelper', () => { }; const { isStandaloneSession } = runCompute(trialSessionHeaderHelper, { - state: baseState, + state: { ...baseState, user: mockDocketClerkUser }, }); expect(isStandaloneSession).toEqual(true); @@ -50,10 +56,8 @@ describe('trialSessionHeaderHelper', () => { describe('nameToDisplay', () => { it("should be the assigned judge's name when the current user is NOT a trial clerk", () => { - applicationContext.getCurrentUser.mockReturnValue(judgeUser); - const result = runCompute(trialSessionHeaderHelper, { - state: baseState, + state: { ...baseState, user: mockJudgeUser }, }); expect(result.nameToDisplay).toBe( @@ -62,13 +66,11 @@ describe('trialSessionHeaderHelper', () => { }); it("should be the current user's name when the current user is a trial clerk", () => { - applicationContext.getCurrentUser.mockReturnValue(trialClerkUser); - const result = runCompute(trialSessionHeaderHelper, { - state: baseState, + state: { ...baseState, user: mockTrialClerkUser }, }); - expect(result.nameToDisplay).toBe(trialClerkUser.name); + expect(result.nameToDisplay).toBe(mockTrialClerkUser.name); }); }); @@ -80,7 +82,7 @@ describe('trialSessionHeaderHelper', () => { }; const result = runCompute(trialSessionHeaderHelper, { - state: baseState, + state: { ...baseState, user: mockTrialClerkUser }, }); expect(result.showBatchDownloadButton).toBe(false); @@ -93,7 +95,7 @@ describe('trialSessionHeaderHelper', () => { }; const result = runCompute(trialSessionHeaderHelper, { - state: baseState, + state: { ...baseState, user: mockTrialClerkUser }, }); expect(result.showBatchDownloadButton).toBe(true); @@ -108,7 +110,7 @@ describe('trialSessionHeaderHelper', () => { }; const result = runCompute(trialSessionHeaderHelper, { - state: baseState, + state: { ...baseState, user: mockTrialClerkUser }, }); expect(result.showPrintCalendarButton).toBe(true); @@ -128,7 +130,11 @@ describe('trialSessionHeaderHelper', () => { }; const result = runCompute(trialSessionHeaderHelper, { - state: { ...baseState, permissions: { TRIAL_SESSIONS: true } }, + state: { + ...baseState, + permissions: { TRIAL_SESSIONS: true }, + user: mockTrialClerkUser, + }, }); expect(result.showPrintPaperServicePDFsButton).toBe(true); @@ -141,10 +147,11 @@ describe('trialSessionHeaderHelper', () => { state: { ...baseState, currentPage: 'TrialSessionWorkingCopy', - judgeUser: { userId: judgeUser.userId }, + judgeUser: { userId: mockJudgeUser.userId }, trialSession: { judge: { userId: 'NOT_ASSIGNED' }, }, + user: mockTrialClerkUser, }, }); @@ -152,8 +159,6 @@ describe('trialSessionHeaderHelper', () => { }); it('should be false when the user is a trial clerk, they are on the TrialSessionWorkingCopy screen, but they are not assigned to the trial session', () => { - applicationContext.getCurrentUser.mockReturnValue(trialClerkUser); - const result = runCompute(trialSessionHeaderHelper, { state: { ...baseState, @@ -161,6 +166,7 @@ describe('trialSessionHeaderHelper', () => { trialSession: { trialClerk: { userId: 'NOT_ASSIGNED' }, }, + user: mockTrialClerkUser, }, }); @@ -168,15 +174,14 @@ describe('trialSessionHeaderHelper', () => { }); it('should be false when the user is assigned to the session but they are already on the TrialSessionDetail screen', () => { - applicationContext.getCurrentUser.mockReturnValue(trialClerkUser); - const result = runCompute(trialSessionHeaderHelper, { state: { ...baseState, currentPage: 'TrialSessionDetail', trialSession: { - trialClerk: { userId: trialClerkUser.userId }, + trialClerk: { userId: mockTrialClerkUser.userId }, }, + user: mockTrialClerkUser, }, }); @@ -184,15 +189,14 @@ describe('trialSessionHeaderHelper', () => { }); it('should be true when the user is assigned to the session and they are on the TrialSessionWorkingCopy screen', () => { - applicationContext.getCurrentUser.mockReturnValue(trialClerkUser); - const result = runCompute(trialSessionHeaderHelper, { state: { ...baseState, currentPage: 'TrialSessionWorkingCopy', trialSession: { - trialClerk: { userId: trialClerkUser.userId }, + trialClerk: { userId: mockTrialClerkUser.userId }, }, + user: mockTrialClerkUser, }, }); @@ -204,10 +208,11 @@ describe('trialSessionHeaderHelper', () => { state: { ...baseState, currentPage: 'TrialSessionWorkingCopy', - judgeUser: { userId: judgeUser.userId }, + judgeUser: { userId: mockJudgeUser.userId }, trialSession: { - judge: { userId: judgeUser.userId }, + judge: { userId: mockJudgeUser.userId }, }, + user: mockTrialClerkUser, }, }); @@ -221,10 +226,11 @@ describe('trialSessionHeaderHelper', () => { state: { ...baseState, currentPage: 'TrialSessionDetail', - judgeUser: { userId: judgeUser.userId }, + judgeUser: { userId: mockJudgeUser.userId }, trialSession: { judge: { userId: 'NOT_ASSIGNED' }, }, + user: mockTrialClerkUser, }, }); @@ -232,8 +238,6 @@ describe('trialSessionHeaderHelper', () => { }); it('should be false when the user is a trial clerk, they are on the TrialSessionDetail screen, but they are not assigned to the trial session', () => { - applicationContext.getCurrentUser.mockReturnValue(trialClerkUser); - const result = runCompute(trialSessionHeaderHelper, { state: { ...baseState, @@ -241,6 +245,7 @@ describe('trialSessionHeaderHelper', () => { trialSession: { trialClerk: { userId: 'NOT_ASSIGNED' }, }, + user: mockTrialClerkUser, }, }); @@ -248,15 +253,14 @@ describe('trialSessionHeaderHelper', () => { }); it('should be false when the user is assigned to the session but they are already on the TrialSessionWorkingCopy screen', () => { - applicationContext.getCurrentUser.mockReturnValue(trialClerkUser); - const result = runCompute(trialSessionHeaderHelper, { state: { ...baseState, currentPage: 'TrialSessionWorkingCopy', trialSession: { - trialClerk: { userId: trialClerkUser.userId }, + trialClerk: { userId: mockTrialClerkUser.userId }, }, + user: mockTrialClerkUser, }, }); @@ -264,15 +268,14 @@ describe('trialSessionHeaderHelper', () => { }); it('should be true when the user is a trial clerk assigned to the session and they are on the TrialSessionDetail screen', () => { - applicationContext.getCurrentUser.mockReturnValue(trialClerkUser); - const result = runCompute(trialSessionHeaderHelper, { state: { ...baseState, currentPage: 'TrialSessionDetail', trialSession: { - trialClerk: { userId: trialClerkUser.userId }, + trialClerk: { userId: mockTrialClerkUser.userId }, }, + user: mockTrialClerkUser, }, }); @@ -284,10 +287,11 @@ describe('trialSessionHeaderHelper', () => { state: { ...baseState, currentPage: 'TrialSessionDetail', - judgeUser: { userId: judgeUser.userId }, + judgeUser: { userId: mockJudgeUser.userId }, trialSession: { - judge: { userId: judgeUser.userId }, + judge: { userId: mockJudgeUser.userId }, }, + user: mockTrialClerkUser, }, }); diff --git a/web-client/src/presenter/computeds/trialSessionHeaderHelper.ts b/web-client/src/presenter/computeds/trialSessionHeaderHelper.ts index fa3b14771ba..474ed3ad5df 100644 --- a/web-client/src/presenter/computeds/trialSessionHeaderHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionHeaderHelper.ts @@ -18,7 +18,7 @@ export const trialSessionHeaderHelper = ( } => { const { USER_ROLES } = applicationContext.getConstants(); - const currentUser = applicationContext.getCurrentUser(); + const currentUser = get(state.user); const trialSession = get(state.trialSession); const judgeUser = get(state.judgeUser); From df91633085d75ff1998d4bacda469b872173ea49 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 16:17:42 -0500 Subject: [PATCH 241/523] 10417 remove getCurrentUser from startCaseHelper --- .../computeds/startCaseHelper.test.ts | 35 +++++++++++++------ .../presenter/computeds/startCaseHelper.ts | 2 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/web-client/src/presenter/computeds/startCaseHelper.test.ts b/web-client/src/presenter/computeds/startCaseHelper.test.ts index f4f53c99013..407a5f69e02 100644 --- a/web-client/src/presenter/computeds/startCaseHelper.test.ts +++ b/web-client/src/presenter/computeds/startCaseHelper.test.ts @@ -5,6 +5,11 @@ import { } from '../../../../shared/src/business/entities/EntityConstants'; import { RawUser } from '@shared/business/entities/User'; import { applicationContext } from '../../applicationContext'; +import { + mockIrsPractitionerUser, + mockPetitionerUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { startCaseHelper as startCaseHelperComputed } from './startCaseHelper'; import { withAppContextDecorator } from '../../withAppContext'; @@ -28,6 +33,7 @@ describe('startCaseHelper', () => { const result = runCompute(startCaseHelper, { state: { form: {}, + user: mockPetitionerUser, }, }); expect(result.showPetitionFileValid).toBeFalsy(); @@ -37,6 +43,7 @@ describe('startCaseHelper', () => { const result = runCompute(startCaseHelper, { state: { form: { petitionFile: true }, + user: mockPetitionerUser, }, }); expect(result.showPetitionFileValid).toBeTruthy(); @@ -50,6 +57,7 @@ describe('startCaseHelper', () => { partyType: true, petitionFile: true, }, + user: mockPetitionerUser, }, }); expect(result.showCorporateDisclosure).toBeTruthy(); @@ -63,6 +71,7 @@ describe('startCaseHelper', () => { partyType: true, petitionFile: true, }, + user: mockPetitionerUser, }, }); expect(result.showCorporateDisclosure).toBeFalsy(); @@ -74,6 +83,7 @@ describe('startCaseHelper', () => { form: { hasIrsNotice: true, }, + user: mockPetitionerUser, }, }); expect(result.showHasIrsNoticeOptions).toBeTruthy(); @@ -86,6 +96,7 @@ describe('startCaseHelper', () => { form: { hasIrsNotice: false, }, + user: mockPetitionerUser, }, }); expect(result.showNotHasIrsNoticeOptions).toBeTruthy(); @@ -98,38 +109,31 @@ describe('startCaseHelper', () => { form: { hasIrsNotice: false, }, + user: mockPetitionerUser, }, }); expect(result.filingTypes).toEqual(FILING_TYPES.petitioner); }); it('returns privatePractitioner filing types if user is privatePractitioner role', () => { - applicationContext.getCurrentUser = () => - ({ - role: ROLES.privatePractitioner, - }) as RawUser; - const result = runCompute(startCaseHelper, { state: { form: { hasIrsNotice: false, }, + user: mockPrivatePractitionerUser, }, }); expect(result.filingTypes).toEqual(FILING_TYPES.privatePractitioner); }); it('returns petitioner filing types by default if user is not petitioner or privatePractitioner role', () => { - applicationContext.getCurrentUser = () => - ({ - role: ROLES.irsPractitioner, - }) as RawUser; - const result = runCompute(startCaseHelper, { state: { form: { hasIrsNotice: false, }, + user: mockIrsPractitionerUser, }, }); expect(result.filingTypes).toEqual(FILING_TYPES.petitioner); @@ -142,6 +146,7 @@ describe('startCaseHelper', () => { contactPrimary: { name: 'Michael G. Scott' }, partyType: PARTY_TYPES.petitioner, }, + user: mockPetitionerUser, }, }); @@ -156,6 +161,7 @@ describe('startCaseHelper', () => { contactSecondary: { name: 'Carol Stills' }, partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, + user: mockPetitionerUser, }, }); @@ -170,6 +176,7 @@ describe('startCaseHelper', () => { contactSecondary: { name: 'Carol Stills' }, partyType: PARTY_TYPES.petitionerSpouse, }, + user: mockPetitionerUser, }, }); @@ -184,6 +191,7 @@ describe('startCaseHelper', () => { contactSecondary: { name: 'Carol Stills' }, partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, + user: mockPetitionerUser, }, }); @@ -200,6 +208,7 @@ describe('startCaseHelper', () => { contactSecondary: { name: 'Carol Stills' }, partyType: PARTY_TYPES.petitionerSpouse, }, + user: mockPetitionerUser, }, }); @@ -215,6 +224,7 @@ describe('startCaseHelper', () => { contactPrimary: { name: '' }, partyType: PARTY_TYPES.trust, }, + user: mockPetitionerUser, }, }); @@ -228,6 +238,7 @@ describe('startCaseHelper', () => { contactPrimary: { name: '' }, partyType: PARTY_TYPES.trust, }, + user: mockPetitionerUser, }, }); @@ -241,6 +252,7 @@ describe('startCaseHelper', () => { contactPrimary: { name: '' }, partyType: PARTY_TYPES.trust, }, + user: mockPetitionerUser, }, }); @@ -302,6 +314,7 @@ describe('startCaseHelper', () => { form: { caseType: 'Disclosure1', }, + user: mockPetitionerUser, }, }); @@ -314,6 +327,7 @@ describe('startCaseHelper', () => { form: { caseType: 'Disclosure2', }, + user: mockPetitionerUser, }, }); @@ -326,6 +340,7 @@ describe('startCaseHelper', () => { form: { caseType: CASE_TYPES_MAP.deficiency, }, + user: mockPetitionerUser, }, }); diff --git a/web-client/src/presenter/computeds/startCaseHelper.ts b/web-client/src/presenter/computeds/startCaseHelper.ts index 081b061d10a..86c87e60737 100644 --- a/web-client/src/presenter/computeds/startCaseHelper.ts +++ b/web-client/src/presenter/computeds/startCaseHelper.ts @@ -16,7 +16,7 @@ export const startCaseHelper = ( USER_ROLES, } = applicationContext.getConstants(); const form = get(state.form); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const showContacts = showContactsHelper(form.partyType, PARTY_TYPES); From 2b29f8ef2474b630bbf0fecc14a3e06d6c887c58 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 16:30:10 -0500 Subject: [PATCH 242/523] 10417 remove getCurrentUser from scanHelper --- .../presenter/computeds/scanHelper.test.ts | 79 +++++++++++-------- .../src/presenter/computeds/scanHelper.ts | 2 +- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/web-client/src/presenter/computeds/scanHelper.test.ts b/web-client/src/presenter/computeds/scanHelper.test.ts index 8c923f7a54d..bc6c9444519 100644 --- a/web-client/src/presenter/computeds/scanHelper.test.ts +++ b/web-client/src/presenter/computeds/scanHelper.test.ts @@ -1,8 +1,13 @@ -import { - INITIAL_DOCUMENT_TYPES, - ROLES, -} from '../../../../shared/src/business/entities/EntityConstants'; +import { INITIAL_DOCUMENT_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { + mockAdcUser, + mockDocketClerkUser, + mockIrsPractitionerUser, + mockPetitionerUser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { scanHelper as scanHelperComputed } from './scanHelper'; import { withAppContextDecorator } from '../../../src/withAppContext'; @@ -20,72 +25,51 @@ describe('scanHelper', () => { ); it('sets hasScanFeature to true for petitionsclerk user roles', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.petitionsClerk, - }); - const result = runCompute(scanHelper, { - state: stateWithEmptyFormDocuments, + state: { ...stateWithEmptyFormDocuments, user: mockPetitionsClerkUser }, }); expect(result.hasScanFeature).toEqual(true); }); it('sets hasScanFeature to true for docketclerk user roles', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.docketClerk, - }); - const result = runCompute(scanHelper, { - state: stateWithEmptyFormDocuments, + state: { ...stateWithEmptyFormDocuments, user: mockDocketClerkUser }, }); expect(result.hasScanFeature).toEqual(true); }); it('sets hasScanFeature to true for adc user roles', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.adc, - }); - const result = runCompute(scanHelper, { - state: stateWithEmptyFormDocuments, + state: { ...stateWithEmptyFormDocuments, user: mockAdcUser }, }); expect(result.hasScanFeature).toEqual(true); }); it('sets hasScanFeature to false for petitioner user roles', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.petitioner, - }); - const result = runCompute(scanHelper, { - state: stateWithEmptyFormDocuments, + state: { ...stateWithEmptyFormDocuments, user: mockPetitionerUser }, }); expect(result.hasScanFeature).toEqual(false); }); it('sets hasScanFeature to false for practitioner user roles', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.privatePractitioner, - }); - const result = runCompute(scanHelper, { - state: stateWithEmptyFormDocuments, + state: { + ...stateWithEmptyFormDocuments, + user: mockPrivatePractitionerUser, + }, }); expect(result.hasScanFeature).toEqual(false); }); it('sets hasScanFeature to false for respondent user roles', () => { - applicationContext.getCurrentUser = () => ({ - role: ROLES.irsPractitioner, - }); - const result = runCompute(scanHelper, { - state: stateWithEmptyFormDocuments, + state: { ...stateWithEmptyFormDocuments, user: mockIrsPractitionerUser }, }); expect(result.hasScanFeature).toEqual(false); @@ -98,6 +82,7 @@ describe('scanHelper', () => { modal: { showModal: 'SelectScannerSourceModal', }, + user: mockPetitionerUser, }, }); expect(result.showScannerSourceModal).toEqual(true); @@ -111,6 +96,7 @@ describe('scanHelper', () => { scanner: { sources: mockSources, }, + user: mockPetitionerUser, }, }); expect(result.sources.length).toEqual(2); @@ -123,6 +109,7 @@ describe('scanHelper', () => { form: { stinFile: {}, }, + user: mockPetitionerUser, }, }); @@ -136,6 +123,7 @@ describe('scanHelper', () => { docketEntries: [], stinFile: {}, }, + user: mockPetitionerUser, }, }); @@ -149,6 +137,7 @@ describe('scanHelper', () => { docketEntries: [], stinFile: null, }, + user: mockPetitionerUser, }, }); expect(result.STINFileCompleted).toEqual(false); @@ -164,6 +153,7 @@ describe('scanHelper', () => { }, ], }, + user: mockPetitionerUser, }, }); @@ -176,6 +166,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, + user: mockPetitionerUser, }, }); @@ -191,6 +182,7 @@ describe('scanHelper', () => { docketEntries: [], requestForPlaceOfTrialFile: {}, }, + user: mockPetitionerUser, }, }); @@ -204,6 +196,7 @@ describe('scanHelper', () => { docketEntries: [], requestForPlaceOfTrialFile: null, }, + user: mockPetitionerUser, }, }); expect(result.RQTFileCompleted).toEqual(false); @@ -220,6 +213,7 @@ describe('scanHelper', () => { }, ], }, + user: mockPetitionerUser, }, }); @@ -232,6 +226,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, + user: mockPetitionerUser, }, }); @@ -247,6 +242,7 @@ describe('scanHelper', () => { applicationForWaiverOfFilingFeeFile: {}, docketEntries: [], }, + user: mockPetitionerUser, }, }); @@ -260,6 +256,7 @@ describe('scanHelper', () => { applicationForWaiverOfFilingFeeFile: null, docketEntries: [], }, + user: mockPetitionerUser, }, }); expect(result.APWFileCompleted).toEqual(false); @@ -277,6 +274,7 @@ describe('scanHelper', () => { }, ], }, + user: mockPetitionerUser, }, }); @@ -289,6 +287,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, + user: mockPetitionerUser, }, }); @@ -304,6 +303,7 @@ describe('scanHelper', () => { docketEntries: [], petitionFile: {}, }, + user: mockPetitionerUser, }, }); @@ -317,6 +317,7 @@ describe('scanHelper', () => { docketEntries: [], petitionFileCompleted: null, }, + user: mockPetitionerUser, }, }); expect(result.PFileCompleted).toEqual(false); @@ -332,6 +333,7 @@ describe('scanHelper', () => { }, ], }, + user: mockPetitionerUser, }, }); @@ -344,6 +346,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, + user: mockPetitionerUser, }, }); @@ -359,6 +362,7 @@ describe('scanHelper', () => { corporateDisclosureFile: {}, docketEntries: [], }, + user: mockPetitionerUser, }, }); @@ -372,6 +376,7 @@ describe('scanHelper', () => { corporateDisclosureFile: null, docketEntries: [], }, + user: mockPetitionerUser, }, }); expect(result.DISCFileCompleted).toEqual(false); @@ -387,6 +392,7 @@ describe('scanHelper', () => { }, ], }, + user: mockPetitionerUser, }, }); @@ -399,6 +405,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, + user: mockPetitionerUser, }, }); @@ -414,6 +421,7 @@ describe('scanHelper', () => { attachmentToPetitionFile: {}, docketEntries: [], }, + user: mockPetitionerUser, }, }); @@ -427,6 +435,7 @@ describe('scanHelper', () => { attachmentToPetitionFile: null, docketEntries: [], }, + user: mockPetitionerUser, }, }); expect(result.ATPFileCompleted).toEqual(false); @@ -443,6 +452,7 @@ describe('scanHelper', () => { }, ], }, + user: mockPetitionerUser, }, }); @@ -455,6 +465,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, + user: mockPetitionerUser, }, }); diff --git a/web-client/src/presenter/computeds/scanHelper.ts b/web-client/src/presenter/computeds/scanHelper.ts index 294c49bb94c..e248ab0b9ed 100644 --- a/web-client/src/presenter/computeds/scanHelper.ts +++ b/web-client/src/presenter/computeds/scanHelper.ts @@ -16,7 +16,7 @@ export const scanHelper = ( const { INITIAL_DOCUMENT_TYPES, SCAN_MODES } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const formCaseDocuments = get(state.form.docketEntries); const initiateScriptLoaded = get(state.scanner.initiateScriptLoaded); const configScriptLoaded = get(state.scanner.configScriptLoaded); From 02ef9060310f7379ebcde17b67d59186f5c2e2c8 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 16:34:33 -0500 Subject: [PATCH 243/523] 10417 remove getCurrentUser from partiesInformationHelper --- .../computeds/partiesInformationHelper.test.ts | 12 ++++-------- .../presenter/computeds/partiesInformationHelper.ts | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/web-client/src/presenter/computeds/partiesInformationHelper.test.ts b/web-client/src/presenter/computeds/partiesInformationHelper.test.ts index 5f1317d3b19..d8c98c51ced 100644 --- a/web-client/src/presenter/computeds/partiesInformationHelper.test.ts +++ b/web-client/src/presenter/computeds/partiesInformationHelper.test.ts @@ -26,10 +26,6 @@ describe('partiesInformationHelper', () => { contactId: '25d51a3b-969e-4bb4-a932-cc9645ba888c', contactType: CONTACT_TYPES.participant, }; - let mockPetitioner; - let mockPrivatePractitioner; - let mockIrsPractitioner; - let mockUser; const partiesInformationHelper = withAppContextDecorator( partiesInformationHelperComputed, @@ -37,8 +33,6 @@ describe('partiesInformationHelper', () => { ); const getBaseState = user => { - mockUser = { ...user }; - return { featureFlags: { [ALLOWLIST_FEATURE_FLAGS.E_CONSENT_FIELDS_ENABLED_FEATURE_FLAG.key]: @@ -46,11 +40,14 @@ describe('partiesInformationHelper', () => { }, permissions: getUserPermissions(user), screenMetadata: { pendingEmails: {} }, + user, }; }; + let mockPrivatePractitioner; + let mockIrsPractitioner; + let mockPetitioner; beforeEach(() => { - mockUser = {}; mockIrsPractitioner = { barNumber: 'RT1111', email: mockEmail, @@ -72,7 +69,6 @@ describe('partiesInformationHelper', () => { role: ROLES.privatePractitioner, userId: '39f7c7ee-ab75-492a-a4ee-63755a24e845', }; - applicationContext.getCurrentUser.mockImplementation(() => mockUser); }); describe('formattedParticipants', () => { diff --git a/web-client/src/presenter/computeds/partiesInformationHelper.ts b/web-client/src/presenter/computeds/partiesInformationHelper.ts index 31584598ec0..97899e53b9b 100644 --- a/web-client/src/presenter/computeds/partiesInformationHelper.ts +++ b/web-client/src/presenter/computeds/partiesInformationHelper.ts @@ -63,7 +63,7 @@ export const partiesInformationHelper = ( const caseDetail = get(state.caseDetail); const screenMetadata = get(state.screenMetadata); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const permissions = get(state.permissions); const isExternalUser = applicationContext .getUtilities() From 8a6ae21bbc4886730f7c3e5710109f98ce247c4e Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 16:39:10 -0500 Subject: [PATCH 244/523] 10417 remove getCurrentUser from orderTypesHelper --- .../src/presenter/computeds/orderTypesHelper.test.ts | 11 +++++------ .../src/presenter/computeds/orderTypesHelper.ts | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/web-client/src/presenter/computeds/orderTypesHelper.test.ts b/web-client/src/presenter/computeds/orderTypesHelper.test.ts index d3240b15445..c9a69d412da 100644 --- a/web-client/src/presenter/computeds/orderTypesHelper.test.ts +++ b/web-client/src/presenter/computeds/orderTypesHelper.test.ts @@ -28,11 +28,10 @@ describe('orderTypesHelper', () => { }, }; }, - getCurrentUser: () => user, }); it('should return all event codes for docketclerk', () => { - const result = runCompute(orderTypesHelper, { state: {} }); + const result = runCompute(orderTypesHelper, { state: { user } }); expect(result.orderTypes).toEqual([ { code: 'Simba', documentType: 'Lion', eventCode: 'ROAR' }, @@ -44,7 +43,7 @@ describe('orderTypesHelper', () => { it('should filter out and only return type O for petitionsclerk', () => { user = petitionsClerkUser; - const result = runCompute(orderTypesHelper, { state: {} }); + const result = runCompute(orderTypesHelper, { state: { user } }); expect(result.orderTypes).toEqual([ { @@ -57,7 +56,7 @@ describe('orderTypesHelper', () => { it('should return showDocumentTitleInput true and documentTitleInputLabel if state.modal.eventCode is O', () => { const result = runCompute(orderTypesHelper, { - state: { modal: { eventCode: 'O' } }, + state: { modal: { eventCode: 'O' }, user }, }); expect(result.showDocumentTitleInput).toEqual(true); @@ -66,7 +65,7 @@ describe('orderTypesHelper', () => { it('should return showDocumentTitleInput true and documentTitleInputLabel if state.modal.eventCode is NOT', () => { const result = runCompute(orderTypesHelper, { - state: { modal: { eventCode: 'NOT' } }, + state: { modal: { eventCode: 'NOT' }, user }, }); expect(result.showDocumentTitleInput).toEqual(true); @@ -75,7 +74,7 @@ describe('orderTypesHelper', () => { it('should return showDocumentTitleInput false if state.modal.eventCode is not O or NOT', () => { const result = runCompute(orderTypesHelper, { - state: { modal: { eventCode: 'OTHER' } }, + state: { modal: { eventCode: 'OTHER' }, user }, }); expect(result.showDocumentTitleInput).toEqual(false); diff --git a/web-client/src/presenter/computeds/orderTypesHelper.ts b/web-client/src/presenter/computeds/orderTypesHelper.ts index 8e217666701..3f79178ae86 100644 --- a/web-client/src/presenter/computeds/orderTypesHelper.ts +++ b/web-client/src/presenter/computeds/orderTypesHelper.ts @@ -7,7 +7,7 @@ export const orderTypesHelper = ( applicationContext: ClientApplicationContext, ): any => { const { ORDER_TYPES_MAP, USER_ROLES } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const eventCode = get(state.modal.eventCode); let orderTypes = ORDER_TYPES_MAP; From 5ffb651cf77f5868f3717dff7f0566f81525d19d Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 16:42:23 -0500 Subject: [PATCH 245/523] 10417 remove getCurrentUser from messagesHelper --- .../computeds/messagesHelper.test.ts | 28 +++++++++++++++---- .../src/presenter/computeds/messagesHelper.ts | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/web-client/src/presenter/computeds/messagesHelper.test.ts b/web-client/src/presenter/computeds/messagesHelper.test.ts index d24bf64d083..c6cb08e7aa8 100644 --- a/web-client/src/presenter/computeds/messagesHelper.test.ts +++ b/web-client/src/presenter/computeds/messagesHelper.test.ts @@ -11,12 +11,10 @@ import { withAppContextDecorator } from '../../withAppContext'; describe('messagesHelper', () => { let user; - const messagesHelper = withAppContextDecorator(messagesHelperComputed, { - ...applicationContext, - getCurrentUser: () => { - return user; - }, - }); + const messagesHelper = withAppContextDecorator( + messagesHelperComputed, + applicationContext, + ); beforeEach(() => { user = docketClerkUser; @@ -28,6 +26,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'my', }, + user, }, }); expect(result.showIndividualMessages).toBeTruthy(); @@ -40,6 +39,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'section', }, + user, }, }); expect(result.showIndividualMessages).toBeFalsy(); @@ -52,6 +52,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'my', }, + user, }, }); @@ -62,6 +63,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'section', }, + user, }, }); @@ -75,6 +77,7 @@ describe('messagesHelper', () => { queue: 'section', section: DOCKET_SECTION, }, + user, }, }); @@ -90,6 +93,7 @@ describe('messagesHelper', () => { }, messagesInboxCount: 5, messagesSectionCount: 3, + user, }, }); @@ -104,6 +108,7 @@ describe('messagesHelper', () => { }, messagesInboxCount: 5, messagesSectionCount: 3, + user, }, }); @@ -119,6 +124,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'section', }, + user, }, }); @@ -133,6 +139,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'section', }, + user, }, }); @@ -147,6 +154,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'my', }, + user, }, }); @@ -161,6 +169,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'section', }, + user, }, }); @@ -175,6 +184,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'my', }, + user, }, }); @@ -190,6 +200,7 @@ describe('messagesHelper', () => { queue: 'my', section: DOCKET_SECTION, }, + user, }, }); @@ -204,6 +215,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'my', }, + user, }, }); @@ -219,6 +231,7 @@ describe('messagesHelper', () => { queue: 'my', section: DOCKET_SECTION, }, + user, }, }); @@ -233,6 +246,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'my', }, + user, }, }); @@ -246,6 +260,7 @@ describe('messagesHelper', () => { messageBoxToDisplay: { queue: 'my', }, + user, }, }); @@ -261,6 +276,7 @@ describe('messagesHelper', () => { queue: 'my', section: DOCKET_SECTION, }, + user, }, }); diff --git a/web-client/src/presenter/computeds/messagesHelper.ts b/web-client/src/presenter/computeds/messagesHelper.ts index 039e79ff7b9..52eb074e0b2 100644 --- a/web-client/src/presenter/computeds/messagesHelper.ts +++ b/web-client/src/presenter/computeds/messagesHelper.ts @@ -7,7 +7,7 @@ export const messagesHelper = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { USER_ROLES } = applicationContext.getConstants(); const userRole = user && user.role; const isCaseServicesSupervisor = From 9e4ed967cdf608af72eebbe2dedd1a60922a4144 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 17 Jul 2024 16:45:38 -0500 Subject: [PATCH 246/523] 10417 remove getCurrentUser from internalPetitionPartiesHelper --- .../internalPetitionPartiesHelper.test.ts | 38 +++++++++++++------ .../internalPetitionPartiesHelper.ts | 2 +- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/web-client/src/presenter/computeds/internalPetitionPartiesHelper.test.ts b/web-client/src/presenter/computeds/internalPetitionPartiesHelper.test.ts index 3860af1c430..8578f408679 100644 --- a/web-client/src/presenter/computeds/internalPetitionPartiesHelper.test.ts +++ b/web-client/src/presenter/computeds/internalPetitionPartiesHelper.test.ts @@ -3,11 +3,12 @@ import { PARTY_TYPES, } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; -import { internalPetitionPartiesHelper as internalPetitionPartiesHelperComputed } from './internalPetitionPartiesHelper'; import { + docketClerk1User, petitionerUser, petitionsClerkUser, } from '../../../../shared/src/test/mockUsers'; +import { internalPetitionPartiesHelper as internalPetitionPartiesHelperComputed } from './internalPetitionPartiesHelper'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -24,6 +25,7 @@ describe('internalPetitionPartiesHelper', () => { PARTY_TYPES, }, form: { partyType: PARTY_TYPES.conservator }, + user: docketClerk1User, }, }); @@ -44,6 +46,7 @@ describe('internalPetitionPartiesHelper', () => { PARTY_TYPES, }, form: { partyType: PARTY_TYPES.corporation }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -62,6 +65,7 @@ describe('internalPetitionPartiesHelper', () => { PARTY_TYPES, }, form: { partyType: PARTY_TYPES.custodian }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -81,6 +85,7 @@ describe('internalPetitionPartiesHelper', () => { PARTY_TYPES, }, form: { partyType: PARTY_TYPES.donor }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -100,6 +105,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.estate, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -122,6 +128,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.estateWithoutExecutor, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -142,6 +149,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.guardian, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -163,6 +171,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.nextFriendForIncompetentPerson, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -184,6 +193,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.nextFriendForMinor, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -205,6 +215,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.partnershipBBA, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -226,6 +237,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.partnershipOtherThanTaxMatters, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -247,6 +259,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -268,6 +281,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.petitioner, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -287,6 +301,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.petitionerSpouse, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -312,6 +327,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -335,6 +351,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.survivingSpouse, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -356,6 +373,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.transferee, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -375,6 +393,7 @@ describe('internalPetitionPartiesHelper', () => { form: { partyType: PARTY_TYPES.trust, }, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -397,27 +416,25 @@ describe('internalPetitionPartiesHelper', () => { isPaper: undefined, partyType: PARTY_TYPES.partnershipAsTaxMattersPartner, }, + user: docketClerk1User, }; it('should be false when the current user is an external user', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - const result = runCompute(internalPetitionPartiesHelper, { - state: baseState, + state: { ...baseState, user: petitionerUser }, }); expect(result.showPaperPetitionEmailFieldAndConsentBox).toEqual(false); }); it('should be true when the current user is a petitions clerk user', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - const result = runCompute(internalPetitionPartiesHelper, { state: { ...baseState, form: { isPaper: true, }, + user: petitionsClerkUser, }, }); @@ -425,8 +442,6 @@ describe('internalPetitionPartiesHelper', () => { }); it('should be false when the e-consent feature flag is disabled', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - const result = runCompute(internalPetitionPartiesHelper, { state: { ...baseState, @@ -434,6 +449,7 @@ describe('internalPetitionPartiesHelper', () => { [ALLOWLIST_FEATURE_FLAGS.E_CONSENT_FIELDS_ENABLED_FEATURE_FLAG.key]: false, }, + user: petitionsClerkUser, }, }); @@ -441,8 +457,6 @@ describe('internalPetitionPartiesHelper', () => { }); it('should be true when the e-consent feature flag is enabled, it is a paper petition and the current user is internal', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - const result = runCompute(internalPetitionPartiesHelper, { state: { ...baseState, @@ -453,6 +467,7 @@ describe('internalPetitionPartiesHelper', () => { form: { isPaper: true, }, + user: petitionsClerkUser, }, }); @@ -460,8 +475,6 @@ describe('internalPetitionPartiesHelper', () => { }); it('should be false when the e-consent feature flag is enabled, and it is NOT a paper petition', () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - const result = runCompute(internalPetitionPartiesHelper, { state: { ...baseState, @@ -472,6 +485,7 @@ describe('internalPetitionPartiesHelper', () => { form: { isPaper: false, }, + user: petitionsClerkUser, }, }); diff --git a/web-client/src/presenter/computeds/internalPetitionPartiesHelper.ts b/web-client/src/presenter/computeds/internalPetitionPartiesHelper.ts index fd8a7448de8..422b65e1127 100644 --- a/web-client/src/presenter/computeds/internalPetitionPartiesHelper.ts +++ b/web-client/src/presenter/computeds/internalPetitionPartiesHelper.ts @@ -211,7 +211,7 @@ export const internalPetitionPartiesHelper = ( ): any => { const { ALLOWLIST_FEATURE_FLAGS, PARTY_TYPES } = applicationContext.getConstants(); - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { isPaper, partyType } = get(state.form); const E_CONSENT_FIELDS_ENABLED_FEATURE_FLAG = get( From 856e9070b41bb7fd68a7dd9ffb1ddcc6673023df Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Wed, 17 Jul 2024 14:49:48 -0700 Subject: [PATCH 247/523] 10417: remove appcontext.getCurrentUser from updateOtherStatisticsInteractor --- .../updateOtherStatisticsInteractor.test.ts | 66 ++++++++++++------- .../updateOtherStatisticsInteractor.ts | 12 ++-- .../cases/updateOtherStatisticsLambda.ts | 18 +++-- 3 files changed, 60 insertions(+), 36 deletions(-) diff --git a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.ts b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.ts index e215fb1b2f9..c0793fec635 100644 --- a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.ts +++ b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.ts @@ -1,12 +1,14 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { updateOtherStatisticsInteractor } from './updateOtherStatisticsInteractor'; describe('updateOtherStatisticsInteractor', () => { let mockLock; + let authorizedUser: UnknownAuthUser; beforeAll(() => { applicationContext @@ -16,10 +18,11 @@ describe('updateOtherStatisticsInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); + // applicationContext.getCurrentUser.mockReturnValue({ + // role: ROLES.docketClerk, + // userId: 'docketClerk', + // }); + authorizedUser = mockDocketClerkUser; applicationContext .getPersistenceGateway() @@ -27,21 +30,28 @@ describe('updateOtherStatisticsInteractor', () => { }); it('should throw an error if the user is unauthorized to update case statistics', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); + // applicationContext.getCurrentUser.mockReturnValue({}); + authorizedUser = {} as UnknownAuthUser; await expect( - updateOtherStatisticsInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - } as any), + updateOtherStatisticsInteractor( + applicationContext, + { docketNumber: MOCK_CASE.docketNumber } as any, + authorizedUser, + ), ).rejects.toThrow('Unauthorized for editing statistics'); }); it('should call updateCase with the updated case statistics and return the updated case', async () => { - const result = await updateOtherStatisticsInteractor(applicationContext, { - damages: 1234, - docketNumber: MOCK_CASE.docketNumber, - litigationCosts: 5678, - }); + const result = await updateOtherStatisticsInteractor( + applicationContext, + { + damages: 1234, + docketNumber: MOCK_CASE.docketNumber, + litigationCosts: 5678, + }, + authorizedUser, + ); expect(result).toMatchObject({ damages: 1234, litigationCosts: 5678, @@ -51,11 +61,15 @@ describe('updateOtherStatisticsInteractor', () => { mockLock = MOCK_LOCK; await expect( - updateOtherStatisticsInteractor(applicationContext, { - damages: 1234, - docketNumber: MOCK_CASE.docketNumber, - litigationCosts: 5678, - }), + updateOtherStatisticsInteractor( + applicationContext, + { + damages: 1234, + docketNumber: MOCK_CASE.docketNumber, + litigationCosts: 5678, + }, + authorizedUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -64,11 +78,15 @@ describe('updateOtherStatisticsInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await updateOtherStatisticsInteractor(applicationContext, { - damages: 1234, - docketNumber: MOCK_CASE.docketNumber, - litigationCosts: 5678, - }); + await updateOtherStatisticsInteractor( + applicationContext, + { + damages: 1234, + docketNumber: MOCK_CASE.docketNumber, + litigationCosts: 5678, + }, + authorizedUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts index 55bda9e9311..327105621db 100644 --- a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -24,10 +25,9 @@ export const updateOtherStatistics = async ( docketNumber, litigationCosts, }: { damages: number; docketNumber: string; litigationCosts: number }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS)) { throw new UnauthorizedError('Unauthorized for editing statistics'); } @@ -37,7 +37,7 @@ export const updateOtherStatistics = async ( const newCase = new Case( { ...oldCase, damages, litigationCosts }, - { authorizedUser: user }, + { authorizedUser }, ); const updatedCase = await applicationContext @@ -47,9 +47,7 @@ export const updateOtherStatistics = async ( caseToUpdate: newCase, }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const updateOtherStatisticsInteractor = withLocking( diff --git a/web-api/src/lambdas/cases/updateOtherStatisticsLambda.ts b/web-api/src/lambdas/cases/updateOtherStatisticsLambda.ts index 2ddbea932c3..23ff55b6e98 100644 --- a/web-api/src/lambdas/cases/updateOtherStatisticsLambda.ts +++ b/web-api/src/lambdas/cases/updateOtherStatisticsLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +7,19 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateOtherStatisticsLambda = event => +export const updateOtherStatisticsLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .updateOtherStatisticsInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); + .updateOtherStatisticsInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); From aee9cf026525e631cbda5bf97c0ac353df41d435 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Wed, 17 Jul 2024 15:23:49 -0700 Subject: [PATCH 248/523] 10417: remove appcontext.getCurrentUser from updateCaseWorksheetInteractor --- .../updateCaseWorksheetInteractor.test.ts | 68 +++++++++++-------- .../updateCaseWorksheetInteractor.ts | 8 +-- .../updateCaseWorksheetLambda.ts | 7 +- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/web-api/src/business/useCases/caseWorksheet/updateCaseWorksheetInteractor.test.ts b/web-api/src/business/useCases/caseWorksheet/updateCaseWorksheetInteractor.test.ts index 30822f5a027..c177ffd3625 100644 --- a/web-api/src/business/useCases/caseWorksheet/updateCaseWorksheetInteractor.test.ts +++ b/web-api/src/business/useCases/caseWorksheet/updateCaseWorksheetInteractor.test.ts @@ -1,11 +1,12 @@ import { InvalidEntityError, UnauthorizedError } from '@web-api/errors/errors'; import { RawCaseWorksheet } from '@shared/business/entities/caseWorksheet/CaseWorksheet'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { judgeColvin } from '@shared/test/mockUsers'; import { - colvinsChambersUser, - judgeColvin, - petitionsClerkUser, -} from '@shared/test/mockUsers'; + mockChambersUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { updateCaseWorksheetInteractor } from './updateCaseWorksheetInteractor'; describe('updateCaseWorksheetInteractor', () => { @@ -22,34 +23,38 @@ describe('updateCaseWorksheetInteractor', () => { }); it('should throw an error when the user does not have access to the case worksheet feature', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); // Only judges and judges chambers have access to case worksheets - await expect( - updateCaseWorksheetInteractor(applicationContext, { - worksheet: mockCaseWorksheet, - }), + updateCaseWorksheetInteractor( + applicationContext, + { + worksheet: mockCaseWorksheet, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should throw an error when the updated case worksheet is invalid', async () => { - applicationContext.getCurrentUser.mockReturnValue(judgeColvin); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(judgeColvin); await expect( - updateCaseWorksheetInteractor(applicationContext, { - worksheet: { - ...mockCaseWorksheet, - finalBriefDueDate: 'abc', // finalBriefDueDate should be a date formatted as YYYY-MM-DD + updateCaseWorksheetInteractor( + applicationContext, + { + worksheet: { + ...mockCaseWorksheet, + finalBriefDueDate: 'abc', // finalBriefDueDate should be a date formatted as YYYY-MM-DD + }, }, - }), + judgeColvin as UnknownAuthUser, + ), ).rejects.toThrow(InvalidEntityError); }); it('should persist and return the updated case worksheet when the updates are valid', async () => { const mockFinalBriefDueDate = '2023-08-29'; - applicationContext.getCurrentUser.mockReturnValue(judgeColvin); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(judgeColvin); @@ -57,12 +62,16 @@ describe('updateCaseWorksheetInteractor', () => { .getPersistenceGateway() .getCaseWorksheet.mockResolvedValue(mockCaseWorksheet); - const result = await updateCaseWorksheetInteractor(applicationContext, { - worksheet: { - ...mockCaseWorksheet, - finalBriefDueDate: mockFinalBriefDueDate, + const result = await updateCaseWorksheetInteractor( + applicationContext, + { + worksheet: { + ...mockCaseWorksheet, + finalBriefDueDate: mockFinalBriefDueDate, + }, }, - }); + judgeColvin as UnknownAuthUser, + ); const expectedUpdatedCaseWorksheet = { ...mockCaseWorksheet, @@ -83,17 +92,20 @@ describe('updateCaseWorksheetInteractor', () => { it('should persist the updated case worksheet when the updates are valid, using the judge`s userId in the section when the current user is a chambers user', async () => { const mockFinalBriefDueDate = '2023-08-29'; - applicationContext.getCurrentUser.mockReturnValue(colvinsChambersUser); applicationContext .getPersistenceGateway() .getCaseWorksheet.mockResolvedValue(mockCaseWorksheet); - const result = await updateCaseWorksheetInteractor(applicationContext, { - worksheet: { - ...mockCaseWorksheet, - finalBriefDueDate: mockFinalBriefDueDate, + const result = await updateCaseWorksheetInteractor( + applicationContext, + { + worksheet: { + ...mockCaseWorksheet, + finalBriefDueDate: mockFinalBriefDueDate, + }, }, - }); + mockChambersUser, + ); const expectedUpdatedCaseWorksheet = { ...mockCaseWorksheet, @@ -103,7 +115,7 @@ describe('updateCaseWorksheetInteractor', () => { applicationContext.getUseCaseHelpers().getJudgeForUserHelper.mock .calls[0][1], ).toEqual({ - user: colvinsChambersUser, + user: mockChambersUser, }); expect( applicationContext.getPersistenceGateway().updateCaseWorksheet, diff --git a/web-api/src/business/useCases/caseWorksheet/updateCaseWorksheetInteractor.ts b/web-api/src/business/useCases/caseWorksheet/updateCaseWorksheetInteractor.ts index b9f37ca87fc..92b85e1e96d 100644 --- a/web-api/src/business/useCases/caseWorksheet/updateCaseWorksheetInteractor.ts +++ b/web-api/src/business/useCases/caseWorksheet/updateCaseWorksheetInteractor.ts @@ -8,6 +8,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const updateCaseWorksheetInteractor = async ( applicationContext: ServerApplicationContext, @@ -16,16 +17,15 @@ export const updateCaseWorksheetInteractor = async ( }: { worksheet: RawCaseWorksheet; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_WORKSHEET)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_WORKSHEET)) { throw new UnauthorizedError('Unauthorized'); } const judgeUser = await applicationContext .getUseCaseHelpers() - .getJudgeForUserHelper(applicationContext, { user }); + .getJudgeForUserHelper(applicationContext, { user: authorizedUser }); const caseWorksheetEntity = new CaseWorksheet(worksheet).validate(); diff --git a/web-api/src/lambdas/caseWorksheet/updateCaseWorksheetLambda.ts b/web-api/src/lambdas/caseWorksheet/updateCaseWorksheetLambda.ts index eef00889cb0..998595f1a5f 100644 --- a/web-api/src/lambdas/caseWorksheet/updateCaseWorksheetLambda.ts +++ b/web-api/src/lambdas/caseWorksheet/updateCaseWorksheetLambda.ts @@ -1,11 +1,16 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -export const updateCaseWorksheetLambda = event => +export const updateCaseWorksheetLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() .updateCaseWorksheetInteractor( applicationContext, JSON.parse(event.body), + authorizedUser, ); }); From e94ce308fbdaf179115454ff5643026a15742769 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 09:06:56 -0700 Subject: [PATCH 249/523] 10417: remove appcontext.getCurrentUser from archiveCorrespondenceDocumentInteractor --- ...veCorrespondenceDocumentInteractor.test.ts | 84 +++++++++++-------- ...archiveCorrespondenceDocumentInteractor.ts | 17 ++-- .../archiveCorrespondenceDocumentLambda.ts | 16 +++- 3 files changed, 67 insertions(+), 50 deletions(-) diff --git a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.test.ts b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.test.ts index 1b794a832b4..49648b0c6f8 100644 --- a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.test.ts @@ -5,9 +5,9 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstan import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { archiveCorrespondenceDocumentInteractor } from './archiveCorrespondenceDocumentInteractor'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('archiveCorrespondenceDocumentInteractor', () => { - let mockUser; let mockUserId = '2474e5c0-f741-4120-befa-b77378ac8bf0'; const mockCorrespondenceId = applicationContext.getUniqueId(); let mockCorrespondence; @@ -28,13 +28,6 @@ describe('archiveCorrespondenceDocumentInteractor', () => { userId: mockUserId, }); - mockUser = { - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: mockUserId, - }; - - applicationContext.getCurrentUser.mockImplementation(() => mockUser); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue({ @@ -44,22 +37,29 @@ describe('archiveCorrespondenceDocumentInteractor', () => { }); it('should throw an Unauthorized error if the user role does not have the CASE_CORRESPONDENCE permission', async () => { - const user = { ...mockUser, role: ROLES.petitioner }; - applicationContext.getCurrentUser.mockReturnValue(user); + const user = { ...mockDocketClerkUser, role: ROLES.petitioner }; await expect( - archiveCorrespondenceDocumentInteractor(applicationContext, { - correspondenceId: mockCorrespondenceId, - docketNumber: MOCK_CASE.docketNumber, - } as any), + archiveCorrespondenceDocumentInteractor( + applicationContext, + { + correspondenceId: mockCorrespondenceId, + docketNumber: MOCK_CASE.docketNumber, + } as any, + user, + ), ).rejects.toThrow('Unauthorized'); }); it('should delete the specified correspondence document from s3', async () => { - await archiveCorrespondenceDocumentInteractor(applicationContext, { - correspondenceId: mockCorrespondenceId, - docketNumber: MOCK_CASE.docketNumber, - }); + await archiveCorrespondenceDocumentInteractor( + applicationContext, + { + correspondenceId: mockCorrespondenceId, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteDocumentFile.mock @@ -70,10 +70,14 @@ describe('archiveCorrespondenceDocumentInteractor', () => { }); it('should update the specified correspondence document on the case to be marked as archived', async () => { - await archiveCorrespondenceDocumentInteractor(applicationContext, { - correspondenceId: mockCorrespondenceId, - docketNumber: MOCK_CASE.docketNumber, - }); + await archiveCorrespondenceDocumentInteractor( + applicationContext, + { + correspondenceId: mockCorrespondenceId, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCaseCorrespondence.mock @@ -88,10 +92,14 @@ describe('archiveCorrespondenceDocumentInteractor', () => { }); it('should update the case to reflect the archived correspondence', async () => { - await archiveCorrespondenceDocumentInteractor(applicationContext, { - correspondenceId: mockCorrespondenceId, - docketNumber: MOCK_CASE.docketNumber, - }); + await archiveCorrespondenceDocumentInteractor( + applicationContext, + { + correspondenceId: mockCorrespondenceId, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -107,10 +115,14 @@ describe('archiveCorrespondenceDocumentInteractor', () => { mockLock = MOCK_LOCK; await expect( - archiveCorrespondenceDocumentInteractor(applicationContext, { - correspondenceId: mockCorrespondenceId, - docketNumber: MOCK_CASE.docketNumber, - }), + archiveCorrespondenceDocumentInteractor( + applicationContext, + { + correspondenceId: mockCorrespondenceId, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -119,10 +131,14 @@ describe('archiveCorrespondenceDocumentInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await archiveCorrespondenceDocumentInteractor(applicationContext, { - correspondenceId: mockCorrespondenceId, - docketNumber: MOCK_CASE.docketNumber, - }); + await archiveCorrespondenceDocumentInteractor( + applicationContext, + { + correspondenceId: mockCorrespondenceId, + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts index 9d9fd4b11ff..d669d51adfd 100644 --- a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts +++ b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts @@ -5,27 +5,20 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -/** - * archiveCorrespondenceDocument - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.correspondenceId case correspondence id - * @param {string} providers.docketNumber the docket number of the case - * @returns {void} - */ export const archiveCorrespondenceDocument = async ( applicationContext: ServerApplicationContext, { correspondenceId, docketNumber, }: { correspondenceId: string; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); + // const user = applicationContext.getCurrentUser(); - if (!isAuthorized(user, ROLE_PERMISSIONS.CASE_CORRESPONDENCE)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_CORRESPONDENCE)) { throw new UnauthorizedError('Unauthorized'); } @@ -38,7 +31,7 @@ export const archiveCorrespondenceDocument = async ( .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); - const caseEntity = new Case(caseToUpdate, { authorizedUser: user }); + const caseEntity = new Case(caseToUpdate, { authorizedUser }); const correspondenceToArchiveEntity = caseEntity.correspondence.find( c => c.correspondenceId === correspondenceId, ); diff --git a/web-api/src/lambdas/correspondence/archiveCorrespondenceDocumentLambda.ts b/web-api/src/lambdas/correspondence/archiveCorrespondenceDocumentLambda.ts index c2ae1fc3387..cb56103c763 100644 --- a/web-api/src/lambdas/correspondence/archiveCorrespondenceDocumentLambda.ts +++ b/web-api/src/lambdas/correspondence/archiveCorrespondenceDocumentLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const archiveCorrespondenceDocumentLambda = event => +export const archiveCorrespondenceDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .archiveCorrespondenceDocumentInteractor(applicationContext, { - ...event.pathParameters, - }); + .archiveCorrespondenceDocumentInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); }); From 3cee47307c298670f92cb481706f7a940890d937 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 09:28:14 -0700 Subject: [PATCH 250/523] 10417: remove appcontext.getCurrentUser from fileCorrespondenceDocumentInteractor --- ...leCorrespondenceDocumentInteractor.test.ts | 62 +++++++++++-------- .../fileCorrespondenceDocumentInteractor.ts | 3 +- .../fileCorrespondenceDocumentLambda.ts | 16 +++-- 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.test.ts b/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.test.ts index f0a0e00eec1..c3b9005e29b 100644 --- a/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.test.ts @@ -7,11 +7,12 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createISODateString } from '../../../../../shared/src/business/utilities/DateHandler'; -import { - docketClerkUser, - petitionerUser, -} from '../../../../../shared/src/test/mockUsers'; +import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; import { fileCorrespondenceDocumentInteractor } from './fileCorrespondenceDocumentInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('fileCorrespondenceDocumentInteractor', () => { const mockCase = { @@ -57,7 +58,6 @@ describe('fileCorrespondenceDocumentInteractor', () => { const mockCorrespondenceId = '14bb669b-0962-4781-87a0-50718f556e2b'; beforeEach(() => { - applicationContext.getCurrentUser.mockImplementation(() => docketClerkUser); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); @@ -68,16 +68,17 @@ describe('fileCorrespondenceDocumentInteractor', () => { }); it('should throw an Unauthorized error if the user role does not have theCASE_CORRESPONDENCE permission', async () => { - const user = petitionerUser; - applicationContext.getCurrentUser.mockReturnValue(user); - await expect( - fileCorrespondenceDocumentInteractor(applicationContext, { - documentMetadata: { - docketNumber: mockCase.docketNumber, - } as any, - primaryDocumentFileId: mockCorrespondenceId, - }), + fileCorrespondenceDocumentInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: mockCase.docketNumber, + } as any, + primaryDocumentFileId: mockCorrespondenceId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -87,10 +88,14 @@ describe('fileCorrespondenceDocumentInteractor', () => { .getCaseByDocketNumber.mockReturnValue(null); await expect( - fileCorrespondenceDocumentInteractor(applicationContext, { - documentMetadata: { docketNumber: mockCase.docketNumber } as any, - primaryDocumentFileId: mockCorrespondenceId, - }), + fileCorrespondenceDocumentInteractor( + applicationContext, + { + documentMetadata: { docketNumber: mockCase.docketNumber } as any, + primaryDocumentFileId: mockCorrespondenceId, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(`Case ${mockCase.docketNumber} was not found`); }); @@ -102,14 +107,18 @@ describe('fileCorrespondenceDocumentInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(mockCase); - await fileCorrespondenceDocumentInteractor(applicationContext, { - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: mockDocumentTitle, - filingDate: mockFilingDate, - } as any, - primaryDocumentFileId: mockCorrespondenceId, - }); + await fileCorrespondenceDocumentInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: mockDocumentTitle, + filingDate: mockFilingDate, + } as any, + primaryDocumentFileId: mockCorrespondenceId, + }, + docketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCaseCorrespondence.mock .calls[0][0], @@ -140,6 +149,7 @@ describe('fileCorrespondenceDocumentInteractor', () => { } as any, primaryDocumentFileId: mockCorrespondenceId, }, + mockDocketClerkUser, ); expect(result).toMatchObject({ ...mockCase, diff --git a/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.ts b/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.ts index c413b9545c6..75fdb4eacea 100644 --- a/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.ts +++ b/web-api/src/business/useCases/correspondence/fileCorrespondenceDocumentInteractor.ts @@ -6,6 +6,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * fileCorrespondenceDocumentInteractor @@ -22,8 +23,8 @@ export const fileCorrespondenceDocumentInteractor = async ( documentMetadata, primaryDocumentFileId, }: { documentMetadata: TDocumentMetaData; primaryDocumentFileId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); const { docketNumber } = documentMetadata; if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_CORRESPONDENCE)) { diff --git a/web-api/src/lambdas/correspondence/fileCorrespondenceDocumentLambda.ts b/web-api/src/lambdas/correspondence/fileCorrespondenceDocumentLambda.ts index 7dd9f597c5e..5505d00511f 100644 --- a/web-api/src/lambdas/correspondence/fileCorrespondenceDocumentLambda.ts +++ b/web-api/src/lambdas/correspondence/fileCorrespondenceDocumentLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const fileCorrespondenceDocumentLambda = event => +export const fileCorrespondenceDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .fileCorrespondenceDocumentInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .fileCorrespondenceDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); From 4125fb216f153e970aca90e039c146b3a5aa1568 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 09:37:07 -0700 Subject: [PATCH 251/523] 10417: remove appcontext.getCurrentUser from updateCorrespondenceDocumentInteractor --- ...teCorrespondenceDocumentInteractor.test.ts | 44 ++++++++++--------- .../updateCorrespondenceDocumentInteractor.ts | 11 +---- .../updateCorrespondenceDocumentLambda.ts | 16 +++++-- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.test.ts b/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.test.ts index b2cdd1bdb03..1e3e186b510 100644 --- a/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.test.ts @@ -8,16 +8,14 @@ import { import { Correspondence } from '../../../../../shared/src/business/entities/Correspondence'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createISODateString } from '../../../../../shared/src/business/utilities/DateHandler'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { updateCorrespondenceDocumentInteractor } from './updateCorrespondenceDocumentInteractor'; describe('updateCorrespondenceDocumentInteractor', () => { - let mockUser; const mockDocketEntryId = 'cf105788-5d34-4451-aa8d-dfd9a851b675'; - const mockUserFixture = { - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '2474e5c0-f741-4120-befa-b77378ac8bf0', - }; const mockCorrespondence = new Correspondence({ correspondenceId: '74e36bf7-dcbd-4ee7-a9ec-6d7446096df8', @@ -67,32 +65,35 @@ describe('updateCorrespondenceDocumentInteractor', () => { }; beforeEach(() => { - mockUser = mockUserFixture; - - applicationContext.getCurrentUser.mockImplementation(() => mockUser); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(mockCase); }); it('should throw an Unauthorized error if the user role does not have the CASE_CORRESPONDENCE permission', async () => { - mockUser = { ...mockUser, role: ROLES.petitioner }; - await expect( - updateCorrespondenceDocumentInteractor(applicationContext, { - documentMetadata: { docketNumber: mockCase.docketNumber } as any, - }), + updateCorrespondenceDocumentInteractor( + applicationContext, + { + documentMetadata: { docketNumber: mockCase.docketNumber } as any, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should update the specified correspondence document title when the case entity is valid', async () => { - await updateCorrespondenceDocumentInteractor(applicationContext, { - documentMetadata: { - correspondenceId: mockCorrespondence.correspondenceId, - docketNumber: mockCase.docketNumber, - documentTitle: 'A title that has been updated', - } as any, - }); + await updateCorrespondenceDocumentInteractor( + applicationContext, + { + documentMetadata: { + correspondenceId: mockCorrespondence.correspondenceId, + docketNumber: mockCase.docketNumber, + documentTitle: 'A title that has been updated', + } as any, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCaseCorrespondence.mock @@ -116,6 +117,7 @@ describe('updateCorrespondenceDocumentInteractor', () => { documentTitle: 'A title that has been updated', } as any, }, + mockDocketClerkUser, ); expect(result).toMatchObject({ diff --git a/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.ts b/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.ts index f3811b63d9c..80228e52194 100644 --- a/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.ts +++ b/web-api/src/business/useCases/correspondence/updateCorrespondenceDocumentInteractor.ts @@ -6,20 +6,13 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * updateCorrespondenceDocumentInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.documentMetadata the document metadata - * @returns {Promise<*>} the updated case entity after the correspondence document is updated - */ export const updateCorrespondenceDocumentInteractor = async ( applicationContext: ServerApplicationContext, { documentMetadata }: { documentMetadata: TDocumentMetaData }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); const { docketNumber } = documentMetadata; if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_CORRESPONDENCE)) { diff --git a/web-api/src/lambdas/correspondence/updateCorrespondenceDocumentLambda.ts b/web-api/src/lambdas/correspondence/updateCorrespondenceDocumentLambda.ts index b4098c451aa..ef30a16238d 100644 --- a/web-api/src/lambdas/correspondence/updateCorrespondenceDocumentLambda.ts +++ b/web-api/src/lambdas/correspondence/updateCorrespondenceDocumentLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateCorrespondenceDocumentLambda = event => +export const updateCorrespondenceDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .updateCorrespondenceDocumentInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .updateCorrespondenceDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); From 4022f3aad0bafd867b1d57021b83c177818c4364 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 09:48:31 -0700 Subject: [PATCH 252/523] 10417: remove appcontext.getCurrentUser from serveCourtIssuedDocumentInteractor --- ...serveCourtIssuedDocumentInteractor.test.ts | 198 +++++++++++------- .../serveCourtIssuedDocumentInteractor.ts | 4 +- .../cases/serveCourtIssuedDocumentLambda.ts | 16 +- 3 files changed, 137 insertions(+), 81 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts index 4f8308e3a15..b26bf4e4c68 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts @@ -2,11 +2,13 @@ import { AUTO_GENERATED_DEADLINE_DOCUMENT_TYPES } from '../../../../../shared/sr import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_DOCUMENTS } from '../../../../../shared/src/test/mockDocketEntry'; import { MOCK_TRIAL_REGULAR } from '../../../../../shared/src/test/mockTrial'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { docketClerkUser, judgeUser, } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { serveCourtIssuedDocumentInteractor } from './serveCourtIssuedDocumentInteractor'; describe('serveCourtIssuedDocumentInteractor', () => { @@ -14,8 +16,6 @@ describe('serveCourtIssuedDocumentInteractor', () => { const mockClientConnectionId = 'ABC123'; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); @@ -42,15 +42,19 @@ describe('serveCourtIssuedDocumentInteractor', () => { }); it('should throw an error when the user role does not have permission to serve a court issued document', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); + // applicationContext.getCurrentUser.mockReturnValue({}); await expect( - serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: '', - docketNumbers: [], - subjectCaseDocketNumber: '', - }), + serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: '', + docketNumbers: [], + subjectCaseDocketNumber: '', + }, + {} as UnknownAuthUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -60,12 +64,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { .getCaseByDocketNumber.mockReturnValue({}); await expect( - serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: '', - docketNumbers: [], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }), + serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: '', + docketNumbers: [], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(`Case ${MOCK_CASE.docketNumber} was not found`); }); @@ -78,12 +86,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { }); await expect( - serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }), + serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(`Docket entry ${mockDocketEntryId} was not found`); }); @@ -101,12 +113,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { }); await expect( - serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }), + serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry has already been served'); }); @@ -124,12 +140,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { }); await expect( - serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }), + serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry is already being served'); expect( @@ -155,12 +175,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { .getUseCaseHelpers() .countPagesInDocument.mockReturnValue(3256); - await serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }); + await serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); const servedDocketEntry = applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -182,12 +206,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { ], }); - await serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [MOCK_CASE.docketNumber], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }); + await serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [MOCK_CASE.docketNumber], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().autoGenerateDeadline, @@ -218,12 +246,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { ], }); - await serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [MOCK_CASE.docketNumber], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }); + await serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [MOCK_CASE.docketNumber], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().autoGenerateDeadline.mock @@ -250,12 +282,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { ], }); - await serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: ['200-21', '300-33'], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }); + await serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: ['200-21', '300-33'], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase, @@ -276,12 +312,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { ], }); - await serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }); + await serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); const expectedDocketEntry = applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -302,12 +342,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { ], }); - await serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }); + await serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -348,12 +392,16 @@ describe('serveCourtIssuedDocumentInteractor', () => { ); await expect( - serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: MOCK_CASE.docketNumber, - }), + serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('whoops, that is an error!'); expect( diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts index b219ddac0bb..a7c496603b9 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts @@ -7,6 +7,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createISODateString } from '../../../../../shared/src/business/utilities/DateHandler'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -23,9 +24,8 @@ export const serveCourtIssuedDocument = async ( docketNumbers: string[]; subjectCaseDocketNumber: string; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - const hasPermission = (isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY) || isAuthorized( diff --git a/web-api/src/lambdas/cases/serveCourtIssuedDocumentLambda.ts b/web-api/src/lambdas/cases/serveCourtIssuedDocumentLambda.ts index 7805c0d8c3e..69d15e0f62e 100644 --- a/web-api/src/lambdas/cases/serveCourtIssuedDocumentLambda.ts +++ b/web-api/src/lambdas/cases/serveCourtIssuedDocumentLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,15 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const serveCourtIssuedDocumentLambda = event => +export const serveCourtIssuedDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .serveCourtIssuedDocumentInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .serveCourtIssuedDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); From e3404bafb3c836fdff7622b81b2e23344b7df494 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 10:22:53 -0700 Subject: [PATCH 253/523] 10417: remove appcontext.getCurrentUser from createCourtIssuedOrderPdfFromHtmlInteractor --- ...rtIssuedOrderPdfFromHtmlInteractor.test.ts | 33 ++++++++++--------- ...teCourtIssuedOrderPdfFromHtmlInteractor.ts | 10 ++++-- ...createCourtIssuedOrderPdfFromHtmlLambda.ts | 16 ++++++--- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts index 0d0a263b37d..bb6d470a192 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts @@ -1,6 +1,9 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createCourtIssuedOrderPdfFromHtmlInteractor } from './createCourtIssuedOrderPdfFromHtmlInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { const mockPdfUrl = 'www.example.com'; @@ -26,23 +29,12 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { }); }); - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: '321', - }); - }); - it('throws an error if the user is not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '432', - }); - await expect( createCourtIssuedOrderPdfFromHtmlInteractor( applicationContext, {} as any, + mockPetitionerUser, ), ).rejects.toThrow('Unauthorized'); }); @@ -51,6 +43,7 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { await createCourtIssuedOrderPdfFromHtmlInteractor( applicationContext, {} as any, + mockDocketClerkUser, ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -61,6 +54,7 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { await createCourtIssuedOrderPdfFromHtmlInteractor( applicationContext, {} as any, + mockDocketClerkUser, ); expect( applicationContext.getDocumentGenerators().order, @@ -77,6 +71,7 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { const result = await createCourtIssuedOrderPdfFromHtmlInteractor( applicationContext, {} as any, + mockDocketClerkUser, ); expect( @@ -91,6 +86,7 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { { addedDocketNumbers: ['101-20'], } as any, + mockDocketClerkUser, ); expect( @@ -109,6 +105,7 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { { eventCode: 'NOT', } as any, + mockDocketClerkUser, ); expect( @@ -125,9 +122,13 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { }); it('calls the generate the order pdf WITHOUT a defined name or title of the clerk for non-NOT event codes', async () => { - await createCourtIssuedOrderPdfFromHtmlInteractor(applicationContext, { - eventCode: 'O', - } as any); + await createCourtIssuedOrderPdfFromHtmlInteractor( + applicationContext, + { + eventCode: 'O', + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getConfigurationItemValue, diff --git a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts index 91a5238ba8d..664d6890c4b 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts @@ -8,6 +8,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { getCaseCaptionMeta } from '../../../../../shared/src/business/utilities/getCaseCaptionMeta'; export const createCourtIssuedOrderPdfFromHtmlInteractor = async ( @@ -25,13 +26,12 @@ export const createCourtIssuedOrderPdfFromHtmlInteractor = async ( documentTitle: string; eventCode: string; }, + authorizedUser: UnknownAuthUser, ): Promise<{ fileId: string; url: string; }> => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT)) { throw new UnauthorizedError('Unauthorized'); } @@ -67,6 +67,8 @@ export const createCourtIssuedOrderPdfFromHtmlInteractor = async ( addedDocketNumbers, caseCaptionExtension, caseTitle, + // TODO 10417: docketNumberwithSuffix should be properly typed + // @ts-ignore docketNumberWithSuffix, nameOfClerk, orderContent: contentHtml, @@ -77,6 +79,8 @@ export const createCourtIssuedOrderPdfFromHtmlInteractor = async ( return await applicationContext.getUseCaseHelpers().saveFileAndGenerateUrl({ applicationContext, + // TODO 10417: file should be properly typed + // @ts-ignore file: orderPdf, useTempBucket: true, }); diff --git a/web-api/src/lambdas/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlLambda.ts b/web-api/src/lambdas/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlLambda.ts index b70ec8e00ce..34fd5633e4e 100644 --- a/web-api/src/lambdas/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlLambda.ts +++ b/web-api/src/lambdas/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,15 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const createCourtIssuedOrderPdfFromHtmlLambda = event => +export const createCourtIssuedOrderPdfFromHtmlLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .createCourtIssuedOrderPdfFromHtmlInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .createCourtIssuedOrderPdfFromHtmlInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); From 0e52da6cf46a738b9544c93f42581874810464d2 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 11:12:51 -0700 Subject: [PATCH 254/523] 10417: remove appcontext.getCurrentUser from updateCourtIssuedOrderInteractor --- .../updateCourtIssuedOrderInteractor.test.ts | 319 ++++++++++-------- .../updateCourtIssuedOrderInteractor.ts | 11 +- .../updateCourtIssuedOrderToCaseLambda.ts | 18 +- 3 files changed, 196 insertions(+), 152 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.test.ts b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.test.ts index aa2cb3ba6af..79339802165 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.test.ts @@ -8,14 +8,17 @@ import { import { Case } from '@shared/business/entities/cases/Case'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { updateCourtIssuedOrderInteractor } from './updateCourtIssuedOrderInteractor'; describe('updateCourtIssuedOrderInteractor', () => { - let mockCurrentUser; - let mockUserById; const mockUserId = applicationContext.getUniqueId(); + let mockUserById; let caseRecord = { caseCaption: 'Caption', @@ -83,14 +86,6 @@ describe('updateCourtIssuedOrderInteractor', () => { beforeEach(() => { mockLock = undefined; - mockCurrentUser = new User({ - name: 'Olivia Jade', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser); - mockUserById = { name: 'bob', userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', @@ -106,18 +101,22 @@ describe('updateCourtIssuedOrderInteractor', () => { }); it('should throw an error if not authorized', async () => { - mockCurrentUser.role = ROLES.privatePractitioner; + // mockCurrentUser.role = ROLES.privatePractitioner; mockUserById = { name: 'bob' }; await expect( - updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - eventCode: 'OSC', + updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentType: 'Order to Show Cause', + eventCode: 'OSC', + }, }, - }), + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -125,31 +124,39 @@ describe('updateCourtIssuedOrderInteractor', () => { applicationContext.getPersistenceGateway().getUserById.mockResolvedValue(); await expect( - updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: '986fece3-6325-4418-bb28-a7095e6707b4', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - eventCode: 'OSC', + updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: '986fece3-6325-4418-bb28-a7095e6707b4', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentType: 'Order to Show Cause', + eventCode: 'OSC', + }, }, - }), + mockPetitionsClerkUser, + ), ).rejects.toThrow('Document not found'); }); it('update existing document within case', async () => { - await updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order of Dismissal for Lack of Jurisdiction', - documentType: 'Notice', - draftOrderState: { - documentType: 'Order of Dismissal for Lack of Jurisdiction', - eventCode: 'ODJ', + await updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Order of Dismissal for Lack of Jurisdiction', + documentType: 'Notice', + draftOrderState: { + documentType: 'Order of Dismissal for Lack of Jurisdiction', + eventCode: 'ODJ', + }, + eventCode: 'NOT', }, - eventCode: 'NOT', }, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -178,19 +185,23 @@ describe('updateCourtIssuedOrderInteractor', () => { it('should not populate free text for OSCP', async () => { const mockDocumentTitle = 'Order to Show Cause Title'; - await updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: mockDocumentTitle, - documentType: 'Notice', - draftOrderState: { - documentType: 'Order to Show Cause', - eventCode: 'OSCP', + await updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: mockDocumentTitle, + documentType: 'Notice', + draftOrderState: { + documentType: 'Order to Show Cause', + eventCode: 'OSCP', + }, + eventCode: 'NOT', }, - eventCode: 'NOT', }, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -217,19 +228,23 @@ describe('updateCourtIssuedOrderInteractor', () => { it('should not populate free text for OF', async () => { const mockDocumentTitle = 'Order for Filing Fee Title'; - await updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: mockDocumentTitle, - documentType: 'Notice', - draftOrderState: { - documentType: 'Order for Filing Fee', - eventCode: 'OF', + await updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: mockDocumentTitle, + documentType: 'Notice', + draftOrderState: { + documentType: 'Order for Filing Fee', + eventCode: 'OF', + }, + eventCode: 'NOT', }, - eventCode: 'NOT', }, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -255,19 +270,23 @@ describe('updateCourtIssuedOrderInteractor', () => { it('should not populate free text for OAP', async () => { const mockDocumentTitle = 'Order for Amended Petition Title'; - await updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: mockDocumentTitle, - documentType: 'Notice', - draftOrderState: { - documentType: 'Order for Amended Petition', - eventCode: 'OAP', + await updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: mockDocumentTitle, + documentType: 'Notice', + draftOrderState: { + documentType: 'Order for Amended Petition', + eventCode: 'OAP', + }, + eventCode: 'NOT', }, - eventCode: 'NOT', }, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -292,15 +311,19 @@ describe('updateCourtIssuedOrderInteractor', () => { }); it('should not update freeText on existing document within case if not an order type', async () => { - await updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Notice Title', - documentType: 'Notice', - eventCode: 'A', + await updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Notice Title', + documentType: 'Notice', + eventCode: 'A', + }, }, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -327,23 +350,27 @@ describe('updateCourtIssuedOrderInteractor', () => { }); it('stores documentContents in S3 if present', async () => { - await updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'the contents!', - documentType: 'Order to Show Cause', - draftOrderState: { + await updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, documentContents: 'the contents!', + documentType: 'Order to Show Cause', + draftOrderState: { + documentContents: 'the contents!', + richText: 'the contents!', + }, + eventCode: 'OSC', richText: 'the contents!', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', }, - eventCode: 'OSC', - richText: 'the contents!', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', }, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda.mock @@ -362,32 +389,36 @@ describe('updateCourtIssuedOrderInteractor', () => { it('should still contain the case caption in documentContents when edited', async () => { let mockContents = 'the contents!'; - await updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: mockContents, - documentType: 'Order to Show Cause', - draftOrderState: { + await updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, documentContents: mockContents, + documentType: 'Order to Show Cause', + draftOrderState: { + documentContents: mockContents, + richText: 'the contents!', + }, + eventCode: 'OSC', richText: 'the contents!', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', }, - eventCode: 'OSC', - richText: 'the contents!', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', }, - }); + mockPetitionsClerkUser, + ); - const newCaseEntity = new Case(caseRecord, { applicationContext }); + const newCaseEntity = new Case(caseRecord, { + authorizedUser: mockPetitionerUser, + }); const expectedDocumentContents = mockContents + ` ${newCaseEntity.docketNumberWithSuffix} ${newCaseEntity.caseCaption}`; - console.log('expectedDocumentContents', expectedDocumentContents); - const expectedContentsToStore = { documentContents: expectedDocumentContents, richText: `${mockContents}`, @@ -402,16 +433,20 @@ describe('updateCourtIssuedOrderInteractor', () => { }); it('does not update non-editable fields on document', async () => { - await updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - draftOrderState: undefined, - eventCode: 'OSC', - judge: 'Judge Judgy', + await updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentType: 'Order to Show Cause', + draftOrderState: undefined, + eventCode: 'OSC', + judge: 'Judge Judgy', + }, }, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -426,19 +461,23 @@ describe('updateCourtIssuedOrderInteractor', () => { mockLock = MOCK_LOCK; await expect( - updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order of Dismissal for Lack of Jurisdiction', - documentType: 'Notice', - draftOrderState: { - documentType: 'Order of Dismissal for Lack of Jurisdiction', - eventCode: 'ODJ', + updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Order of Dismissal for Lack of Jurisdiction', + documentType: 'Notice', + draftOrderState: { + documentType: 'Order of Dismissal for Lack of Jurisdiction', + eventCode: 'ODJ', + }, + eventCode: 'NOT', }, - eventCode: 'NOT', }, - }), + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -447,19 +486,23 @@ describe('updateCourtIssuedOrderInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await updateCourtIssuedOrderInteractor(applicationContext, { - docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order of Dismissal for Lack of Jurisdiction', - documentType: 'Notice', - draftOrderState: { - documentType: 'Order of Dismissal for Lack of Jurisdiction', - eventCode: 'ODJ', + await updateCourtIssuedOrderInteractor( + applicationContext, + { + docketEntryIdToEdit: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Order of Dismissal for Lack of Jurisdiction', + documentType: 'Notice', + draftOrderState: { + documentType: 'Order of Dismissal for Lack of Jurisdiction', + eventCode: 'ODJ', + }, + eventCode: 'NOT', }, - eventCode: 'NOT', }, - }); + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts index 6446733f60a..61aea2a9b7c 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts @@ -10,22 +10,15 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { get } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -/** - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.docketEntryIdToEdit the id of the docket entry to update - * @param {object} providers.documentMetadata the document metadata - * @returns {Promise<*>} the updated case entity after the document is updated - */ export const updateCourtIssuedOrder = async ( applicationContext, { docketEntryIdToEdit, documentMetadata }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); const { docketNumber } = documentMetadata; if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT)) { diff --git a/web-api/src/lambdas/documents/updateCourtIssuedOrderToCaseLambda.ts b/web-api/src/lambdas/documents/updateCourtIssuedOrderToCaseLambda.ts index c2501692ff4..d7047dafc0e 100644 --- a/web-api/src/lambdas/documents/updateCourtIssuedOrderToCaseLambda.ts +++ b/web-api/src/lambdas/documents/updateCourtIssuedOrderToCaseLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +7,19 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateCourtIssuedOrderToCaseLambda = event => +export const updateCourtIssuedOrderToCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .updateCourtIssuedOrderInteractor(applicationContext, { - ...JSON.parse(event.body), - docketEntryIdToEdit: event.pathParameters.docketEntryId, - }); + .updateCourtIssuedOrderInteractor( + applicationContext, + { + ...JSON.parse(event.body), + docketEntryIdToEdit: event.pathParameters.docketEntryId, + }, + authorizedUser, + ); }); From 6d9ef86b74a0ab5e1d315c21320fd9ba4e0702f4 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 18 Jul 2024 14:13:20 -0400 Subject: [PATCH 255/523] 10417 rm getCurrentUser from headerHelper --- .../src/authorization/authorizationClientService.ts | 1 + .../src/presenter/computeds/headerHelper.test.ts | 11 +++++++++-- web-client/src/presenter/computeds/headerHelper.ts | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/shared/src/authorization/authorizationClientService.ts b/shared/src/authorization/authorizationClientService.ts index 6fc7e1d8144..554c94f059a 100644 --- a/shared/src/authorization/authorizationClientService.ts +++ b/shared/src/authorization/authorizationClientService.ts @@ -350,6 +350,7 @@ export const isAuthorized = ( owner?: string, ): user is AuthUser => { if (!isAuthUser(user)) { + console.debug('User is not authenticated'); return false; } diff --git a/web-client/src/presenter/computeds/headerHelper.test.ts b/web-client/src/presenter/computeds/headerHelper.test.ts index 2b5a9ddca45..c154a31d5ba 100644 --- a/web-client/src/presenter/computeds/headerHelper.test.ts +++ b/web-client/src/presenter/computeds/headerHelper.test.ts @@ -1,5 +1,6 @@ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; -import { applicationContext } from '@shared/business/test/createTestApplicationContext'; +//import { applicationContext } from '@shared/business/test/createTestApplicationContext'; +import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { headerHelper as headerHelperComputed } from './headerHelper'; import { runCompute } from '@web-client/presenter/test.cerebral'; @@ -18,6 +19,7 @@ const getBaseState = user => { unreadCount: 0, }, permissions: getUserPermissions(user), + user, }; }; @@ -100,9 +102,14 @@ describe('headerHelper', () => { }); it('should show trial sessions for internal users', () => { + const user = { + email: 'something@mail.com', + name: 'Jody', + userId: '77747b11-19b3-4c96-b7a1-fa6a5654e2d5', + }; internal.forEach(role => { const result = runCompute(headerHelper, { - state: getBaseState({ role }), + state: getBaseState({ role, ...user }), }); expect(result.showTrialSessions).toBeTruthy(); }); diff --git a/web-client/src/presenter/computeds/headerHelper.ts b/web-client/src/presenter/computeds/headerHelper.ts index 9213395f378..f406858c1f1 100644 --- a/web-client/src/presenter/computeds/headerHelper.ts +++ b/web-client/src/presenter/computeds/headerHelper.ts @@ -6,7 +6,7 @@ export const headerHelper = ( get: Get, applicationContext: ClientApplicationContext, ): any => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const userRole = user && user.role; const isLoggedIn = !!user; const currentPage = get(state.currentPage) || ''; From c5fa1a46711e2fabe3862e199ae00e5c85cae9b3 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 11:52:43 -0700 Subject: [PATCH 256/523] 10417: remove appcontext.getCurrentUser from createCaseInteractor --- .../useCases/createCaseInteractor.test.ts | 509 ++++++++++-------- .../business/useCases/createCaseInteractor.ts | 14 +- web-api/src/lambdas/cases/createCaseLambda.ts | 13 +- .../dynamo/cases/docketNumberGenerator.ts | 2 +- 4 files changed, 288 insertions(+), 250 deletions(-) diff --git a/web-api/src/business/useCases/createCaseInteractor.test.ts b/web-api/src/business/useCases/createCaseInteractor.test.ts index 9d08b64a53a..55e3f0352b0 100644 --- a/web-api/src/business/useCases/createCaseInteractor.test.ts +++ b/web-api/src/business/useCases/createCaseInteractor.test.ts @@ -63,12 +63,12 @@ describe('createCaseInteractor', () => { beforeEach(() => { user = new User({ + email: 'tom.petitioner@example.com', name: 'Test Petitioner', role: ROLES.petitioner, userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }); - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext.docketNumberGenerator.createDocketNumber.mockResolvedValue( '00101-00', ); @@ -86,18 +86,22 @@ describe('createCaseInteractor', () => { user = {}; await expect( - createCaseInteractor(applicationContext, { - petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', - petitionMetadata: { - caseType: CASE_TYPES_MAP.other, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.petitioner, - preferredTrialCity: 'Fresno, California', - procedureType: 'Small', - }, - stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - } as any), + createCaseInteractor( + applicationContext, + { + petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', + petitionMetadata: { + caseType: CASE_TYPES_MAP.other, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.petitioner, + preferredTrialCity: 'Fresno, California', + procedureType: 'Small', + }, + stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', + } as any, + user, + ), ).rejects.toThrow('Unauthorized'); expect( applicationContext.getUseCaseHelpers().createCaseAndAssociations, @@ -108,11 +112,15 @@ describe('createCaseInteractor', () => { }); it('should create a case (with a case status history) successfully as a petitioner', async () => { - const result = await createCaseInteractor(applicationContext, { - petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', - petitionMetadata: mockPetitionMetadata, - stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - } as any); + const result = await createCaseInteractor( + applicationContext, + { + petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', + petitionMetadata: mockPetitionMetadata, + stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', + } as any, + user, + ); expect(result).toBeDefined(); expect( @@ -138,16 +146,21 @@ describe('createCaseInteractor', () => { it('should create a case (with a case status history) successfully as a private practitioner', async () => { user = { barNumber: 'BN1234', + email: 'privateprac@example.com', name: 'Attorney One', role: ROLES.privatePractitioner, userId: '330d4b65-620a-489d-8414-6623653ebc4f', }; - const result = await createCaseInteractor(applicationContext, { - petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', - petitionMetadata: mockPetitionMetadata, - stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - } as any); + const result = await createCaseInteractor( + applicationContext, + { + petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', + petitionMetadata: mockPetitionMetadata, + stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', + } as any, + user, + ); expect(result).toBeDefined(); expect( @@ -171,47 +184,55 @@ describe('createCaseInteractor', () => { }); it('should match the current user id to the contactId when the user is petitioner', async () => { - const result = await createCaseInteractor(applicationContext, { - petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', - petitionMetadata: mockPetitionMetadata, - stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - } as any); + const result = await createCaseInteractor( + applicationContext, + { + petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', + petitionMetadata: mockPetitionMetadata, + stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', + } as any, + user, + ); expect(result.petitioners[0].contactId).toEqual(user.userId); expect(result.petitioners[0].address1).toEqual('99 South Oak Lane'); }); it('should create a STIN docket entry on the case with index 0', async () => { - const result = await createCaseInteractor(applicationContext, { - petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', - petitionMetadata: { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '99 South Oak Lane', - address2: 'Culpa numquam saepe ', - address3: 'Eaque voluptates com', - city: 'Dignissimos voluptat', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'petitioner1@example.com', - name: 'Diana Prince', - phone: '+1 (215) 128-6587', - postalCode: '69580', - state: 'AR', + const result = await createCaseInteractor( + applicationContext, + { + petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', + petitionMetadata: { + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '99 South Oak Lane', + address2: 'Culpa numquam saepe ', + address3: 'Eaque voluptates com', + city: 'Dignissimos voluptat', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'petitioner1@example.com', + name: 'Diana Prince', + phone: '+1 (215) 128-6587', + postalCode: '69580', + state: 'AR', + }, + contactSecondary: {}, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.petitioner, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + preferredTrialCity: 'Fresno, California', + procedureType: 'Small', + signature: true, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, }, - contactSecondary: {}, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.petitioner, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - preferredTrialCity: 'Fresno, California', - procedureType: 'Small', - signature: true, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, - }, - stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - } as any); + stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', + } as any, + user, + ); const stinDocketEntry = result.docketEntries.find( d => d.eventCode === INITIAL_DOCUMENT_TYPES.stin.eventCode, @@ -222,42 +243,47 @@ describe('createCaseInteractor', () => { it('should create a case successfully as a practitioner', async () => { user = new PrivatePractitioner({ barNumber: 'BN1234', + email: 'pbventures@example.com', name: 'Mister Peanutbutter', role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); - const result = await createCaseInteractor(applicationContext, { - corporateDisclosureFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', - petitionMetadata: { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '99 South Oak Lane', - address2: 'Culpa numquam saepe ', - address3: 'Eaque voluptates com', - city: 'Dignissimos voluptat', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'petitioner1@example.com', - name: 'Diana Prince', - phone: '+1 (215) 128-6587', - postalCode: '69580', - state: 'AR', + const result = await createCaseInteractor( + applicationContext, + { + corporateDisclosureFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', + petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', + petitionMetadata: { + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '99 South Oak Lane', + address2: 'Culpa numquam saepe ', + address3: 'Eaque voluptates com', + city: 'Dignissimos voluptat', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'petitioner1@example.com', + name: 'Diana Prince', + phone: '+1 (215) 128-6587', + postalCode: '69580', + state: 'AR', + }, + contactSecondary: {}, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.petitioner, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + preferredTrialCity: 'Fresno, California', + procedureType: 'Small', + signature: true, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, }, - contactSecondary: {}, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.petitioner, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - preferredTrialCity: 'Fresno, California', - procedureType: 'Small', - signature: true, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, + stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', }, - stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - }); + user, + ); expect(result).toBeDefined(); expect(result.privatePractitioners).toBeDefined(); @@ -273,37 +299,41 @@ describe('createCaseInteractor', () => { }); it('should create a case successfully with an "Attachment to Petition" document', async () => { - const result = await createCaseInteractor(applicationContext, { - attachmentToPetitionFileId: 'f09116b1-6a8c-4198-b661-0f06e9c6cbdc', - petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', - petitionMetadata: { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '99 South Oak Lane', - address2: 'Culpa numquam saepe ', - address3: 'Eaque voluptates com', - city: 'Dignissimos voluptat', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'petitioner1@example.com', - name: 'Diana Prince', - phone: '+1 (215) 128-6587', - postalCode: '69580', - state: 'AR', + const result = await createCaseInteractor( + applicationContext, + { + attachmentToPetitionFileId: 'f09116b1-6a8c-4198-b661-0f06e9c6cbdc', + petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', + petitionMetadata: { + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '99 South Oak Lane', + address2: 'Culpa numquam saepe ', + address3: 'Eaque voluptates com', + city: 'Dignissimos voluptat', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'petitioner1@example.com', + name: 'Diana Prince', + phone: '+1 (215) 128-6587', + postalCode: '69580', + state: 'AR', + }, + contactSecondary: {}, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.petitioner, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + preferredTrialCity: 'Fresno, California', + procedureType: 'Small', + signature: true, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, }, - contactSecondary: {}, - filingType: 'Myself', - hasIrsNotice: true, - partyType: PARTY_TYPES.petitioner, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - preferredTrialCity: 'Fresno, California', - procedureType: 'Small', - signature: true, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, + stinFileId: '96759830-8970-486f-916b-23439a8ebb70', }, - stinFileId: '96759830-8970-486f-916b-23439a8ebb70', - }); + user, + ); const atpDocketEntry = result.docketEntries.find( d => @@ -316,53 +346,58 @@ describe('createCaseInteractor', () => { it('should create a case with contact primary and secondary successfully as a practitioner', async () => { user = new PrivatePractitioner({ barNumber: 'BN1234', - name: 'Carole Baskin', + email: 'kb@example.com', + name: 'Karen Baskinostan', role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); - const result = await createCaseInteractor(applicationContext, { - corporateDisclosureFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', - petitionMetadata: { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '99 South Oak Lane', - address2: 'Culpa numquam saepe ', - address3: 'Eaque voluptates com', - city: 'Dignissimos voluptat', - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'petitioner1@example.com', - name: 'Diana Prince', - phone: '+1 (215) 128-6587', - postalCode: '69580', - state: 'AR', - }, - contactSecondary: { - address1: '99 South Oak Lane', - address2: 'Culpa numquam saepe ', - address3: 'Eaque voluptates com', - city: 'Dignissimos voluptat', - countryType: COUNTRY_TYPES.DOMESTIC, - name: 'Bob Prince', - phone: '+1 (215) 128-6587', - postalCode: '69580', - state: 'AR', + const result = await createCaseInteractor( + applicationContext, + { + corporateDisclosureFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', + petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', + petitionMetadata: { + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '99 South Oak Lane', + address2: 'Culpa numquam saepe ', + address3: 'Eaque voluptates com', + city: 'Dignissimos voluptat', + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'petitioner1@example.com', + name: 'Diana Prince', + phone: '+1 (215) 128-6587', + postalCode: '69580', + state: 'AR', + }, + contactSecondary: { + address1: '99 South Oak Lane', + address2: 'Culpa numquam saepe ', + address3: 'Eaque voluptates com', + city: 'Dignissimos voluptat', + countryType: COUNTRY_TYPES.DOMESTIC, + name: 'Bob Prince', + phone: '+1 (215) 128-6587', + postalCode: '69580', + state: 'AR', + }, + filingType: 'Myself and my spouse', + hasIrsNotice: true, + isSpouseDeceased: 'No', + partyType: PARTY_TYPES.petitionerSpouse, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + preferredTrialCity: 'Fresno, California', + procedureType: 'Small', + signature: true, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, }, - filingType: 'Myself and my spouse', - hasIrsNotice: true, - isSpouseDeceased: 'No', - partyType: PARTY_TYPES.petitionerSpouse, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - preferredTrialCity: 'Fresno, California', - procedureType: 'Small', - signature: true, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, + stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', }, - stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - }); + user, + ); expect(result).toBeDefined(); expect(result.privatePractitioners).toBeDefined(); @@ -381,58 +416,63 @@ describe('createCaseInteractor', () => { it('should set serviceIndicators for each petitioner on the case', async () => { user = new PrivatePractitioner({ barNumber: 'BN1234', - name: 'Carole Baskin', + email: 'kb@example.com', + name: 'Karen Baskinostan', role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); - const result = await createCaseInteractor(applicationContext, { - corporateDisclosureFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', - petitionMetadata: { - caseType: CASE_TYPES_MAP.other, - contactPrimary: { - address1: '99 South Oak Lane', - address2: 'Culpa numquam saepe ', - address3: 'Eaque voluptates com', - city: 'Dignissimos voluptat', - contactType: CONTACT_TYPES.primary, - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'petitioner1@example.com', - name: 'Diana Prince', - phone: '+1 (215) 128-6587', - postalCode: '69580', - serviceIndicator: undefined, - state: 'AR', - }, - contactSecondary: { - address1: '99 South Oak Lane', - address2: 'Culpa numquam saepe ', - address3: 'Eaque voluptates com', - city: 'Dignissimos voluptat', - contactType: CONTACT_TYPES.secondary, - countryType: COUNTRY_TYPES.DOMESTIC, - name: 'Bob Prince', - phone: '+1 (215) 128-6587', - postalCode: '69580', - serviceIndicator: undefined, - state: 'AR', + const result = await createCaseInteractor( + applicationContext, + { + corporateDisclosureFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', + petitionFileId: '413f62ce-d7c8-446e-aeda-14a2a625a626', + petitionMetadata: { + caseType: CASE_TYPES_MAP.other, + contactPrimary: { + address1: '99 South Oak Lane', + address2: 'Culpa numquam saepe ', + address3: 'Eaque voluptates com', + city: 'Dignissimos voluptat', + contactType: CONTACT_TYPES.primary, + countryType: COUNTRY_TYPES.DOMESTIC, + email: 'petitioner1@example.com', + name: 'Diana Prince', + phone: '+1 (215) 128-6587', + postalCode: '69580', + serviceIndicator: undefined, + state: 'AR', + }, + contactSecondary: { + address1: '99 South Oak Lane', + address2: 'Culpa numquam saepe ', + address3: 'Eaque voluptates com', + city: 'Dignissimos voluptat', + contactType: CONTACT_TYPES.secondary, + countryType: COUNTRY_TYPES.DOMESTIC, + name: 'Bob Prince', + phone: '+1 (215) 128-6587', + postalCode: '69580', + serviceIndicator: undefined, + state: 'AR', + }, + filedBy: 'Resp.', + filingType: 'Myself and my spouse', + hasIrsNotice: true, + isSpouseDeceased: 'No', + partyType: PARTY_TYPES.petitionerSpouse, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + preferredTrialCity: 'Fresno, California', + procedureType: 'Small', + signature: true, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, }, - filedBy: 'Resp.', - filingType: 'Myself and my spouse', - hasIrsNotice: true, - isSpouseDeceased: 'No', - partyType: PARTY_TYPES.petitionerSpouse, - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 1, - preferredTrialCity: 'Fresno, California', - procedureType: 'Small', - signature: true, - stinFile: new File([], 'test.pdf'), - stinFileSize: 1, + stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', }, - stinFileId: '413f62ce-7c8d-446e-aeda-14a2a625a611', - }); + user, + ); result.petitioners.forEach(p => { expect(p.serviceIndicator).not.toBeUndefined(); @@ -442,41 +482,46 @@ describe('createCaseInteractor', () => { it('should set serviceIndicator to none for petitioner when case is created by a private petitioner', async () => { user = new PrivatePractitioner({ barNumber: 'BN1234', - name: 'Carole Baskin', + email: 'kb@example.com', + name: 'Karen Baskinostan', role: ROLES.privatePractitioner, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }); - const result = await createCaseInteractor(applicationContext, { - petitionFileId: '6722d660-d241-45ad-b7b2-0326cbfee40d', - petitionMetadata: { - caseType: 'Deficiency', - contactPrimary: { - address1: '25 Second Lane', - address2: 'Adipisci qui et est ', - address3: 'Cumque reprehenderit', - city: 'Consequatur Iusto e', - countryType: 'domestic', - email: 'privatePractitioner@example.com', - name: 'Inez Martinez', - phone: '+1 (756) 271-3574', - postalCode: '68964', - state: 'VA', + const result = await createCaseInteractor( + applicationContext, + { + petitionFileId: '6722d660-d241-45ad-b7b2-0326cbfee40d', + petitionMetadata: { + caseType: 'Deficiency', + contactPrimary: { + address1: '25 Second Lane', + address2: 'Adipisci qui et est ', + address3: 'Cumque reprehenderit', + city: 'Consequatur Iusto e', + countryType: 'domestic', + email: 'privatePractitioner@example.com', + name: 'Inez Martinez', + phone: '+1 (756) 271-3574', + postalCode: '68964', + state: 'VA', + }, + contactSecondary: {}, + filingType: 'Individual petitioner', + hasIrsNotice: true, + partyType: 'Petitioner', + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 13264, + preferredTrialCity: 'Birmingham, Alabama', + procedureType: 'Regular', + stinFile: new File([], 'test.pdf'), + stinFileSize: 13264, + wizardStep: '5', }, - contactSecondary: {}, - filingType: 'Individual petitioner', - hasIrsNotice: true, - partyType: 'Petitioner', - petitionFile: new File([], 'test.pdf'), - petitionFileSize: 13264, - preferredTrialCity: 'Birmingham, Alabama', - procedureType: 'Regular', - stinFile: new File([], 'test.pdf'), - stinFileSize: 13264, - wizardStep: '5', - }, - stinFileId: 'e8bd0522-84ec-41fb-b490-0f4b8aa8a430', - } as any); + stinFileId: 'e8bd0522-84ec-41fb-b490-0f4b8aa8a430', + } as any, + user, + ); result.petitioners.forEach(p => { expect(p.serviceIndicator).toBe(SERVICE_INDICATOR_TYPES.SI_NONE); diff --git a/web-api/src/business/useCases/createCaseInteractor.ts b/web-api/src/business/useCases/createCaseInteractor.ts index 2317b7fe905..5b5928630f3 100644 --- a/web-api/src/business/useCases/createCaseInteractor.ts +++ b/web-api/src/business/useCases/createCaseInteractor.ts @@ -13,6 +13,7 @@ import { } from '../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { UserCase } from '../../../../shared/src/business/entities/UserCase'; import { UserRecord } from '@web-api/persistence/dynamo/dynamoTypes'; import { WorkItem } from '../../../../shared/src/business/entities/WorkItem'; @@ -55,16 +56,6 @@ const addPetitionDocketEntryToCase = ({ return workItemEntity; }; -/** - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.corporateDisclosureFileId the id of the corporate disclosure file - * @param {string} providers.petitionFileId the id of the petition file - * @param {object} providers.petitionMetadata the petition metadata - * @param {string} providers.stinFileId the id of the stin file - * @returns {object} the created case - */ export const createCaseInteractor = async ( applicationContext: ServerApplicationContext, { @@ -80,9 +71,8 @@ export const createCaseInteractor = async ( petitionMetadata: any; stinFileId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.PETITION)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/cases/createCaseLambda.ts b/web-api/src/lambdas/cases/createCaseLambda.ts index 715b791be7e..2dcf4814604 100644 --- a/web-api/src/lambdas/cases/createCaseLambda.ts +++ b/web-api/src/lambdas/cases/createCaseLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,13 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const createCaseLambda = event => +export const createCaseLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createCaseInteractor(applicationContext, { + return await applicationContext.getUseCases().createCaseInteractor( + applicationContext, + { ...JSON.parse(event.body), - }); + }, + authorizedUser, + ); }); diff --git a/web-api/src/persistence/dynamo/cases/docketNumberGenerator.ts b/web-api/src/persistence/dynamo/cases/docketNumberGenerator.ts index a041c7ce014..486ea7d8ff4 100644 --- a/web-api/src/persistence/dynamo/cases/docketNumberGenerator.ts +++ b/web-api/src/persistence/dynamo/cases/docketNumberGenerator.ts @@ -71,7 +71,7 @@ export const createDocketNumber = async ({ receivedAt, }: { applicationContext: IApplicationContext; - receivedAt: string; + receivedAt?: string; }) => { const year = receivedAt ? formatDateString(receivedAt, FORMATS.YEAR) From e6cc645d9f378811a3610d3b69ad2ead120b15a1 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 18 Jul 2024 14:59:03 -0400 Subject: [PATCH 257/523] 10417 rm getCurrentUser from formattedMessageDetail and setUserPermissionsAction --- .../presenter/actions/setUserPermissionsAction.test.ts | 5 ----- .../src/presenter/actions/setUserPermissionsAction.ts | 9 ++++----- .../presenter/computeds/formattedMessageDetail.test.ts | 10 ++++++++++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/web-client/src/presenter/actions/setUserPermissionsAction.test.ts b/web-client/src/presenter/actions/setUserPermissionsAction.test.ts index a155b3449bb..461b59b7027 100644 --- a/web-client/src/presenter/actions/setUserPermissionsAction.test.ts +++ b/web-client/src/presenter/actions/setUserPermissionsAction.test.ts @@ -1,6 +1,5 @@ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; -import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { presenter } from '../presenter-mock'; import { runAction } from '@web-client/presenter/test.cerebral'; import { setUserPermissionsAction } from './setUserPermissionsAction'; @@ -13,10 +12,6 @@ describe('setUserPermissionsAction', () => { }); it('set state.permissions based on the user role', async () => { - applicationContext.getCurrentUserPermissions.mockReturnValue( - getUserPermissions(mockUser), - ); - const result = await runAction(setUserPermissionsAction, { modules: { presenter, diff --git a/web-client/src/presenter/actions/setUserPermissionsAction.ts b/web-client/src/presenter/actions/setUserPermissionsAction.ts index 3f629a4d7c0..c14b42636fe 100644 --- a/web-client/src/presenter/actions/setUserPermissionsAction.ts +++ b/web-client/src/presenter/actions/setUserPermissionsAction.ts @@ -1,3 +1,4 @@ +import { getUserPermissions } from '@shared/authorization/getUserPermissions'; import { state } from '@web-client/presenter/app.cerebral'; /** @@ -6,10 +7,8 @@ import { state } from '@web-client/presenter/app.cerebral'; * @param {object} providers.applicationContext the application context * @param {object} providers.store the cerebral store object */ -export const setUserPermissionsAction = ({ - applicationContext, - store, -}: ActionProps) => { - const userPermissions = applicationContext.getCurrentUserPermissions(); +export const setUserPermissionsAction = ({ get, store }: ActionProps) => { + const user = get(state.user); + const userPermissions = getUserPermissions(user); store.set(state.permissions, userPermissions); }; diff --git a/web-client/src/presenter/computeds/formattedMessageDetail.test.ts b/web-client/src/presenter/computeds/formattedMessageDetail.test.ts index 3e20bcd78c8..f9bec7135f7 100644 --- a/web-client/src/presenter/computeds/formattedMessageDetail.test.ts +++ b/web-client/src/presenter/computeds/formattedMessageDetail.test.ts @@ -56,6 +56,7 @@ describe('formattedMessageDetail', () => { messageId: '98a9dbc4-a8d1-459b-98b2-30235b596d70', }, ], + user: { ...generalUser }, }, }); @@ -105,6 +106,7 @@ describe('formattedMessageDetail', () => { messageId: '98a9dbc4-a8d1-459b-98b2-30235b596d70', }, ], + user: { ...generalUser }, }, }); @@ -139,6 +141,7 @@ describe('formattedMessageDetail', () => { { attachments: [], createdAt: '2019-03-01T21:40:46.415Z' }, { attachments: [], createdAt: '2019-04-01T21:40:46.415Z' }, ], + user: { ...generalUser }, }, }); @@ -152,6 +155,7 @@ describe('formattedMessageDetail', () => { messageDetail: [ { attachments: [], createdAt: '2019-03-01T21:40:46.415Z' }, ], + user: { ...generalUser }, }, }); @@ -168,6 +172,7 @@ describe('formattedMessageDetail', () => { { attachments: [], createdAt: '2019-03-01T21:40:46.415Z' }, { attachments: [], createdAt: '2019-04-01T21:40:46.415Z' }, ], + user: { ...generalUser }, }, }); @@ -183,6 +188,7 @@ describe('formattedMessageDetail', () => { { attachments: [], createdAt: '2019-03-01T21:40:46.415Z' }, { attachments: [], createdAt: '2019-04-01T21:40:46.415Z' }, ], + user: { ...generalUser }, }, }); @@ -213,6 +219,7 @@ describe('formattedMessageDetail', () => { messageId: '98a9dbc4-a8d1-459b-98b2-30235b596d70', }, ], + user: { ...generalUser }, }, }); @@ -273,6 +280,7 @@ describe('formattedMessageDetail', () => { createdAt: '2019-03-01T21:40:46.415Z', }, ], + user: { ...generalUser }, }, }); @@ -308,6 +316,7 @@ describe('formattedMessageDetail', () => { createdAt: '2019-03-01T21:40:46.415Z', }, ], + user: { ...generalUser }, }, }); @@ -339,6 +348,7 @@ describe('formattedMessageDetail', () => { createdAt: '2019-03-01T21:40:46.415Z', }, ], + user: { ...generalUser }, }, }); From b9bad9683a206b0d0b5bc3eac12eca4e9ab37950 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 18 Jul 2024 15:36:15 -0400 Subject: [PATCH 258/523] 10417 add user to cerbralTest --- .../sequences/gotoTrialSessionDetailSequence.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web-client/src/presenter/sequences/gotoTrialSessionDetailSequence.test.ts b/web-client/src/presenter/sequences/gotoTrialSessionDetailSequence.test.ts index 7a13191651a..9f9d36bfc6f 100644 --- a/web-client/src/presenter/sequences/gotoTrialSessionDetailSequence.test.ts +++ b/web-client/src/presenter/sequences/gotoTrialSessionDetailSequence.test.ts @@ -1,5 +1,6 @@ import { CerebralTest } from 'cerebral/test'; import { MOCK_TRIAL_INPERSON } from '../../../../shared/src/test/mockTrial'; +import { ROLES } from '@shared/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { gotoTrialSessionDetailSequence } from '../sequences/gotoTrialSessionDetailSequence'; import { presenter } from '../presenter-mock'; @@ -17,6 +18,11 @@ describe('gotoTrialSessionDetailSequence', () => { cerebralTest = CerebralTest(presenter); //set token to take 'isLoggedIn' path cerebralTest.setState('token', 'a'); + cerebralTest.setState('user', { + name: 'richard', + role: ROLES.petitioner, + userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', + }); }); it('should set up state for an uncalendared session with eligible cases and case order', async () => { From 3f0af35b3e9d0ffb55303f51b3013f74ab3dfcab Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 13:25:44 -0700 Subject: [PATCH 259/523] 10417: remove appcontext.getCurrentUser from createCsvCustomCaseReportFileInteractor --- ...eCsvCustomCaseReportFileInteractor.test.ts | 34 ++++++++++++------- ...createCsvCustomCaseReportFileInteractor.ts | 4 +-- .../createCsvCustomCaseReportFileLambda.ts | 7 +++- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.test.ts b/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.test.ts index ece7a54be42..0eac3179977 100644 --- a/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.test.ts +++ b/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.test.ts @@ -1,9 +1,9 @@ import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createCsvCustomCaseReportFileInteractor } from '@web-api/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor'; import { - docketClerkUser, - privatePractitionerUser, -} from '@shared/test/mockUsers'; + mockDocketClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('createCsvCustomCaseReportFileInteractor', () => { const DEFAULT_PARAMS = { @@ -21,9 +21,9 @@ describe('createCsvCustomCaseReportFileInteractor', () => { } as any; beforeEach(() => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(docketClerkUser); + // applicationContext.getCurrentUser = jest + // .fn() + // .mockReturnValue(docketClerkUser); applicationContext.getNotificationGateway().sendNotificationToUser = jest .fn() @@ -63,6 +63,7 @@ describe('createCsvCustomCaseReportFileInteractor', () => { await createCsvCustomCaseReportFileInteractor( applicationContext, DEFAULT_PARAMS, + mockDocketClerkUser, ); const sendNotificationCalls = @@ -105,14 +106,15 @@ describe('createCsvCustomCaseReportFileInteractor', () => { }); it('should throw an error if a user is not authorized', async () => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(privatePractitionerUser); + // applicationContext.getCurrentUser = jest + // .fn() + // .mockReturnValue(privatePractitionerUser); await expect( createCsvCustomCaseReportFileInteractor( applicationContext, DEFAULT_PARAMS, + mockPrivatePractitionerUser, ), ).rejects.toThrow('Unauthorized'); }); @@ -122,10 +124,14 @@ describe('createCsvCustomCaseReportFileInteractor', () => { .fn() .mockImplementation(callback => callback()); - await createCsvCustomCaseReportFileInteractor(applicationContext, { - ...DEFAULT_PARAMS, - totalCount: 100000, - }); + await createCsvCustomCaseReportFileInteractor( + applicationContext, + { + ...DEFAULT_PARAMS, + totalCount: 100000, + }, + mockDocketClerkUser, + ); expect(applicationContext.setTimeout).toHaveBeenCalledTimes(1); }); @@ -151,6 +157,7 @@ describe('createCsvCustomCaseReportFileInteractor', () => { await createCsvCustomCaseReportFileInteractor( applicationContext, DEFAULT_PARAMS, + mockDocketClerkUser, ); const saveFileAndGenerateUrlCalls = @@ -188,6 +195,7 @@ describe('createCsvCustomCaseReportFileInteractor', () => { await createCsvCustomCaseReportFileInteractor( applicationContext, DEFAULT_PARAMS, + mockDocketClerkUser, ); const saveFileAndGenerateUrlCalls = diff --git a/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.ts b/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.ts index 98a7d53ffab..c2437f63dd0 100644 --- a/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.ts +++ b/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.ts @@ -12,6 +12,7 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { stringify } from 'csv-stringify/sync'; export type CustomCaseReportCsvRequest = CustomCaseReportFilters & { @@ -34,9 +35,8 @@ export const createCsvCustomCaseReportFileInteractor = async ( startDate, totalCount, }: CustomCaseReportCsvRequest, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_INVENTORY_REPORT)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/reports/createCsvCustomCaseReportFileLambda.ts b/web-api/src/lambdas/reports/createCsvCustomCaseReportFileLambda.ts index 85e38b90b1d..eb075a1fc4f 100644 --- a/web-api/src/lambdas/reports/createCsvCustomCaseReportFileLambda.ts +++ b/web-api/src/lambdas/reports/createCsvCustomCaseReportFileLambda.ts @@ -1,11 +1,16 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -export const createCsvCustomCaseReportFileLambda = event => +export const createCsvCustomCaseReportFileLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() .createCsvCustomCaseReportFileInteractor( applicationContext, JSON.parse(event.body), + authorizedUser, ); }); From d54b228408f1c42c17dee3d9daf6a8aee2a1d0c6 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 18 Jul 2024 16:33:10 -0400 Subject: [PATCH 260/523] 10417 fix tests for gotoDashboardSequence --- .../src/presenter/actions/setUserPermissionsAction.ts | 1 + .../presenter/sequences/gotoDashboardSequence.test.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/web-client/src/presenter/actions/setUserPermissionsAction.ts b/web-client/src/presenter/actions/setUserPermissionsAction.ts index c14b42636fe..2542f4a44f8 100644 --- a/web-client/src/presenter/actions/setUserPermissionsAction.ts +++ b/web-client/src/presenter/actions/setUserPermissionsAction.ts @@ -10,5 +10,6 @@ import { state } from '@web-client/presenter/app.cerebral'; export const setUserPermissionsAction = ({ get, store }: ActionProps) => { const user = get(state.user); const userPermissions = getUserPermissions(user); + console.debug('userPermissions:', userPermissions); store.set(state.permissions, userPermissions); }; diff --git a/web-client/src/presenter/sequences/gotoDashboardSequence.test.ts b/web-client/src/presenter/sequences/gotoDashboardSequence.test.ts index b9226c1d50c..51081d8f941 100644 --- a/web-client/src/presenter/sequences/gotoDashboardSequence.test.ts +++ b/web-client/src/presenter/sequences/gotoDashboardSequence.test.ts @@ -1,6 +1,7 @@ import { CerebralTest } from 'cerebral/test'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { gotoDashboardSequence } from '../sequences/gotoDashboardSequence'; +import { petitionerUser } from '@shared/test/mockUsers'; import { presenter } from '../presenter-mock'; describe('gotoDashboardSequence', () => { @@ -26,10 +27,19 @@ describe('gotoDashboardSequence', () => { //set token to take 'isLoggedIn' path cerebralTest.setState('token', 'a'); + cerebralTest.setState('user', { + email: 'richard@e.mail', + name: 'richard', + role: petitionerUser.role, + userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', + }); }); it('should set up state for petitioner going to dashboard', async () => { + console.debug('Before runSequence'); await cerebralTest.runSequence('gotoDashboardSequence'); + const cerebralTestState = cerebralTest.getState(); + console.debug('cerebralTestState:', cerebralTestState); expect(cerebralTest.getState()).toMatchObject({ closedCases, From a5d150faf288190cb402d187484c876be89f1121 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 18 Jul 2024 16:44:21 -0400 Subject: [PATCH 261/523] 10417 fix gotoStartCaseWizardSequence --- .../authorization/authorizationClientService.ts | 1 - .../presenter/actions/setUserPermissionsAction.ts | 1 - .../computeds/caseInformationHelper.test.ts | 3 --- .../sequences/gotoDashboardSequence.test.ts | 3 --- .../sequences/gotoStartCaseWizardSequence.test.ts | 14 ++++---------- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/shared/src/authorization/authorizationClientService.ts b/shared/src/authorization/authorizationClientService.ts index 554c94f059a..6fc7e1d8144 100644 --- a/shared/src/authorization/authorizationClientService.ts +++ b/shared/src/authorization/authorizationClientService.ts @@ -350,7 +350,6 @@ export const isAuthorized = ( owner?: string, ): user is AuthUser => { if (!isAuthUser(user)) { - console.debug('User is not authenticated'); return false; } diff --git a/web-client/src/presenter/actions/setUserPermissionsAction.ts b/web-client/src/presenter/actions/setUserPermissionsAction.ts index 2542f4a44f8..c14b42636fe 100644 --- a/web-client/src/presenter/actions/setUserPermissionsAction.ts +++ b/web-client/src/presenter/actions/setUserPermissionsAction.ts @@ -10,6 +10,5 @@ import { state } from '@web-client/presenter/app.cerebral'; export const setUserPermissionsAction = ({ get, store }: ActionProps) => { const user = get(state.user); const userPermissions = getUserPermissions(user); - console.debug('userPermissions:', userPermissions); store.set(state.permissions, userPermissions); }; diff --git a/web-client/src/presenter/computeds/caseInformationHelper.test.ts b/web-client/src/presenter/computeds/caseInformationHelper.test.ts index e77f76c3edd..155f964c563 100644 --- a/web-client/src/presenter/computeds/caseInformationHelper.test.ts +++ b/web-client/src/presenter/computeds/caseInformationHelper.test.ts @@ -101,7 +101,6 @@ describe('caseInformationHelper', () => { }); it('should be true when the user is an internal user with permissions to edit counsel', () => { - let state = getBaseState(mockDocketClerk); const result = runCompute(caseInformationHelper, { state: { ...getBaseState(mockDocketClerk), @@ -112,8 +111,6 @@ describe('caseInformationHelper', () => { }, }); - console.debug('********************', state); - expect(result.showAddCounsel).toEqual(true); }); diff --git a/web-client/src/presenter/sequences/gotoDashboardSequence.test.ts b/web-client/src/presenter/sequences/gotoDashboardSequence.test.ts index 51081d8f941..3319a692933 100644 --- a/web-client/src/presenter/sequences/gotoDashboardSequence.test.ts +++ b/web-client/src/presenter/sequences/gotoDashboardSequence.test.ts @@ -36,10 +36,7 @@ describe('gotoDashboardSequence', () => { }); it('should set up state for petitioner going to dashboard', async () => { - console.debug('Before runSequence'); await cerebralTest.runSequence('gotoDashboardSequence'); - const cerebralTestState = cerebralTest.getState(); - console.debug('cerebralTestState:', cerebralTestState); expect(cerebralTest.getState()).toMatchObject({ closedCases, diff --git a/web-client/src/presenter/sequences/gotoStartCaseWizardSequence.test.ts b/web-client/src/presenter/sequences/gotoStartCaseWizardSequence.test.ts index b3c987c06ba..0c5650b428f 100644 --- a/web-client/src/presenter/sequences/gotoStartCaseWizardSequence.test.ts +++ b/web-client/src/presenter/sequences/gotoStartCaseWizardSequence.test.ts @@ -1,10 +1,8 @@ import { CerebralTest } from 'cerebral/test'; -import { - DEFAULT_PROCEDURE_TYPE, - ROLES, -} from '../../../../shared/src/business/entities/EntityConstants'; +import { DEFAULT_PROCEDURE_TYPE } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { gotoStartCaseWizardSequence } from '../sequences/gotoStartCaseWizardSequence'; +import { petitionerUser, petitionsClerkUser } from '@shared/test/mockUsers'; import { presenter } from '../presenter-mock'; describe('gotoStartCaseWizardSequence', () => { @@ -19,9 +17,7 @@ describe('gotoStartCaseWizardSequence', () => { }); it('should set up state for an internal user going to start case form', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - }); + cerebralTest.setState('user', petitionsClerkUser); await cerebralTest.runSequence('gotoStartCaseWizardSequence'); @@ -44,9 +40,7 @@ describe('gotoStartCaseWizardSequence', () => { }); it('should set up state for an external user going to start case form', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - }); + cerebralTest.setState('user', petitionerUser); await cerebralTest.runSequence('gotoStartCaseWizardSequence'); From 1814491d547516a8a36b1f1bd7cb1e403bb07590 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 18 Jul 2024 16:54:06 -0400 Subject: [PATCH 262/523] 10417 fix gotoTrialSessionWorkingCopySequence --- .../gotoTrialSessionWorkingCopySequence.test.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/web-client/src/presenter/sequences/gotoTrialSessionWorkingCopySequence.test.ts b/web-client/src/presenter/sequences/gotoTrialSessionWorkingCopySequence.test.ts index 1f321957627..da0486350c4 100644 --- a/web-client/src/presenter/sequences/gotoTrialSessionWorkingCopySequence.test.ts +++ b/web-client/src/presenter/sequences/gotoTrialSessionWorkingCopySequence.test.ts @@ -1,15 +1,13 @@ import { CerebralTest } from 'cerebral/test'; -import { - ROLES, - TRIAL_SESSION_PROCEEDING_TYPES, -} from '../../../../shared/src/business/entities/EntityConstants'; +import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { gotoTrialSessionWorkingCopySequence } from '../sequences/gotoTrialSessionWorkingCopySequence'; +import { judgeUser } from '@shared/test/mockUsers'; import { presenter } from '../presenter-mock'; describe('gotoTrialSessionWorkingCopySequence', () => { const mockTrialSessionId = '2f731ada-0276-4eca-b518-cfedc4c496d9'; - const mockJudgeUserId = '42e55e43-2cc2-4266-96ed-8cc0400ff1ce'; + const mockJudgeUserId = judgeUser.userId; const mockTrialSession = { judge: { @@ -46,14 +44,10 @@ describe('gotoTrialSessionWorkingCopySequence', () => { //set token to take 'isLoggedIn' path cerebralTest.setState('token', 'a'); + cerebralTest.setState('user', judgeUser); }); it('should set up state for a user associated with the trial session', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.judge, - userId: mockJudgeUserId, - }); - applicationContext .getUseCases() .getTrialSessionDetailsInteractor.mockReturnValue(mockTrialSession); From 99f0f147030f190e2bc385a6d28ac5800f8cdc54 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 13:56:41 -0700 Subject: [PATCH 263/523] 10417: remove appcontext.getCurrentUser from addPaperFilingInteractor --- .../addPaperFilingInteractor.test.ts | 476 ++++++++++-------- .../docketEntry/addPaperFilingInteractor.ts | 4 +- .../lambdas/documents/addPaperFilingLambda.ts | 13 +- 3 files changed, 282 insertions(+), 211 deletions(-) diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.test.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.test.ts index 6464ac80545..cfb79801fa3 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.test.ts @@ -9,9 +9,11 @@ import { MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE, MOCK_LEAD_CASE_WITH_PAPER_SERVICE, } from '../../../../../shared/src/test/mockCase'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { addPaperFilingInteractor } from './addPaperFilingInteractor'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('addPaperFilingInteractor', () => { const mockClientConnectionId = '987654'; @@ -33,8 +35,6 @@ describe('addPaperFilingInteractor', () => { isSavingForLater: false, }; - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); @@ -45,10 +45,12 @@ describe('addPaperFilingInteractor', () => { }); it('should throw an error when the user is not authorized to add a paper filing', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - addPaperFilingInteractor(applicationContext, defaultParamaters), + addPaperFilingInteractor( + applicationContext, + defaultParamaters, + {} as UnknownAuthUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -56,7 +58,11 @@ describe('addPaperFilingInteractor', () => { defaultParamaters.docketEntryId = undefined as any; await expect( - addPaperFilingInteractor(applicationContext, defaultParamaters), + addPaperFilingInteractor( + applicationContext, + defaultParamaters, + mockDocketClerkUser, + ), ).rejects.toThrow('Did not receive a docketEntryId'); }); @@ -64,28 +70,36 @@ describe('addPaperFilingInteractor', () => { defaultParamaters.documentMetadata = undefined as any; await expect( - addPaperFilingInteractor(applicationContext, defaultParamaters), + addPaperFilingInteractor( + applicationContext, + defaultParamaters, + mockDocketClerkUser, + ), ).rejects.toThrow('Did not receive meta data for docket entry'); }); it('should add documents and send service emails for electronic service parties', async () => { const mockdocketEntryId = 'c54ba5a9-b37b-479d-9201-067ec6e335bb'; - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: mockdocketEntryId, - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: mockdocketEntryId, + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().putWorkItemInUsersOutbox, @@ -114,21 +128,25 @@ describe('addPaperFilingInteractor', () => { pdfUrl: mockPdfUrl, }); - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -152,23 +170,27 @@ describe('addPaperFilingInteractor', () => { pdfUrl: mockPdfUrl, }); - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [ - MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, - ], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [ + MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, + ], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -177,21 +199,25 @@ describe('addPaperFilingInteractor', () => { }); it('should add documents and workItem to inbox when saving for later when a document is attached', async () => { - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: true, }, - isSavingForLater: true, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().putWorkItemInUsersOutbox, @@ -209,21 +235,25 @@ describe('addPaperFilingInteractor', () => { }); it('should add documents and workItem to inbox when saving for later when a document is NOT attached', async () => { - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: false, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: false, + isPaper: true, + }, + isSavingForLater: true, }, - isSavingForLater: true, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -241,21 +271,25 @@ describe('addPaperFilingInteractor', () => { }); it('should add workItem to the user outbox when NOT saving for later if a document is attached', async () => { - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: undefined as any, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: undefined as any, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().putWorkItemInUsersOutbox.mock @@ -267,22 +301,26 @@ describe('addPaperFilingInteractor', () => { }); it('sets the case as blocked if the document filed is a tracked document type', async () => { - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - category: 'Application', - docketNumber: mockCase.docketNumber, - documentTitle: 'Application for Examination Pursuant to Rule 73', - documentType: 'Application for Examination Pursuant to Rule 73', - eventCode: 'AFE', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + category: 'Application', + docketNumber: mockCase.docketNumber, + documentTitle: 'Application for Examination Pursuant to Rule 73', + documentType: 'Application for Examination Pursuant to Rule 73', + eventCode: 'AFE', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -308,22 +346,26 @@ describe('addPaperFilingInteractor', () => { { deadline: 'something' }, ]); - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - category: 'Application', - docketNumber: mockCase.docketNumber, - documentTitle: 'Application for Examination Pursuant to Rule 73', - documentType: 'Application for Examination Pursuant to Rule 73', - eventCode: 'AFE', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + category: 'Application', + docketNumber: mockCase.docketNumber, + documentTitle: 'Application for Examination Pursuant to Rule 73', + documentType: 'Application for Examination Pursuant to Rule 73', + eventCode: 'AFE', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -348,7 +390,36 @@ describe('addPaperFilingInteractor', () => { .updateCase.mockRejectedValueOnce(new Error('bad!')); await expect( - addPaperFilingInteractor(applicationContext, { + addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: false, + }, + mockDocketClerkUser, + ), + ).rejects.toThrow(new Error('bad!')); + + expect( + applicationContext.getUseCaseHelpers().serveDocumentAndGetPaperServicePdf, + ).not.toHaveBeenCalled(); + }); + + it('should use original case caption to create case title when creating work item', async () => { + await addPaperFilingInteractor( + applicationContext, + { clientConnectionId: mockClientConnectionId, consolidatedGroupDocketNumbers: [], docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', @@ -361,31 +432,10 @@ describe('addPaperFilingInteractor', () => { isFileAttached: true, isPaper: true, }, - isSavingForLater: false, - }), - ).rejects.toThrow(new Error('bad!')); - - expect( - applicationContext.getUseCaseHelpers().serveDocumentAndGetPaperServicePdf, - ).not.toHaveBeenCalled(); - }); - - it('should use original case caption to create case title when creating work item', async () => { - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + isSavingForLater: true, }, - isSavingForLater: true, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem.mock.calls[0][0] @@ -396,21 +446,25 @@ describe('addPaperFilingInteractor', () => { }); it('should send a serve_document_complete notification with a success message when all document processing has completed', async () => { - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: true, }, - isSavingForLater: true, - }); + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -429,21 +483,25 @@ describe('addPaperFilingInteractor', () => { }); it('should send a serve_document_complete notification with generateCoversheet true when the docket entry has a file attached and the user is NOT saving for later', async () => { - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -452,21 +510,25 @@ describe('addPaperFilingInteractor', () => { }); it('should send a serve_document_complete notification with generateCoversheet false when the docket entry does NOT have a file attached', async () => { - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filedBy: 'Test Petitioner', - isFileAttached: false, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filedBy: 'Test Petitioner', + isFileAttached: false, + isPaper: true, + }, + isSavingForLater: true, }, - isSavingForLater: true, - }); + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -502,6 +564,7 @@ describe('addPaperFilingInteractor', () => { await addPaperFilingInteractor( applicationContext, mockConsolidatedGroupRequest, + mockDocketClerkUser, ); expect( @@ -524,6 +587,7 @@ describe('addPaperFilingInteractor', () => { await addPaperFilingInteractor( applicationContext, mockConsolidatedGroupRequest, + mockDocketClerkUser, ); expect( @@ -536,21 +600,25 @@ describe('addPaperFilingInteractor', () => { it('should pass in an empty array for electronicParties when calling "serveDocumentAndGetPaperServicePdf" when dealing with ATP docket entry', async () => { const mockdocketEntryId = 'c54ba5a9-b37b-479d-9201-067ec6e335bb'; - await addPaperFilingInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - consolidatedGroupDocketNumbers: [], - docketEntryId: mockdocketEntryId, - documentMetadata: { - docketNumber: mockCase.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'ATP', - filedBy: 'Test Petitioner', - isFileAttached: true, - isPaper: true, + await addPaperFilingInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + consolidatedGroupDocketNumbers: [], + docketEntryId: mockdocketEntryId, + documentMetadata: { + docketNumber: mockCase.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'ATP', + filedBy: 'Test Petitioner', + isFileAttached: true, + isPaper: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().serveDocumentAndGetPaperServicePdf, diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts index 2cf9857c7b4..1eea5b9ad40 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts @@ -14,6 +14,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -44,9 +45,8 @@ export const addPaperFiling = async ( isSavingForLater: boolean; docketEntryId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/documents/addPaperFilingLambda.ts b/web-api/src/lambdas/documents/addPaperFilingLambda.ts index 0baf72a6173..b15e5f6c58b 100644 --- a/web-api/src/lambdas/documents/addPaperFilingLambda.ts +++ b/web-api/src/lambdas/documents/addPaperFilingLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,13 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const addPaperFilingLambda = event => +export const addPaperFilingLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .addPaperFilingInteractor(applicationContext, { + return await applicationContext.getUseCases().addPaperFilingInteractor( + applicationContext, + { ...JSON.parse(event.body), - }); + }, + authorizedUser, + ); }); From 50ad430e09ec58b21243a7c5ff0f00fc18c7218d Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 13:58:07 -0700 Subject: [PATCH 264/523] 10417: comment cleanup --- .../useCases/docketEntry/addPaperFilingInteractor.ts | 11 ----------- web-api/src/lambdas/documents/addPaperFilingLambda.ts | 6 ------ 2 files changed, 17 deletions(-) diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts index 1eea5b9ad40..29def819c2d 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts @@ -19,17 +19,6 @@ import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -/** - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.clientConnectionId the client connection Id - * @param {string} providers.docketEntryId the id of the docket entry to add - * @param {object} providers.consolidatedGroupDocketNumbers the docket numbers from the consolidated group - * @param {object} providers.documentMetadata the document metadata - * @param {boolean} providers.isSavingForLater flag for saving docket entry for later instead of serving it - * @returns {object} the updated case after the documents are added - */ export const addPaperFiling = async ( applicationContext: ServerApplicationContext, { diff --git a/web-api/src/lambdas/documents/addPaperFilingLambda.ts b/web-api/src/lambdas/documents/addPaperFilingLambda.ts index b15e5f6c58b..0fa6a9556cf 100644 --- a/web-api/src/lambdas/documents/addPaperFilingLambda.ts +++ b/web-api/src/lambdas/documents/addPaperFilingLambda.ts @@ -1,12 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * lambda used for adding a paper filing to a case - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ export const addPaperFilingLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext.getUseCases().addPaperFilingInteractor( From acc8833883e9a07f6e0ba2374192ac4ac518558b Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 18 Jul 2024 17:04:03 -0400 Subject: [PATCH 265/523] 10417 fix reportMenuHelper --- shared/src/test/mockUsers.ts | 1 + .../computeds/reportMenuHelper.test.ts | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/shared/src/test/mockUsers.ts b/shared/src/test/mockUsers.ts index ffff42a6ac1..0b3eb78828a 100644 --- a/shared/src/test/mockUsers.ts +++ b/shared/src/test/mockUsers.ts @@ -33,6 +33,7 @@ export const adcUser = { }; export const colvinsChambersUser = { + email: 'chambers@e.mail', name: 'Chandler Chambers', role: ROLES.chambers, section: getJudgesChambers().COLVINS_CHAMBERS_SECTION.section, diff --git a/web-client/src/presenter/computeds/reportMenuHelper.test.ts b/web-client/src/presenter/computeds/reportMenuHelper.test.ts index db75f3a853c..3638d2346a3 100644 --- a/web-client/src/presenter/computeds/reportMenuHelper.test.ts +++ b/web-client/src/presenter/computeds/reportMenuHelper.test.ts @@ -1,5 +1,9 @@ -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { + colvinsChambersUser, + judgeUser, + petitionsClerkUser, +} from '@shared/test/mockUsers'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { reportMenuHelper as reportMenuHeaderComputed } from './reportMenuHelper'; import { runCompute } from '@web-client/presenter/test.cerebral'; @@ -16,13 +20,14 @@ describe('reportMenuHelper', () => { return { currentPage: 'CaseDetailInternal', permissions: getUserPermissions(user), + user, }; }; describe('showActivityReport', () => { it('should be true when the current user is a judge user', () => { const result = runCompute(reportMenuHelper, { - state: getBaseState({ role: ROLES.judge }), + state: getBaseState(judgeUser), }); expect(result.showActivityReport).toBeTruthy(); @@ -30,7 +35,7 @@ describe('reportMenuHelper', () => { it('should be true when the current user is a chambers user', () => { const result = runCompute(reportMenuHelper, { - state: getBaseState({ role: ROLES.chambers }), + state: getBaseState(colvinsChambersUser), }); expect(result.showActivityReport).toBeTruthy(); @@ -38,7 +43,7 @@ describe('reportMenuHelper', () => { it('should be false when the current user is NOT a judge or chambers user', () => { const result = runCompute(reportMenuHelper, { - state: getBaseState({ role: ROLES.petitionsClerk }), + state: getBaseState(petitionsClerkUser), }); expect(result.showActivityReport).toBeFalsy(); @@ -60,7 +65,7 @@ describe('reportMenuHelper', () => { it('should show a border under the Reports tab to indicate it is the active tab when the current page is Case Deadlines Report', () => { const result = runCompute(reportMenuHelper, { state: { - ...getBaseState({ role: ROLES.petitionsClerk }), + ...getBaseState(petitionsClerkUser), currentPage: 'CaseDeadlines', }, }); @@ -71,7 +76,7 @@ describe('reportMenuHelper', () => { it('should show a border under the Reports tab to indicate it is the active tab when the current page is the Blocked Cases Report', () => { const result = runCompute(reportMenuHelper, { state: { - ...getBaseState({ role: ROLES.petitionsClerk }), + ...getBaseState(petitionsClerkUser), currentPage: 'BlockedCasesReport', }, }); From 87c05d0bdf58945a075e2e8536166261c1eab0ff Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 18 Jul 2024 17:13:39 -0400 Subject: [PATCH 266/523] 10417 fix advancedSearchHelper --- .../computeds/AdvancedSearch/advancedSearchHelper.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.ts b/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.ts index f1f4be9a917..5ee1a32698d 100644 --- a/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.ts +++ b/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.ts @@ -3,6 +3,7 @@ import { paginationHelper, } from './advancedSearchHelper'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { docketClerk1User } from '@shared/test/mockUsers'; import { getUserPermissions } from '../../../../../shared/src/authorization/getUserPermissions'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../../withAppContext'; @@ -18,6 +19,7 @@ describe('advancedSearchHelper', () => { const getBaseState = user => { return { permissions: getUserPermissions(user), + user, }; }; @@ -50,10 +52,7 @@ describe('advancedSearchHelper', () => { }; beforeEach(() => { - globalUser = { - role: USER_ROLES.docketClerk, - userId: 'docketClerk', - }; + globalUser = docketClerk1User; }); it('returns appropriate defaults if permissions are not defined in state', () => { From 7f33eb29eb786fadceddd3d9657fb393d902590f Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 14:30:09 -0700 Subject: [PATCH 267/523] 10417: missed a portion of addPaperFilingInteractor that used getCurrentUser --- .../addPaperFilingInteractor.locking.test.ts | 38 ++++++++++++++----- .../docketEntry/addPaperFilingInteractor.ts | 10 +++-- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.locking.test.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.locking.test.ts index fc305fef91a..52bd17e66e9 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.locking.test.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.locking.test.ts @@ -49,9 +49,9 @@ describe('handleLockError', () => { .getUserById.mockReturnValue(docketClerkUser); }); - it('should determine who the user is based on applicationContext', async () => { - await handleLockError(applicationContext, { foo: 'bar' }); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); + it('should determine who the user is based on method arg, not applicationContext', async () => { + await handleLockError(applicationContext, { foo: 'bar' }, docketClerkUser); + expect(applicationContext.getCurrentUser).not.toHaveBeenCalled(); }); it('should send a notification to the user with "retry_async_request" and the originalRequest', async () => { @@ -59,7 +59,11 @@ describe('handleLockError', () => { clientConnectionId: mockClientConnectionId, foo: 'bar', }; - await handleLockError(applicationContext, mockOriginalRequest); + await handleLockError( + applicationContext, + mockOriginalRequest, + docketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -99,8 +103,6 @@ describe('addPaperFilingInteractor', () => { beforeEach(() => { mockLock = undefined; // unlocked - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); @@ -117,7 +119,11 @@ describe('addPaperFilingInteractor', () => { it('should throw a ServiceUnavailableError if a Case is currently locked', async () => { await expect( - addPaperFilingInteractor(applicationContext, mockRequest), + addPaperFilingInteractor( + applicationContext, + mockRequest, + docketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -127,7 +133,11 @@ describe('addPaperFilingInteractor', () => { it('should return a "retry_async_request" notification with the original request', async () => { await expect( - addPaperFilingInteractor(applicationContext, mockRequest), + addPaperFilingInteractor( + applicationContext, + mockRequest, + docketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -155,7 +165,11 @@ describe('addPaperFilingInteractor', () => { }); it('should acquire a lock that lasts for 15 minutes', async () => { - await addPaperFilingInteractor(applicationContext, mockRequest); + await addPaperFilingInteractor( + applicationContext, + mockRequest, + docketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -166,7 +180,11 @@ describe('addPaperFilingInteractor', () => { }); }); it('should remove the lock', async () => { - await addPaperFilingInteractor(applicationContext, mockRequest); + await addPaperFilingInteractor( + applicationContext, + mockRequest, + docketClerkUser, + ); expect( applicationContext.getPersistenceGateway().removeLock, diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts index 29def819c2d..0e985991409 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts @@ -285,9 +285,11 @@ export const determineEntitiesToLock = ( ttl: 900, }); -export const handleLockError = async (applicationContext, originalRequest) => { - const user = applicationContext.getCurrentUser(); - +export const handleLockError = async ( + applicationContext, + originalRequest, + authorizedUser: UnknownAuthUser, +) => { await applicationContext.getNotificationGateway().sendNotificationToUser({ applicationContext, clientConnectionId: originalRequest.clientConnectionId, @@ -296,7 +298,7 @@ export const handleLockError = async (applicationContext, originalRequest) => { originalRequest, requestToRetry: 'add_paper_filing', }, - userId: user.userId, + userId: authorizedUser!.userId, }); }; From 2858840fcd8e5a643fbc80a97e98b049b6f6cb3f Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 15:15:50 -0700 Subject: [PATCH 268/523] 10417: remove appcontext.getCurrentUser from sealDocketEntryInteractor --- .../sealDocketEntryInteractor.test.ts | 85 ++++++++++--------- .../docketEntry/sealDocketEntryInteractor.ts | 13 +-- .../documents/sealDocketEntryLambda.ts | 14 +-- 3 files changed, 54 insertions(+), 58 deletions(-) diff --git a/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.test.ts b/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.test.ts index 856ecc14dc0..2cdf662d0b7 100644 --- a/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.test.ts @@ -1,79 +1,79 @@ -import { - DOCKET_ENTRY_SEALED_TO_TYPES, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { DOCKET_ENTRY_SEALED_TO_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { sealDocketEntryInteractor } from './sealDocketEntryInteractor'; describe('sealDocketEntryInteractor', () => { const answerDocketEntryId = 'e6b81f4d-1e47-423a-8caf-6d2fdc3d3859'; it('should require a value for dockeEntrySealedTo', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); - await expect( - sealDocketEntryInteractor(applicationContext, { - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - docketEntrySealedTo: undefined, - docketNumber: '101-20', - }), + sealDocketEntryInteractor( + applicationContext, + { + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + //@ts-ignore this error is intentional + docketEntrySealedTo: undefined, + docketNumber: '101-20', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry sealed to is required'); }); it('should only allow docket clerks to seal a docket entry', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - }); - await expect( - sealDocketEntryInteractor(applicationContext, { - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - docketEntrySealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, - docketNumber: '101-20', - }), + sealDocketEntryInteractor( + applicationContext, + { + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + docketEntrySealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, + docketNumber: '101-20', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should throw an error when the docket entry is not found', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); - await expect( - sealDocketEntryInteractor(applicationContext, { - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - docketEntrySealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, - docketNumber: '101-20', - }), + sealDocketEntryInteractor( + applicationContext, + { + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + docketEntrySealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, + docketNumber: '101-20', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry not found'); }); it('should throw an error when an invalid option is provided for docketEntrySealedTo', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); await expect( - sealDocketEntryInteractor(applicationContext, { - docketEntryId: answerDocketEntryId, - docketEntrySealedTo: 'invalid', - docketNumber: '101-20', - }), + sealDocketEntryInteractor( + applicationContext, + { + docketEntryId: answerDocketEntryId, + docketEntrySealedTo: 'invalid', + docketNumber: '101-20', + }, + mockDocketClerkUser, + ), ).rejects.toThrow( 'The DocketEntry entity was invalid. {"sealedTo":"\'sealedTo\' must be one of [External, Public]"}', ); }); it('should mark the docket entry as sealed and save', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - }); applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); @@ -84,6 +84,7 @@ describe('sealDocketEntryInteractor', () => { docketEntrySealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, docketNumber: MOCK_CASE.docketNumber, }, + mockDocketClerkUser, ); expect(sealedDocketEntry).toBeDefined(); expect(sealedDocketEntry.isSealed).toEqual(true); diff --git a/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.ts index 0f727a17493..eb9f7c86140 100644 --- a/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/sealDocketEntryInteractor.ts @@ -5,16 +5,8 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * seals a given docket entry on a case - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.docketEntryId the docket entry id to seal - * @param {string} providers.docketNumber the docket number of the case - * @returns {object} the updated docket entry after it has been sealed - */ export const sealDocketEntryInteractor = async ( applicationContext: ServerApplicationContext, { @@ -26,13 +18,12 @@ export const sealDocketEntryInteractor = async ( docketEntrySealedTo: string; docketNumber: string; }, + authorizedUser: UnknownAuthUser, ) => { if (!docketEntrySealedTo) { throw new Error('Docket entry sealed to is required'); } - const authorizedUser = applicationContext.getCurrentUser(); - const hasPermission = isAuthorized( authorizedUser, ROLE_PERMISSIONS.SEAL_DOCKET_ENTRY, diff --git a/web-api/src/lambdas/documents/sealDocketEntryLambda.ts b/web-api/src/lambdas/documents/sealDocketEntryLambda.ts index 53c1329253c..8152360121f 100644 --- a/web-api/src/lambdas/documents/sealDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/sealDocketEntryLambda.ts @@ -1,12 +1,14 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** * used for sealing docket entries * * @param {object} event the AWS event object + * @param {UnknownAuthUser} authorizedUser current user associated with the request * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const sealDocketEntryLambda = event => +export const sealDocketEntryLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { const { pathParameters: { docketEntryId, docketNumber }, @@ -14,11 +16,13 @@ export const sealDocketEntryLambda = event => const { docketEntrySealedTo } = JSON.parse(event.body); - return await applicationContext - .getUseCases() - .sealDocketEntryInteractor(applicationContext, { + return await applicationContext.getUseCases().sealDocketEntryInteractor( + applicationContext, + { docketEntryId, docketEntrySealedTo, docketNumber, - }); + }, + authorizedUser, + ); }); From d51454b8c7c68c19aee2156ca8838d95905a8f3f Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 16:45:05 -0700 Subject: [PATCH 269/523] 10417: remove appcontext.getCurrentUser from strikeDocketEntryInteractor --- .../strikeDocketEntryInteractor.test.ts | 64 ++++++++++--------- .../strikeDocketEntryInteractor.ts | 13 +--- .../documents/strikeDocketEntryLambda.ts | 17 +++-- 3 files changed, 48 insertions(+), 46 deletions(-) diff --git a/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.test.ts b/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.test.ts index 7878c6b1021..1465cb74113 100644 --- a/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.test.ts @@ -5,7 +5,9 @@ import { PARTY_TYPES, ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { strikeDocketEntryInteractor } from './strikeDocketEntryInteractor'; describe('strikeDocketEntryInteractor', () => { @@ -64,42 +66,40 @@ describe('strikeDocketEntryInteractor', () => { }); it('should throw an error if not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - strikeDocketEntryInteractor(applicationContext, { - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - docketNumber: caseRecord.docketNumber, - }), + strikeDocketEntryInteractor( + applicationContext, + { + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + docketNumber: caseRecord.docketNumber, + }, + {} as UnknownAuthUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should throw an error if the docket record is not found on the case', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.docketClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - await expect( - strikeDocketEntryInteractor(applicationContext, { - docketEntryId: 'does-not-exist', - docketNumber: caseRecord.docketNumber, - }), + strikeDocketEntryInteractor( + applicationContext, + { + docketEntryId: 'does-not-exist', + docketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry not found'); }); it('should call getCaseByDocketNumber, getUserById, and updateDocketEntry', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.docketClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - await strikeDocketEntryInteractor(applicationContext, { - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - docketNumber: caseRecord.docketNumber, - }); + await strikeDocketEntryInteractor( + applicationContext, + { + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + docketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -120,10 +120,14 @@ describe('strikeDocketEntryInteractor', () => { caseRecord.docketEntries[0].isOnDocketRecord = false; await expect( - strikeDocketEntryInteractor(applicationContext, { - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - docketNumber: caseRecord.docketNumber, - }), + strikeDocketEntryInteractor( + applicationContext, + { + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + docketNumber: caseRecord.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow( 'Cannot strike a document that is not on the docket record.', ); diff --git a/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.ts index b26b58767dd..c1e94f416b4 100644 --- a/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/strikeDocketEntryInteractor.ts @@ -5,25 +5,16 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * strikes a given docket entry on a case - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.docketEntryId the docket entry id to strike - * @param {string} providers.docketNumber the docket number of the case - * @returns {object} the updated case after the docket entry is stricken - */ export const strikeDocketEntryInteractor = async ( applicationContext: ServerApplicationContext, { docketEntryId, docketNumber, }: { docketEntryId: string; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - const hasPermission = isAuthorized( authorizedUser, ROLE_PERMISSIONS.EDIT_DOCKET_ENTRY, diff --git a/web-api/src/lambdas/documents/strikeDocketEntryLambda.ts b/web-api/src/lambdas/documents/strikeDocketEntryLambda.ts index eceaf1234f7..c54d0c58d9d 100644 --- a/web-api/src/lambdas/documents/strikeDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/strikeDocketEntryLambda.ts @@ -1,21 +1,28 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** * used for striking docket records * * @param {object} event the AWS event object + * @param {UnknownAuthUser} authorizedUser current user associated with the request * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const strikeDocketEntryLambda = event => +export const strikeDocketEntryLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { pathParameters: { docketEntryId, docketNumber }, } = event; - return await applicationContext - .getUseCases() - .strikeDocketEntryInteractor(applicationContext, { + return await applicationContext.getUseCases().strikeDocketEntryInteractor( + applicationContext, + { docketEntryId, docketNumber, - }); + }, + authorizedUser, + ); }); From a20744b40f392ce1f3cc6c41eb916b4e220b5245 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Thu, 18 Jul 2024 17:03:12 -0700 Subject: [PATCH 270/523] 10417: remove appcontext.getCurrentUser from updateCourtIssuedDocketEntryInteractor --- ...teCourtIssuedDocketEntryInteractor.test.ts | 143 ++++++++++-------- .../updateCourtIssuedDocketEntryInteractor.ts | 11 +- .../updateCourtIssuedDocketEntryLambda.ts | 8 +- 3 files changed, 90 insertions(+), 72 deletions(-) diff --git a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.test.ts b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.test.ts index c3c84239beb..b1fd2d76a75 100644 --- a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.test.ts @@ -8,7 +8,9 @@ import { import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { updateCourtIssuedDocketEntryInteractor } from './updateCourtIssuedDocketEntryInteractor'; describe('updateCourtIssuedDocketEntryInteractor', () => { @@ -62,33 +64,51 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.docketClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); }); it('should throw an error if not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - updateCourtIssuedDocketEntryInteractor(applicationContext, { - documentMeta: { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bc', - docketNumber: caseRecord.docketNumber, - documentType: 'Memorandum in Support', - eventCode: 'MISP', + updateCourtIssuedDocketEntryInteractor( + applicationContext, + { + documentMeta: { + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bc', + docketNumber: caseRecord.docketNumber, + documentType: 'Memorandum in Support', + eventCode: 'MISP', + }, }, - }), + {} as UnknownAuthUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should throw an error if the document is not found on the case', async () => { await expect( - updateCourtIssuedDocketEntryInteractor(applicationContext, { + updateCourtIssuedDocketEntryInteractor( + applicationContext, + { + documentMeta: { + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bc', + docketNumber: caseRecord.docketNumber, + documentType: 'Order', + eventCode: 'O', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, + }, + mockDocketClerkUser, + ), + ).rejects.toThrow('Document not found'); + }); + + it('should call updateCase and saveWorkItem', async () => { + await updateCourtIssuedDocketEntryInteractor( + applicationContext, + { documentMeta: { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bc', + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335ba', docketNumber: caseRecord.docketNumber, documentType: 'Order', eventCode: 'O', @@ -96,22 +116,9 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { signedByUserId: mockUserId, signedJudgeName: 'Dredd', }, - }), - ).rejects.toThrow('Document not found'); - }); - - it('should call updateCase and saveWorkItem', async () => { - await updateCourtIssuedDocketEntryInteractor(applicationContext, { - documentMeta: { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335ba', - docketNumber: caseRecord.docketNumber, - documentType: 'Order', - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -122,18 +129,22 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { }); it('should not update non-editable fields on the document', async () => { - await updateCourtIssuedDocketEntryInteractor(applicationContext, { - documentMeta: { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335ba', - docketNumber: caseRecord.docketNumber, - documentType: 'Order', - eventCode: 'O', - objections: OBJECTIONS_OPTIONS_MAP.NO, - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + await updateCourtIssuedDocketEntryInteractor( + applicationContext, + { + documentMeta: { + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335ba', + docketNumber: caseRecord.docketNumber, + documentType: 'Order', + eventCode: 'O', + objections: OBJECTIONS_OPTIONS_MAP.NO, + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -148,17 +159,21 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { mockLock = MOCK_LOCK; await expect( - updateCourtIssuedDocketEntryInteractor(applicationContext, { - documentMeta: { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335ba', - docketNumber: caseRecord.docketNumber, - documentType: 'Order', - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + updateCourtIssuedDocketEntryInteractor( + applicationContext, + { + documentMeta: { + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335ba', + docketNumber: caseRecord.docketNumber, + documentType: 'Order', + eventCode: 'O', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, }, - }), + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -167,17 +182,21 @@ describe('updateCourtIssuedDocketEntryInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await updateCourtIssuedDocketEntryInteractor(applicationContext, { - documentMeta: { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335ba', - docketNumber: caseRecord.docketNumber, - documentType: 'Order', - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', + await updateCourtIssuedDocketEntryInteractor( + applicationContext, + { + documentMeta: { + docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335ba', + docketNumber: caseRecord.docketNumber, + documentType: 'Order', + eventCode: 'O', + signedAt: '2019-03-01T21:40:46.415Z', + signedByUserId: mockUserId, + signedJudgeName: 'Dredd', + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts index c59d95dd698..42ff20b3446 100644 --- a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts @@ -6,21 +6,14 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -/** - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.documentMeta document details to go on the record - * @returns {object} the updated case after the documents are added - */ export const updateCourtIssuedDocketEntry = async ( applicationContext: ServerApplicationContext, { documentMeta }: { documentMeta: any }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - const hasPermission = isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY) || isAuthorized(authorizedUser, ROLE_PERMISSIONS.CREATE_ORDER_DOCKET_ENTRY); diff --git a/web-api/src/lambdas/documents/updateCourtIssuedDocketEntryLambda.ts b/web-api/src/lambdas/documents/updateCourtIssuedDocketEntryLambda.ts index 943565d44f2..4c5e7825a75 100644 --- a/web-api/src/lambdas/documents/updateCourtIssuedDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/updateCourtIssuedDocketEntryLambda.ts @@ -1,17 +1,23 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** * lambda which is used for updating a court issued docket entry * * @param {object} event the AWS event object + * @param {UnknownAuthUser} authorizedUser user associated with the current request * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateCourtIssuedDocketEntryLambda = event => +export const updateCourtIssuedDocketEntryLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() .updateCourtIssuedDocketEntryInteractor( applicationContext, JSON.parse(event.body), + authorizedUser, ); }); From 658e76beb518112cef7255e94e46dbbe2fe4b7b1 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 07:53:54 -0500 Subject: [PATCH 271/523] 10417 fix messageDocumentHelper.showApplyStampButton.test --- ...sageDocumentHelper.showApplyStampButton.test.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/web-client/src/presenter/computeds/messageDocumentHelper.showApplyStampButton.test.ts b/web-client/src/presenter/computeds/messageDocumentHelper.showApplyStampButton.test.ts index 33da9427f18..cabec6fbe47 100644 --- a/web-client/src/presenter/computeds/messageDocumentHelper.showApplyStampButton.test.ts +++ b/web-client/src/presenter/computeds/messageDocumentHelper.showApplyStampButton.test.ts @@ -1,14 +1,14 @@ import { STAMPED_DOCUMENTS_ALLOWLIST } from '../../../../shared/src/business/entities/EntityConstants'; +import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { - adcUser, clerkOfCourtUser, colvinsChambersUser, docketClerkUser, judgeUser, } from '../../../../shared/src/test/mockUsers'; -import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { messageDocumentHelper as messageDocumentHelperComputed } from './messageDocumentHelper'; +import { mockAdcUser } from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -19,18 +19,14 @@ describe('messageDocumentHelper.showApplyStampButton', () => { const messageDocumentHelper = withAppContextDecorator( messageDocumentHelperComputed, - { - ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, - }, + applicationContext, ); const getBaseState = user => { globalUser = user; return { permissions: getUserPermissions(user), + user: globalUser, }; }; @@ -148,7 +144,7 @@ describe('messageDocumentHelper.showApplyStampButton', () => { const { showApplyStampButton } = runCompute(messageDocumentHelper, { state: { - ...getBaseState(adcUser), + ...getBaseState(mockAdcUser), caseDetail: { docketEntries: [], }, From bc02097c3833805d3b9242ed50e6ab8474f3e886 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 07:57:16 -0500 Subject: [PATCH 272/523] 10417 fix caseDetailHelper tests --- ...DetailHelper.showConsolidatedCasesCard.test.ts | 15 +++++++-------- .../caseDetailHelper.showSealedCaseView.test.ts | 11 +++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/web-client/src/presenter/computeds/caseDetailHelper.showConsolidatedCasesCard.test.ts b/web-client/src/presenter/computeds/caseDetailHelper.showConsolidatedCasesCard.test.ts index 22658aac362..d87bfc1e0f3 100644 --- a/web-client/src/presenter/computeds/caseDetailHelper.showConsolidatedCasesCard.test.ts +++ b/web-client/src/presenter/computeds/caseDetailHelper.showConsolidatedCasesCard.test.ts @@ -2,20 +2,18 @@ import { adcUser, irsPractitionerUser, petitionerUser, - privatePractitionerUser, } from '../../../../shared/src/test/mockUsers'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { caseDetailHelper as caseDetailHelperComputed } from './caseDetailHelper'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; +import { mockPrivatePractitionerUser } from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; -const caseDetailHelper = withAppContextDecorator(caseDetailHelperComputed, { - ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, -}); +const caseDetailHelper = withAppContextDecorator( + caseDetailHelperComputed, + applicationContext, +); let globalUser; @@ -23,6 +21,7 @@ const getBaseState = user => { globalUser = user; return { permissions: getUserPermissions(user), + user: globalUser, }; }; @@ -43,7 +42,7 @@ describe('showConsolidatedCasesCard', () => { }); it('should be true when the user is a private practitioner and has the VIEW_CONSOLIDATED_CASES_CARD permission and the case is in a consolidated group', () => { - const user = privatePractitionerUser; + const user = mockPrivatePractitionerUser; const result = runCompute(caseDetailHelper, { state: { diff --git a/web-client/src/presenter/computeds/caseDetailHelper.showSealedCaseView.test.ts b/web-client/src/presenter/computeds/caseDetailHelper.showSealedCaseView.test.ts index 3ee32221d5a..5fb0d6fa6a2 100644 --- a/web-client/src/presenter/computeds/caseDetailHelper.showSealedCaseView.test.ts +++ b/web-client/src/presenter/computeds/caseDetailHelper.showSealedCaseView.test.ts @@ -9,12 +9,10 @@ import { import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; -const caseDetailHelper = withAppContextDecorator(caseDetailHelperComputed, { - ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, -}); +const caseDetailHelper = withAppContextDecorator( + caseDetailHelperComputed, + applicationContext, +); let globalUser; @@ -24,6 +22,7 @@ const getBaseState = user => { currentPage: 'CaseDetail', form: {}, permissions: getUserPermissions(user), + user: globalUser, }; }; From 03cab2e610aecc46e1e51cdfd6473b6ee77f5ee9 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 07:59:40 -0500 Subject: [PATCH 273/523] 10417 fix more caseDetailHelper tests --- ...caseDetailHelper.hasTrackedItemsPermission.test.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web-client/src/presenter/computeds/caseDetailHelper.hasTrackedItemsPermission.test.ts b/web-client/src/presenter/computeds/caseDetailHelper.hasTrackedItemsPermission.test.ts index 9c454a74cae..53e483ce618 100644 --- a/web-client/src/presenter/computeds/caseDetailHelper.hasTrackedItemsPermission.test.ts +++ b/web-client/src/presenter/computeds/caseDetailHelper.hasTrackedItemsPermission.test.ts @@ -8,12 +8,10 @@ import { getUserPermissions } from '../../../../shared/src/authorization/getUser import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; -const caseDetailHelper = withAppContextDecorator(caseDetailHelperComputed, { - ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, -}); +const caseDetailHelper = withAppContextDecorator( + caseDetailHelperComputed, + applicationContext, +); let globalUser; @@ -23,6 +21,7 @@ const getBaseState = user => { currentPage: 'CaseDetailInternal', form: {}, permissions: getUserPermissions(user), + user: globalUser, }; }; From d6ad2c42f51fad4ecc5055e96ceb8158d876d368 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 08:07:57 -0500 Subject: [PATCH 274/523] 10417 fix more client unit tests --- ...ationHelper.showUnsealedCaseButton.test.ts | 29 +++++-------------- .../sequences/chooseWorkQueueSequence.test.ts | 2 ++ .../gotoMessageDetailSequence.test.ts | 2 ++ .../sequences/gotoMessagesSequence.test.ts | 2 ++ 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/web-client/src/presenter/computeds/caseInformationHelper.showUnsealedCaseButton.test.ts b/web-client/src/presenter/computeds/caseInformationHelper.showUnsealedCaseButton.test.ts index 991d5083e58..d065055b80b 100644 --- a/web-client/src/presenter/computeds/caseInformationHelper.showUnsealedCaseButton.test.ts +++ b/web-client/src/presenter/computeds/caseInformationHelper.showUnsealedCaseButton.test.ts @@ -1,44 +1,31 @@ -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { caseInformationHelper as caseInformationHelperComputed } from './caseInformationHelper'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; +import { + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; describe('caseInformationHelper', () => { - const mockPetitionsClerk = { - role: ROLES.petitionsClerk, - userId: '0dd60083-ab1f-4a43-95f8-bfbc69b48777', - }; - const mockDocketClerk = { - role: ROLES.docketClerk, - userId: 'a09053ab-58c7-4384-96a1-bd5fbe14977a', - }; - const caseInformationHelper = withAppContextDecorator( caseInformationHelperComputed, applicationContext, ); const getBaseState = user => { - mockUser = { ...user }; return { permissions: getUserPermissions(user), + user, }; }; - let mockUser; - - beforeEach(() => { - mockUser = {}; - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - }); - describe('showUnsealCaseButton', () => { it('should be false when the user has UNSEAL_CASE permission and case is not already sealed', () => { const result = runCompute(caseInformationHelper, { state: { - ...getBaseState(mockDocketClerk), // has SEAL_CASE permission + ...getBaseState(mockDocketClerkUser), // has SEAL_CASE permission caseDetail: { isSealed: false, petitioners: [], sealedDate: null }, form: {}, }, @@ -50,7 +37,7 @@ describe('caseInformationHelper', () => { it('should be true when the user has UNSEAL_CASE permission and case is already sealed', () => { const result = runCompute(caseInformationHelper, { state: { - ...getBaseState(mockDocketClerk), // has SEAL_CASE permission + ...getBaseState(mockDocketClerkUser), // has SEAL_CASE permission caseDetail: { isSealed: true, petitioners: [], @@ -66,7 +53,7 @@ describe('caseInformationHelper', () => { it('should be false when the user does not have UNSEAL_CASE permission', () => { const result = runCompute(caseInformationHelper, { state: { - ...getBaseState(mockPetitionsClerk), // does not have SEAL_CASE permission + ...getBaseState(mockPetitionsClerkUser), // does not have SEAL_CASE permission caseDetail: { petitioners: [], }, diff --git a/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts b/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts index 1930541f29a..c337e8f173d 100644 --- a/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts +++ b/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts @@ -1,6 +1,7 @@ import { CerebralTest } from 'cerebral/test'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { chooseWorkQueueSequence } from '../sequences/chooseWorkQueueSequence'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { presenter } from '../presenter-mock'; describe('chooseWorkQueueSequence', () => { @@ -25,6 +26,7 @@ describe('chooseWorkQueueSequence', () => { chooseWorkQueueSequence, }; cerebralTest = CerebralTest(presenter); + cerebralTest.setState('user', mockDocketClerkUser); }); it('should set the workQueueToDisplay to match the props passed in', async () => { diff --git a/web-client/src/presenter/sequences/gotoMessageDetailSequence.test.ts b/web-client/src/presenter/sequences/gotoMessageDetailSequence.test.ts index 9b86bc8ec7a..b5d64c5e24a 100644 --- a/web-client/src/presenter/sequences/gotoMessageDetailSequence.test.ts +++ b/web-client/src/presenter/sequences/gotoMessageDetailSequence.test.ts @@ -6,6 +6,7 @@ import { CerebralTest } from 'cerebral/test'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { gotoMessageDetailSequence } from '../sequences/gotoMessageDetailSequence'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { presenter } from '../presenter-mock'; describe('gotoMessageDetailSequence', () => { @@ -75,6 +76,7 @@ describe('gotoMessageDetailSequence', () => { //set token to take 'isLoggedIn' path cerebralTest.setState('token', 'a'); + cerebralTest.setState('user', mockDocketClerkUser); }); it('should change the page to MyAccount and close the opened menu', async () => { diff --git a/web-client/src/presenter/sequences/gotoMessagesSequence.test.ts b/web-client/src/presenter/sequences/gotoMessagesSequence.test.ts index 979752514ab..43243d8031a 100644 --- a/web-client/src/presenter/sequences/gotoMessagesSequence.test.ts +++ b/web-client/src/presenter/sequences/gotoMessagesSequence.test.ts @@ -1,6 +1,7 @@ import { CerebralTest } from 'cerebral/test'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { gotoMessagesSequence } from '../sequences/gotoMessagesSequence'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { presenter } from '../presenter-mock'; describe('gotoMessagesSequence', () => { @@ -34,6 +35,7 @@ describe('gotoMessagesSequence', () => { //set token to take 'isLoggedIn' path cerebralTest.setState('token', 'a'); + cerebralTest.setState('user', mockDocketClerkUser); }); it('should change the page to MyAccount and close the opened menu', async () => { From a53454ced1d90854761c833fdf21aeace4ba7dde Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 08:40:58 -0500 Subject: [PATCH 275/523] 10417 point client side to mockUsers instead of mockAuthUsers --- shared/src/test/mockUsers.ts | 6 +- .../addCourtIssuedDocketEntryHelper.test.ts | 1 - ...ilHelper.showConsolidatedCasesCard.test.ts | 4 +- ...ationHelper.showUnsealedCaseButton.test.ts | 11 +- .../computeds/caseInformationHelper.test.ts | 14 +-- .../formattedTrialSessionDetails.test.ts | 52 ++++----- .../computeds/formattedTrialSessions.test.ts | 47 ++++---- ...formattedWorkQueue.filterWorkItems.test.ts | 4 +- ...ocumentHelper.showApplyStampButton.test.ts | 6 +- .../presenter/computeds/scanHelper.test.ts | 82 ++++++------- .../computeds/startCaseHelper.test.ts | 48 ++++---- .../trialSessionHeaderHelper.test.ts | 64 +++++------ .../trialSessionsSummaryHelper.test.ts | 12 +- .../computeds/workQueueHelper.test.ts | 108 +++++++++--------- .../sequences/chooseWorkQueueSequence.test.ts | 4 +- .../gotoMessageDetailSequence.test.ts | 4 +- .../sequences/gotoMessagesSequence.test.ts | 4 +- 17 files changed, 234 insertions(+), 237 deletions(-) diff --git a/shared/src/test/mockUsers.ts b/shared/src/test/mockUsers.ts index 0b3eb78828a..cee55c84c1e 100644 --- a/shared/src/test/mockUsers.ts +++ b/shared/src/test/mockUsers.ts @@ -19,6 +19,7 @@ import { } from '../../../web-client/src/business/chambers/getJudgesChambers'; export const adminUser: RawUser = { + email: 'admin@example.com', entityName: 'User', name: 'Test admin', role: ROLES.admin, @@ -26,10 +27,11 @@ export const adminUser: RawUser = { }; export const adcUser = { + email: 'adc@example.com', name: 'ADC', role: ROLES.adc, section: ADC_SECTION, - userId: 'g7d90c05-f6cd-442c-a168-202db587f16f', + userId: '9f357f78-a8fa-40bf-83db-8144ddf14047', }; export const colvinsChambersUser = { @@ -121,6 +123,7 @@ export const petitionerUser = { export const privatePractitionerUser = { barNumber: 'BN1234', + email: 'privatePractitioner@example.com', name: 'Private Practitioner', role: ROLES.privatePractitioner, section: 'privatePractitioner', @@ -171,6 +174,7 @@ export const petitionsClerkUser: RawUser = { }; export const admissionsClerkUser = { + email: 'admissionsClerk@example.com', name: 'AdmissionsClerk', role: ROLES.admissionsClerk, section: ADMISSIONS_SECTION, diff --git a/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.test.ts b/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.test.ts index 63f4f5cf510..1bbec8ab36b 100644 --- a/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.test.ts +++ b/web-client/src/presenter/computeds/addCourtIssuedDocketEntryHelper.test.ts @@ -78,7 +78,6 @@ describe('addCourtIssuedDocketEntryHelper', () => { }); it('should calculate document types based on constants in applicationContext', () => { - console.debug('*****************************************', state.user); const result = runCompute(addCourtIssuedDocketEntryHelper, { state }); expect(result.documentTypes).toEqual([ { diff --git a/web-client/src/presenter/computeds/caseDetailHelper.showConsolidatedCasesCard.test.ts b/web-client/src/presenter/computeds/caseDetailHelper.showConsolidatedCasesCard.test.ts index d87bfc1e0f3..9ed36eb5928 100644 --- a/web-client/src/presenter/computeds/caseDetailHelper.showConsolidatedCasesCard.test.ts +++ b/web-client/src/presenter/computeds/caseDetailHelper.showConsolidatedCasesCard.test.ts @@ -6,7 +6,7 @@ import { import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { caseDetailHelper as caseDetailHelperComputed } from './caseDetailHelper'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; -import { mockPrivatePractitionerUser } from '@shared/test/mockAuthUsers'; +import { privatePractitionerUser } from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -42,7 +42,7 @@ describe('showConsolidatedCasesCard', () => { }); it('should be true when the user is a private practitioner and has the VIEW_CONSOLIDATED_CASES_CARD permission and the case is in a consolidated group', () => { - const user = mockPrivatePractitionerUser; + const user = privatePractitionerUser; const result = runCompute(caseDetailHelper, { state: { diff --git a/web-client/src/presenter/computeds/caseInformationHelper.showUnsealedCaseButton.test.ts b/web-client/src/presenter/computeds/caseInformationHelper.showUnsealedCaseButton.test.ts index d065055b80b..c0bf73c1e74 100644 --- a/web-client/src/presenter/computeds/caseInformationHelper.showUnsealedCaseButton.test.ts +++ b/web-client/src/presenter/computeds/caseInformationHelper.showUnsealedCaseButton.test.ts @@ -1,10 +1,7 @@ import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { caseInformationHelper as caseInformationHelperComputed } from './caseInformationHelper'; +import { docketClerkUser, petitionsClerkUser } from '@shared/test/mockUsers'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; -import { - mockDocketClerkUser, - mockPetitionsClerkUser, -} from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -25,7 +22,7 @@ describe('caseInformationHelper', () => { it('should be false when the user has UNSEAL_CASE permission and case is not already sealed', () => { const result = runCompute(caseInformationHelper, { state: { - ...getBaseState(mockDocketClerkUser), // has SEAL_CASE permission + ...getBaseState(docketClerkUser), // has SEAL_CASE permission caseDetail: { isSealed: false, petitioners: [], sealedDate: null }, form: {}, }, @@ -37,7 +34,7 @@ describe('caseInformationHelper', () => { it('should be true when the user has UNSEAL_CASE permission and case is already sealed', () => { const result = runCompute(caseInformationHelper, { state: { - ...getBaseState(mockDocketClerkUser), // has SEAL_CASE permission + ...getBaseState(docketClerkUser), // has SEAL_CASE permission caseDetail: { isSealed: true, petitioners: [], @@ -53,7 +50,7 @@ describe('caseInformationHelper', () => { it('should be false when the user does not have UNSEAL_CASE permission', () => { const result = runCompute(caseInformationHelper, { state: { - ...getBaseState(mockPetitionsClerkUser), // does not have SEAL_CASE permission + ...getBaseState(petitionsClerkUser), // does not have SEAL_CASE permission caseDetail: { petitioners: [], }, diff --git a/web-client/src/presenter/computeds/caseInformationHelper.test.ts b/web-client/src/presenter/computeds/caseInformationHelper.test.ts index 155f964c563..edf16d58456 100644 --- a/web-client/src/presenter/computeds/caseInformationHelper.test.ts +++ b/web-client/src/presenter/computeds/caseInformationHelper.test.ts @@ -7,13 +7,13 @@ import { applicationContextForClient as applicationContext } from '@web-client/t import { caseInformationHelper as caseInformationHelperComputed } from './caseInformationHelper'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { - mockAdcUser as mockAdc, - mockDocketClerkUser as mockDocketClerk, - mockJudgeUser as mockJudge, - mockPetitionerUser as mockPetitioner, - mockPetitionsClerkUser as mockPetitionsClerk, - mockPrivatePractitionerUser as mockPrivatePractitioner, -} from '@shared/test/mockAuthUsers'; + adcUser as mockAdc, + docketClerkUser as mockDocketClerk, + judgeUser as mockJudge, + petitionerUser as mockPetitioner, + petitionsClerkUser as mockPetitionsClerk, + privatePractitionerUser as mockPrivatePractitioner, +} from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts index 8e638492fd8..1e206f3f3a7 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts @@ -8,10 +8,10 @@ import { import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { colvinsChambersUser, + docketClerk1User, judgeUser, } from '../../../../shared/src/test/mockUsers'; import { formattedTrialSessionDetails as formattedTrialSessionDetailsComputed } from './formattedTrialSessionDetails'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -64,7 +64,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -79,7 +79,7 @@ describe('formattedTrialSessionDetails', () => { let result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -92,7 +92,7 @@ describe('formattedTrialSessionDetails', () => { result = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -124,7 +124,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -139,7 +139,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -152,7 +152,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -170,7 +170,7 @@ describe('formattedTrialSessionDetails', () => { isCalendared: false, startDate: PAST_DATE, }, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -188,7 +188,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -207,7 +207,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -226,7 +226,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -245,7 +245,7 @@ describe('formattedTrialSessionDetails', () => { sessionStatus: SESSION_STATUS_GROUPS.open, startDate: PAST_DATE, }, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); expect(result).toMatchObject({ @@ -263,7 +263,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -284,7 +284,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -322,7 +322,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -344,7 +344,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -362,7 +362,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -380,7 +380,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); expect(result.canClose).toBe(false); @@ -397,7 +397,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -415,7 +415,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -433,7 +433,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -453,7 +453,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -475,7 +475,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -497,7 +497,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -517,7 +517,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: mockDocketClerkUser, + user: docketClerk1User, }, }); @@ -538,7 +538,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: mockDocketClerkUser, + user: docketClerk1User, }, }, ); diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.test.ts b/web-client/src/presenter/computeds/formattedTrialSessions.test.ts index 0d3890e5af3..c30830cd766 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessions.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessions.test.ts @@ -6,10 +6,7 @@ import { import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { formatTrialSessionDisplayOptions } from './addToTrialSessionModalHelper'; import { formattedTrialSessions as formattedTrialSessionsComputed } from './formattedTrialSessions'; -import { - mockJudgeUser, - mockPetitionsClerkUser, -} from '@shared/test/mockAuthUsers'; +import { judgeUser, petitionsClerkUser } from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; jest.mock('./addToTrialSessionModalHelper.ts'); @@ -40,7 +37,7 @@ const testTrialClerkUser = { const baseState = { constants: { USER_ROLES: ROLES }, - judgeUser: mockJudgeUser, + judgeUser, }; let TRIAL_SESSIONS_LIST: any[] = []; @@ -55,7 +52,7 @@ describe('formattedTrialSessions', () => { { caseOrder: [], isCalendared: true, - judge: { name: mockJudgeUser.name, userId: mockJudgeUser.userId }, + judge: { name: judgeUser.name, userId: judgeUser.userId }, proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, sessionStatus: 'Open', sessionType: SESSION_TYPES.regular, @@ -173,7 +170,7 @@ describe('formattedTrialSessions', () => { state: { ...baseState, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); } catch (err) { @@ -187,7 +184,7 @@ describe('formattedTrialSessions', () => { state: { ...baseState, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); @@ -206,10 +203,10 @@ describe('formattedTrialSessions', () => { state: { ...baseState, screenMetadata: { - trialSessionFilters: { judge: { userId: mockJudgeUser.userId } }, + trialSessionFilters: { judge: { userId: judgeUser.userId } }, }, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); expect(result.formattedSessions.length).toBe(1); @@ -226,7 +223,7 @@ describe('formattedTrialSessions', () => { }, }, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); const flattenedSessions = result.formattedSessions.flatMap( @@ -241,7 +238,7 @@ describe('formattedTrialSessions', () => { ...baseState, screenMetadata: { trialSessionFilters: { judge: { userId: '' } } }, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); expect(result.formattedSessions.length).toBe(4); @@ -260,7 +257,7 @@ describe('formattedTrialSessions', () => { trialSessionFilters: { judge: { userId: 'unassigned' } }, }, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); @@ -277,7 +274,7 @@ describe('formattedTrialSessions', () => { ...baseState, form, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); expect(result.sessionsByTerm.length).toEqual(0); @@ -289,7 +286,7 @@ describe('formattedTrialSessions', () => { ...baseState, form, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); expect(result.sessionsByTerm.length).toEqual(1); @@ -301,7 +298,7 @@ describe('formattedTrialSessions', () => { ...baseState, form, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); expect(result.sessionsByTerm.length).toEqual(0); @@ -316,7 +313,7 @@ describe('formattedTrialSessions', () => { term: 'Winter', }, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); @@ -416,7 +413,7 @@ describe('formattedTrialSessions', () => { term: 'Winter', }, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); @@ -432,7 +429,7 @@ describe('formattedTrialSessions', () => { }, trialSession: { trialSessionId: TRIAL_SESSIONS_LIST[1].trialSessionId }, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); @@ -450,7 +447,7 @@ describe('formattedTrialSessions', () => { ...baseState, judgeUser: undefined, trialSessions: TRIAL_SESSIONS_LIST, - user: mockPetitionsClerkUser, + user: petitionsClerkUser, }, }); @@ -462,7 +459,7 @@ describe('formattedTrialSessions', () => { userIsAssignedToSession: false, }, { - judge: { name: mockJudgeUser.name, userId: mockJudgeUser.userId }, + judge: { name: judgeUser.name, userId: judgeUser.userId }, userIsAssignedToSession: false, }, { @@ -498,7 +495,7 @@ describe('formattedTrialSessions', () => { state: { ...baseState, trialSessions: TRIAL_SESSIONS_LIST, - user: mockJudgeUser, + user: judgeUser, }, }); expect(result.formattedSessions).toMatchObject([ @@ -510,7 +507,7 @@ describe('formattedTrialSessions', () => { userIsAssignedToSession: false, }, { - judge: { name: mockJudgeUser.name, userId: mockJudgeUser.userId }, + judge: { name: judgeUser.name, userId: judgeUser.userId }, userIsAssignedToSession: true, }, { @@ -593,7 +590,7 @@ describe('formattedTrialSessions', () => { userIsAssignedToSession: false, }, { - judge: { name: mockJudgeUser.name, userId: mockJudgeUser.userId }, + judge: { name: judgeUser.name, userId: judgeUser.userId }, userIsAssignedToSession: false, }, { @@ -640,7 +637,7 @@ describe('formattedTrialSessions', () => { trialLocation: 'Jacksonville, FL', }, ], - user: mockPetitionsClerkUser, + user: petitionsClerkUser, }, }); expect(result.formattedSessions).toMatchObject([ diff --git a/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts b/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts index 6a082b8cff7..a7d695192aa 100644 --- a/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts +++ b/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts @@ -1,6 +1,6 @@ import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { filterWorkItems } from './formattedWorkQueue'; -import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; +import { petitionsClerkUser } from '@shared/test/mockUsers'; const { DOCKET_SECTION, @@ -204,7 +204,7 @@ describe('filterWorkItems', () => { it('Returns section work items for a Petitions Clerk in Section Document QC Inbox', () => { const filtered = filterWorkItems({ applicationContext, - authorizedUser: mockPetitionsClerkUser, + authorizedUser: petitionsClerkUser, section: PETITIONS_SECTION, workItems: workQueueInbox, ...SECTION_DOCUMENT_QC_INBOX, diff --git a/web-client/src/presenter/computeds/messageDocumentHelper.showApplyStampButton.test.ts b/web-client/src/presenter/computeds/messageDocumentHelper.showApplyStampButton.test.ts index cabec6fbe47..c32c3a3b297 100644 --- a/web-client/src/presenter/computeds/messageDocumentHelper.showApplyStampButton.test.ts +++ b/web-client/src/presenter/computeds/messageDocumentHelper.showApplyStampButton.test.ts @@ -1,14 +1,14 @@ import { STAMPED_DOCUMENTS_ALLOWLIST } from '../../../../shared/src/business/entities/EntityConstants'; -import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { + adcUser, clerkOfCourtUser, colvinsChambersUser, docketClerkUser, judgeUser, } from '../../../../shared/src/test/mockUsers'; +import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { messageDocumentHelper as messageDocumentHelperComputed } from './messageDocumentHelper'; -import { mockAdcUser } from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; @@ -144,7 +144,7 @@ describe('messageDocumentHelper.showApplyStampButton', () => { const { showApplyStampButton } = runCompute(messageDocumentHelper, { state: { - ...getBaseState(mockAdcUser), + ...getBaseState(adcUser), caseDetail: { docketEntries: [], }, diff --git a/web-client/src/presenter/computeds/scanHelper.test.ts b/web-client/src/presenter/computeds/scanHelper.test.ts index bc6c9444519..16658116df8 100644 --- a/web-client/src/presenter/computeds/scanHelper.test.ts +++ b/web-client/src/presenter/computeds/scanHelper.test.ts @@ -1,13 +1,13 @@ import { INITIAL_DOCUMENT_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; -import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { - mockAdcUser, - mockDocketClerkUser, - mockIrsPractitionerUser, - mockPetitionerUser, - mockPetitionsClerkUser, - mockPrivatePractitionerUser, -} from '@shared/test/mockAuthUsers'; + adcUser, + docketClerkUser, + irsPractitionerUser, + petitionerUser, + petitionsClerkUser, + privatePractitionerUser, +} from '@shared/test/mockUsers'; +import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { scanHelper as scanHelperComputed } from './scanHelper'; import { withAppContextDecorator } from '../../../src/withAppContext'; @@ -26,7 +26,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to true for petitionsclerk user roles', () => { const result = runCompute(scanHelper, { - state: { ...stateWithEmptyFormDocuments, user: mockPetitionsClerkUser }, + state: { ...stateWithEmptyFormDocuments, user: petitionsClerkUser }, }); expect(result.hasScanFeature).toEqual(true); @@ -34,7 +34,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to true for docketclerk user roles', () => { const result = runCompute(scanHelper, { - state: { ...stateWithEmptyFormDocuments, user: mockDocketClerkUser }, + state: { ...stateWithEmptyFormDocuments, user: docketClerkUser }, }); expect(result.hasScanFeature).toEqual(true); @@ -42,7 +42,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to true for adc user roles', () => { const result = runCompute(scanHelper, { - state: { ...stateWithEmptyFormDocuments, user: mockAdcUser }, + state: { ...stateWithEmptyFormDocuments, user: adcUser }, }); expect(result.hasScanFeature).toEqual(true); @@ -50,7 +50,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to false for petitioner user roles', () => { const result = runCompute(scanHelper, { - state: { ...stateWithEmptyFormDocuments, user: mockPetitionerUser }, + state: { ...stateWithEmptyFormDocuments, user: petitionerUser }, }); expect(result.hasScanFeature).toEqual(false); @@ -60,7 +60,7 @@ describe('scanHelper', () => { const result = runCompute(scanHelper, { state: { ...stateWithEmptyFormDocuments, - user: mockPrivatePractitionerUser, + user: privatePractitionerUser, }, }); @@ -69,7 +69,7 @@ describe('scanHelper', () => { it('sets hasScanFeature to false for respondent user roles', () => { const result = runCompute(scanHelper, { - state: { ...stateWithEmptyFormDocuments, user: mockIrsPractitionerUser }, + state: { ...stateWithEmptyFormDocuments, user: irsPractitionerUser }, }); expect(result.hasScanFeature).toEqual(false); @@ -82,7 +82,7 @@ describe('scanHelper', () => { modal: { showModal: 'SelectScannerSourceModal', }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.showScannerSourceModal).toEqual(true); @@ -96,7 +96,7 @@ describe('scanHelper', () => { scanner: { sources: mockSources, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.sources.length).toEqual(2); @@ -109,7 +109,7 @@ describe('scanHelper', () => { form: { stinFile: {}, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -123,7 +123,7 @@ describe('scanHelper', () => { docketEntries: [], stinFile: {}, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -137,7 +137,7 @@ describe('scanHelper', () => { docketEntries: [], stinFile: null, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.STINFileCompleted).toEqual(false); @@ -153,7 +153,7 @@ describe('scanHelper', () => { }, ], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -166,7 +166,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -182,7 +182,7 @@ describe('scanHelper', () => { docketEntries: [], requestForPlaceOfTrialFile: {}, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -196,7 +196,7 @@ describe('scanHelper', () => { docketEntries: [], requestForPlaceOfTrialFile: null, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.RQTFileCompleted).toEqual(false); @@ -213,7 +213,7 @@ describe('scanHelper', () => { }, ], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -226,7 +226,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -242,7 +242,7 @@ describe('scanHelper', () => { applicationForWaiverOfFilingFeeFile: {}, docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -256,7 +256,7 @@ describe('scanHelper', () => { applicationForWaiverOfFilingFeeFile: null, docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.APWFileCompleted).toEqual(false); @@ -274,7 +274,7 @@ describe('scanHelper', () => { }, ], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -287,7 +287,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -303,7 +303,7 @@ describe('scanHelper', () => { docketEntries: [], petitionFile: {}, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -317,7 +317,7 @@ describe('scanHelper', () => { docketEntries: [], petitionFileCompleted: null, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.PFileCompleted).toEqual(false); @@ -333,7 +333,7 @@ describe('scanHelper', () => { }, ], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -346,7 +346,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -362,7 +362,7 @@ describe('scanHelper', () => { corporateDisclosureFile: {}, docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -376,7 +376,7 @@ describe('scanHelper', () => { corporateDisclosureFile: null, docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.DISCFileCompleted).toEqual(false); @@ -392,7 +392,7 @@ describe('scanHelper', () => { }, ], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -405,7 +405,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -421,7 +421,7 @@ describe('scanHelper', () => { attachmentToPetitionFile: {}, docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -435,7 +435,7 @@ describe('scanHelper', () => { attachmentToPetitionFile: null, docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.ATPFileCompleted).toEqual(false); @@ -452,7 +452,7 @@ describe('scanHelper', () => { }, ], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -465,7 +465,7 @@ describe('scanHelper', () => { form: { docketEntries: [], }, - user: mockPetitionerUser, + user: petitionerUser, }, }); diff --git a/web-client/src/presenter/computeds/startCaseHelper.test.ts b/web-client/src/presenter/computeds/startCaseHelper.test.ts index 407a5f69e02..59c7c8482fa 100644 --- a/web-client/src/presenter/computeds/startCaseHelper.test.ts +++ b/web-client/src/presenter/computeds/startCaseHelper.test.ts @@ -6,10 +6,10 @@ import { import { RawUser } from '@shared/business/entities/User'; import { applicationContext } from '../../applicationContext'; import { - mockIrsPractitionerUser, - mockPetitionerUser, - mockPrivatePractitionerUser, -} from '@shared/test/mockAuthUsers'; + irsPractitionerUser, + petitionerUser, + privatePractitionerUser, +} from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { startCaseHelper as startCaseHelperComputed } from './startCaseHelper'; import { withAppContextDecorator } from '../../withAppContext'; @@ -33,7 +33,7 @@ describe('startCaseHelper', () => { const result = runCompute(startCaseHelper, { state: { form: {}, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.showPetitionFileValid).toBeFalsy(); @@ -43,7 +43,7 @@ describe('startCaseHelper', () => { const result = runCompute(startCaseHelper, { state: { form: { petitionFile: true }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.showPetitionFileValid).toBeTruthy(); @@ -57,7 +57,7 @@ describe('startCaseHelper', () => { partyType: true, petitionFile: true, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.showCorporateDisclosure).toBeTruthy(); @@ -71,7 +71,7 @@ describe('startCaseHelper', () => { partyType: true, petitionFile: true, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.showCorporateDisclosure).toBeFalsy(); @@ -83,7 +83,7 @@ describe('startCaseHelper', () => { form: { hasIrsNotice: true, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.showHasIrsNoticeOptions).toBeTruthy(); @@ -96,7 +96,7 @@ describe('startCaseHelper', () => { form: { hasIrsNotice: false, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.showNotHasIrsNoticeOptions).toBeTruthy(); @@ -109,7 +109,7 @@ describe('startCaseHelper', () => { form: { hasIrsNotice: false, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); expect(result.filingTypes).toEqual(FILING_TYPES.petitioner); @@ -121,7 +121,7 @@ describe('startCaseHelper', () => { form: { hasIrsNotice: false, }, - user: mockPrivatePractitionerUser, + user: privatePractitionerUser, }, }); expect(result.filingTypes).toEqual(FILING_TYPES.privatePractitioner); @@ -133,7 +133,7 @@ describe('startCaseHelper', () => { form: { hasIrsNotice: false, }, - user: mockIrsPractitionerUser, + user: irsPractitionerUser, }, }); expect(result.filingTypes).toEqual(FILING_TYPES.petitioner); @@ -146,7 +146,7 @@ describe('startCaseHelper', () => { contactPrimary: { name: 'Michael G. Scott' }, partyType: PARTY_TYPES.petitioner, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -161,7 +161,7 @@ describe('startCaseHelper', () => { contactSecondary: { name: 'Carol Stills' }, partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -176,7 +176,7 @@ describe('startCaseHelper', () => { contactSecondary: { name: 'Carol Stills' }, partyType: PARTY_TYPES.petitionerSpouse, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -191,7 +191,7 @@ describe('startCaseHelper', () => { contactSecondary: { name: 'Carol Stills' }, partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -208,7 +208,7 @@ describe('startCaseHelper', () => { contactSecondary: { name: 'Carol Stills' }, partyType: PARTY_TYPES.petitionerSpouse, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -224,7 +224,7 @@ describe('startCaseHelper', () => { contactPrimary: { name: '' }, partyType: PARTY_TYPES.trust, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -238,7 +238,7 @@ describe('startCaseHelper', () => { contactPrimary: { name: '' }, partyType: PARTY_TYPES.trust, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -252,7 +252,7 @@ describe('startCaseHelper', () => { contactPrimary: { name: '' }, partyType: PARTY_TYPES.trust, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -314,7 +314,7 @@ describe('startCaseHelper', () => { form: { caseType: 'Disclosure1', }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -327,7 +327,7 @@ describe('startCaseHelper', () => { form: { caseType: 'Disclosure2', }, - user: mockPetitionerUser, + user: petitionerUser, }, }); @@ -340,7 +340,7 @@ describe('startCaseHelper', () => { form: { caseType: CASE_TYPES_MAP.deficiency, }, - user: mockPetitionerUser, + user: petitionerUser, }, }); diff --git a/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.ts b/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.ts index abb07fa8dee..bc874858495 100644 --- a/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionHeaderHelper.test.ts @@ -2,10 +2,10 @@ import { MOCK_TRIAL_REGULAR } from '@shared/test/mockTrial'; import { TRIAL_SESSION_SCOPE_TYPES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { - mockDocketClerkUser, - mockJudgeUser, - mockTrialClerkUser, -} from '@shared/test/mockAuthUsers'; + docketClerkUser, + judgeUser, + trialClerkUser, +} from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { trialSessionHeaderHelper as trialSessionHeaderHelperComputed } from './trialSessionHeaderHelper'; import { withAppContextDecorator } from '../../withAppContext'; @@ -47,7 +47,7 @@ describe('trialSessionHeaderHelper', () => { }; const { isStandaloneSession } = runCompute(trialSessionHeaderHelper, { - state: { ...baseState, user: mockDocketClerkUser }, + state: { ...baseState, user: docketClerkUser }, }); expect(isStandaloneSession).toEqual(true); @@ -57,7 +57,7 @@ describe('trialSessionHeaderHelper', () => { describe('nameToDisplay', () => { it("should be the assigned judge's name when the current user is NOT a trial clerk", () => { const result = runCompute(trialSessionHeaderHelper, { - state: { ...baseState, user: mockJudgeUser }, + state: { ...baseState, user: judgeUser }, }); expect(result.nameToDisplay).toBe( @@ -67,10 +67,10 @@ describe('trialSessionHeaderHelper', () => { it("should be the current user's name when the current user is a trial clerk", () => { const result = runCompute(trialSessionHeaderHelper, { - state: { ...baseState, user: mockTrialClerkUser }, + state: { ...baseState, user: trialClerkUser }, }); - expect(result.nameToDisplay).toBe(mockTrialClerkUser.name); + expect(result.nameToDisplay).toBe(trialClerkUser.name); }); }); @@ -82,7 +82,7 @@ describe('trialSessionHeaderHelper', () => { }; const result = runCompute(trialSessionHeaderHelper, { - state: { ...baseState, user: mockTrialClerkUser }, + state: { ...baseState, user: trialClerkUser }, }); expect(result.showBatchDownloadButton).toBe(false); @@ -95,7 +95,7 @@ describe('trialSessionHeaderHelper', () => { }; const result = runCompute(trialSessionHeaderHelper, { - state: { ...baseState, user: mockTrialClerkUser }, + state: { ...baseState, user: trialClerkUser }, }); expect(result.showBatchDownloadButton).toBe(true); @@ -110,7 +110,7 @@ describe('trialSessionHeaderHelper', () => { }; const result = runCompute(trialSessionHeaderHelper, { - state: { ...baseState, user: mockTrialClerkUser }, + state: { ...baseState, user: trialClerkUser }, }); expect(result.showPrintCalendarButton).toBe(true); @@ -133,7 +133,7 @@ describe('trialSessionHeaderHelper', () => { state: { ...baseState, permissions: { TRIAL_SESSIONS: true }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -147,11 +147,11 @@ describe('trialSessionHeaderHelper', () => { state: { ...baseState, currentPage: 'TrialSessionWorkingCopy', - judgeUser: { userId: mockJudgeUser.userId }, + judgeUser: { userId: judgeUser.userId }, trialSession: { judge: { userId: 'NOT_ASSIGNED' }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -166,7 +166,7 @@ describe('trialSessionHeaderHelper', () => { trialSession: { trialClerk: { userId: 'NOT_ASSIGNED' }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -179,9 +179,9 @@ describe('trialSessionHeaderHelper', () => { ...baseState, currentPage: 'TrialSessionDetail', trialSession: { - trialClerk: { userId: mockTrialClerkUser.userId }, + trialClerk: { userId: trialClerkUser.userId }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -194,9 +194,9 @@ describe('trialSessionHeaderHelper', () => { ...baseState, currentPage: 'TrialSessionWorkingCopy', trialSession: { - trialClerk: { userId: mockTrialClerkUser.userId }, + trialClerk: { userId: trialClerkUser.userId }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -208,11 +208,11 @@ describe('trialSessionHeaderHelper', () => { state: { ...baseState, currentPage: 'TrialSessionWorkingCopy', - judgeUser: { userId: mockJudgeUser.userId }, + judgeUser: { userId: judgeUser.userId }, trialSession: { - judge: { userId: mockJudgeUser.userId }, + judge: { userId: judgeUser.userId }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -226,11 +226,11 @@ describe('trialSessionHeaderHelper', () => { state: { ...baseState, currentPage: 'TrialSessionDetail', - judgeUser: { userId: mockJudgeUser.userId }, + judgeUser: { userId: judgeUser.userId }, trialSession: { judge: { userId: 'NOT_ASSIGNED' }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -245,7 +245,7 @@ describe('trialSessionHeaderHelper', () => { trialSession: { trialClerk: { userId: 'NOT_ASSIGNED' }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -258,9 +258,9 @@ describe('trialSessionHeaderHelper', () => { ...baseState, currentPage: 'TrialSessionWorkingCopy', trialSession: { - trialClerk: { userId: mockTrialClerkUser.userId }, + trialClerk: { userId: trialClerkUser.userId }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -273,9 +273,9 @@ describe('trialSessionHeaderHelper', () => { ...baseState, currentPage: 'TrialSessionDetail', trialSession: { - trialClerk: { userId: mockTrialClerkUser.userId }, + trialClerk: { userId: trialClerkUser.userId }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); @@ -287,11 +287,11 @@ describe('trialSessionHeaderHelper', () => { state: { ...baseState, currentPage: 'TrialSessionDetail', - judgeUser: { userId: mockJudgeUser.userId }, + judgeUser: { userId: judgeUser.userId }, trialSession: { - judge: { userId: mockJudgeUser.userId }, + judge: { userId: judgeUser.userId }, }, - user: mockTrialClerkUser, + user: trialClerkUser, }, }); diff --git a/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.ts index 73bb54e0a77..344a46aa535 100644 --- a/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsSummaryHelper.test.ts @@ -1,5 +1,5 @@ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; -import { mockChambersUser, mockJudgeUser } from '@shared/test/mockAuthUsers'; +import { colvinsChambersUser, judgeUser } from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { trialSessionsSummaryHelper as trialSessionsSummaryHelperComputed } from './trialSessionsSummaryHelper'; import { withAppContextDecorator } from '../../withAppContext'; @@ -17,11 +17,11 @@ describe('trialSessionsSummaryHelper', () => { it('should return the judeUserId as the logged in user when that user is a judge', () => { const result = runCompute(trialSessionsSummaryHelper, { state: { - user: mockJudgeUser, + user: judgeUser, }, }); - expect(result.judgeUserId).toEqual(mockJudgeUser.userId); + expect(result.judgeUserId).toEqual(judgeUser.userId); }); it('should return the judeUserId as the chambers judge associated with the logged in user', () => { @@ -29,12 +29,12 @@ describe('trialSessionsSummaryHelper', () => { state: { judgeUser: { role: ROLES.judge, - userId: mockJudgeUser.userId, + userId: judgeUser.userId, }, - user: mockChambersUser, + user: colvinsChambersUser, }, }); - expect(result.judgeUserId).toEqual(mockJudgeUser.userId); + expect(result.judgeUserId).toEqual(judgeUser.userId); }); }); diff --git a/web-client/src/presenter/computeds/workQueueHelper.test.ts b/web-client/src/presenter/computeds/workQueueHelper.test.ts index 1a3105eada7..98b401c38df 100644 --- a/web-client/src/presenter/computeds/workQueueHelper.test.ts +++ b/web-client/src/presenter/computeds/workQueueHelper.test.ts @@ -1,14 +1,14 @@ import { DOCKET_SECTION } from '../../../../shared/src/business/entities/EntityConstants'; +import { + adcUser, + caseServicesSupervisorUser, + colvinsChambersUser, + docketClerk1User, + judgeUser, + petitionsClerkUser, +} from '@shared/test/mockUsers'; import { applicationContext } from '../../applicationContext'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; -import { - mockAdcUser, - mockCaseServicesSupervisorUser, - mockChambersUser, - mockDocketClerkUser, - mockJudgeUser, - mockPetitionsClerkUser, -} from '@shared/test/mockAuthUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../../src/withAppContext'; import { workQueueHelper as workQueueHelperComputed } from './workQueueHelper'; @@ -27,9 +27,9 @@ describe('workQueueHelper', () => { it('returns the expected state when selected work items are set', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockPetitionsClerkUser), + ...getBaseState(petitionsClerkUser), selectedWorkItems: [true], - user: mockPetitionsClerkUser, + user: petitionsClerkUser, workQueueToDisplay: { box: 'inbox', queue: 'section' }, }, }); @@ -46,9 +46,9 @@ describe('workQueueHelper', () => { it('returns the expected state when selected work items are not set', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockPetitionsClerkUser), + ...getBaseState(petitionsClerkUser), selectedWorkItems: [], - user: mockPetitionsClerkUser, + user: petitionsClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -65,9 +65,9 @@ describe('workQueueHelper', () => { it('returns My Document QC for workQueueTitle if showing individual non-internal work queue', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockPetitionsClerkUser), + ...getBaseState(petitionsClerkUser), selectedWorkItems: [], - user: mockPetitionsClerkUser, + user: petitionsClerkUser, workQueueToDisplay: { queue: 'my', }, @@ -81,9 +81,9 @@ describe('workQueueHelper', () => { it('returns Document QC for workQueueTitle if showing section non-internal work queue and current user is not a docket or petitions clerk', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockAdcUser), + ...getBaseState(adcUser), selectedWorkItems: [], - user: mockAdcUser, + user: adcUser, workQueueToDisplay: { queue: 'section', }, @@ -97,9 +97,9 @@ describe('workQueueHelper', () => { it('returns Section Document QC for workQueueTitle if showing section non-internal work queue and current user is a docket clerk', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockDocketClerkUser), + ...getBaseState(docketClerk1User), selectedWorkItems: [], - user: mockDocketClerkUser, + user: docketClerk1User, workQueueToDisplay: { queue: 'section', }, @@ -113,9 +113,9 @@ describe('workQueueHelper', () => { it('should set workQueueTitle to a capitalized section specific title when the user is caseServicesSupervisor and workQueueToDisplay.section exists', () => { let result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockCaseServicesSupervisorUser), + ...getBaseState(caseServicesSupervisorUser), selectedWorkItems: [], - user: mockCaseServicesSupervisorUser, + user: caseServicesSupervisorUser, workQueueToDisplay: { queue: 'section', section: DOCKET_SECTION, @@ -129,9 +129,9 @@ describe('workQueueHelper', () => { it('should set workQueueTitle to "My Document QC" when the user is caseServicesSupervisor and workQueueToDisplay.section does not exist', () => { let result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockCaseServicesSupervisorUser), + ...getBaseState(caseServicesSupervisorUser), selectedWorkItems: [], - user: mockCaseServicesSupervisorUser, + user: caseServicesSupervisorUser, workQueueToDisplay: { queue: 'section', }, @@ -144,9 +144,9 @@ describe('workQueueHelper', () => { it('shows the start a case button when role is petitions clerk', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockPetitionsClerkUser), + ...getBaseState(petitionsClerkUser), selectedWorkItems: [], - user: mockPetitionsClerkUser, + user: petitionsClerkUser, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -158,9 +158,9 @@ describe('workQueueHelper', () => { it('does not show the start a case button when role is docket clerk', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockDocketClerkUser), + ...getBaseState(docketClerk1User), selectedWorkItems: [], - user: mockDocketClerkUser, + user: docketClerk1User, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -172,9 +172,9 @@ describe('workQueueHelper', () => { it('shows the case status column when role is judge', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockJudgeUser), + ...getBaseState(judgeUser), selectedWorkItems: [], - user: mockJudgeUser, + user: judgeUser, workQueueToDisplay: { box: 'inbox', queue: 'my' }, }, }); @@ -184,9 +184,9 @@ describe('workQueueHelper', () => { it('shows the case status column when role is chambers', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockChambersUser), + ...getBaseState(colvinsChambersUser), selectedWorkItems: [], - user: mockChambersUser, + user: colvinsChambersUser, workQueueToDisplay: { box: 'inbox', queue: 'my' }, }, }); @@ -196,9 +196,9 @@ describe('workQueueHelper', () => { it('shows the from column when role is judge', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockJudgeUser), + ...getBaseState(judgeUser), selectedWorkItems: [], - user: mockJudgeUser, + user: judgeUser, workQueueToDisplay: { box: 'inbox', queue: 'my' }, }, }); @@ -208,9 +208,9 @@ describe('workQueueHelper', () => { it('shows the from column when role is chambers', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockChambersUser), + ...getBaseState(colvinsChambersUser), selectedWorkItems: [], - user: mockChambersUser, + user: colvinsChambersUser, workQueueToDisplay: { box: 'inbox', queue: 'my' }, }, }); @@ -220,9 +220,9 @@ describe('workQueueHelper', () => { it('shows in progress petitions for a petitionsclerk', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockPetitionsClerkUser), + ...getBaseState(petitionsClerkUser), selectedWorkItems: [], - user: mockPetitionsClerkUser, + user: petitionsClerkUser, workQueueToDisplay: { box: 'inProgress', queue: 'section', @@ -237,9 +237,9 @@ describe('workQueueHelper', () => { it('should return expected flags when user is the case services supervisor', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockCaseServicesSupervisorUser), + ...getBaseState(caseServicesSupervisorUser), selectedWorkItems: [], - user: mockCaseServicesSupervisorUser, + user: caseServicesSupervisorUser, workQueueToDisplay: { box: 'inProgress', queue: 'section', @@ -258,10 +258,10 @@ describe('workQueueHelper', () => { it('returns the individualInboxCount for the work queue based on the value of state.individualInboxCount', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockDocketClerkUser), + ...getBaseState(docketClerk1User), individualInboxCount: 3, selectedWorkItems: [], - user: mockDocketClerkUser, + user: docketClerk1User, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -271,10 +271,10 @@ describe('workQueueHelper', () => { it('returns the individualInProgressCount for the work queue based on the value of state.individualInProgressCount', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockDocketClerkUser), + ...getBaseState(docketClerk1User), individualInProgressCount: 10, selectedWorkItems: [], - user: mockDocketClerkUser, + user: docketClerk1User, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -284,10 +284,10 @@ describe('workQueueHelper', () => { it('returns the sectionInboxCount for the work queue based on the value of state.sectionInboxCount', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockDocketClerkUser), + ...getBaseState(docketClerk1User), sectionInboxCount: 3, selectedWorkItems: [], - user: mockDocketClerkUser, + user: docketClerk1User, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -297,10 +297,10 @@ describe('workQueueHelper', () => { it('returns the sectionInProgressCount for the work queue based on the value of state.sectionInProgressCount', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockDocketClerkUser), + ...getBaseState(docketClerk1User), sectionInProgressCount: 10, selectedWorkItems: [], - user: mockDocketClerkUser, + user: docketClerk1User, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -313,10 +313,10 @@ describe('workQueueHelper', () => { const result = runCompute(workQueueHelper, { state: { - ...getBaseState(mockDocketClerkUser), + ...getBaseState(docketClerk1User), sectionInProgressCount: 10, selectedWorkItems: [], - user: mockDocketClerkUser, + user: docketClerk1User, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -330,10 +330,10 @@ describe('workQueueHelper', () => { it('should construct a path based on the queue and box values passed in', () => { const { documentQCNavigationPath } = runCompute(workQueueHelper, { state: { - ...getBaseState(mockDocketClerkUser), + ...getBaseState(docketClerk1User), sectionInProgressCount: 10, selectedWorkItems: [], - user: mockDocketClerkUser, + user: docketClerk1User, workQueueToDisplay: { box: 'outbox', queue: 'my' }, }, }); @@ -346,10 +346,10 @@ describe('workQueueHelper', () => { it('should construct a path based on the queue box, and section values when section is defined', () => { const { documentQCNavigationPath } = runCompute(workQueueHelper, { state: { - ...getBaseState(mockDocketClerkUser), + ...getBaseState(docketClerk1User), sectionInProgressCount: 10, selectedWorkItems: [], - user: mockDocketClerkUser, + user: docketClerk1User, workQueueToDisplay: { box: 'outbox', queue: 'my', @@ -370,10 +370,10 @@ describe('workQueueHelper', () => { it('showSwitchToMyDocQCLink should be false when the user is a case services supervisor', () => { const { showSwitchToMyDocQCLink } = runCompute(workQueueHelper, { state: { - ...getBaseState(mockCaseServicesSupervisorUser), + ...getBaseState(caseServicesSupervisorUser), sectionInProgressCount: 10, selectedWorkItems: [], - user: mockCaseServicesSupervisorUser, + user: caseServicesSupervisorUser, workQueueToDisplay: { box: 'outbox', queue: 'my', diff --git a/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts b/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts index c337e8f173d..b90dd0a4361 100644 --- a/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts +++ b/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts @@ -1,7 +1,7 @@ import { CerebralTest } from 'cerebral/test'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { chooseWorkQueueSequence } from '../sequences/chooseWorkQueueSequence'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; +import { docketClerk1User } from '@shared/test/mockUsers'; import { presenter } from '../presenter-mock'; describe('chooseWorkQueueSequence', () => { @@ -26,7 +26,7 @@ describe('chooseWorkQueueSequence', () => { chooseWorkQueueSequence, }; cerebralTest = CerebralTest(presenter); - cerebralTest.setState('user', mockDocketClerkUser); + cerebralTest.setState('user', docketClerk1User); }); it('should set the workQueueToDisplay to match the props passed in', async () => { diff --git a/web-client/src/presenter/sequences/gotoMessageDetailSequence.test.ts b/web-client/src/presenter/sequences/gotoMessageDetailSequence.test.ts index b5d64c5e24a..b4b029ec69f 100644 --- a/web-client/src/presenter/sequences/gotoMessageDetailSequence.test.ts +++ b/web-client/src/presenter/sequences/gotoMessageDetailSequence.test.ts @@ -5,8 +5,8 @@ import { import { CerebralTest } from 'cerebral/test'; import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { docketClerk1User } from '@shared/test/mockUsers'; import { gotoMessageDetailSequence } from '../sequences/gotoMessageDetailSequence'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { presenter } from '../presenter-mock'; describe('gotoMessageDetailSequence', () => { @@ -76,7 +76,7 @@ describe('gotoMessageDetailSequence', () => { //set token to take 'isLoggedIn' path cerebralTest.setState('token', 'a'); - cerebralTest.setState('user', mockDocketClerkUser); + cerebralTest.setState('user', docketClerk1User); }); it('should change the page to MyAccount and close the opened menu', async () => { diff --git a/web-client/src/presenter/sequences/gotoMessagesSequence.test.ts b/web-client/src/presenter/sequences/gotoMessagesSequence.test.ts index 43243d8031a..ef2eb0dd875 100644 --- a/web-client/src/presenter/sequences/gotoMessagesSequence.test.ts +++ b/web-client/src/presenter/sequences/gotoMessagesSequence.test.ts @@ -1,7 +1,7 @@ import { CerebralTest } from 'cerebral/test'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { docketClerk1User } from '@shared/test/mockUsers'; import { gotoMessagesSequence } from '../sequences/gotoMessagesSequence'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { presenter } from '../presenter-mock'; describe('gotoMessagesSequence', () => { @@ -35,7 +35,7 @@ describe('gotoMessagesSequence', () => { //set token to take 'isLoggedIn' path cerebralTest.setState('token', 'a'); - cerebralTest.setState('user', mockDocketClerkUser); + cerebralTest.setState('user', docketClerk1User); }); it('should change the page to MyAccount and close the opened menu', async () => { From b3bbeb0a46c869b3dc8bd1e946e29a201663e6dc Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 10:14:06 -0500 Subject: [PATCH 276/523] 10417 remove getCurrentUser from updateUserContactInformationInteractor --- ...ntactInformationInteractor.locking.test.ts | 26 ++- ...teUserContactInformationInteractor.test.ts | 166 +++++++++++------- .../updateUserContactInformationInteractor.ts | 15 +- .../updateUserContactInformationLambda.ts | 20 ++- 4 files changed, 143 insertions(+), 84 deletions(-) diff --git a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.locking.test.ts b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.locking.test.ts index f674d3fdacb..529d15fd50f 100644 --- a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.locking.test.ts +++ b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.locking.test.ts @@ -3,6 +3,7 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { MOCK_PRACTITIONER } from '../../../../../shared/src/test/mockUsers'; import { ServiceUnavailableError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { determineEntitiesToLock, @@ -60,16 +61,15 @@ describe('determineEntitiesToLock', () => { }); describe('handleLockError', () => { - it('should determine who the user is based on applicationContext', async () => { - await handleLockError(applicationContext, { foo: 'bar' }); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it('should send a notification to the user with "retry_async_request" and the originalRequest', async () => { const mockOriginalRequest = { foo: 'bar', }; - await handleLockError(applicationContext, mockOriginalRequest); + await handleLockError( + applicationContext, + mockOriginalRequest, + MOCK_PRACTITIONER as UnknownAuthUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -129,7 +129,11 @@ describe('updateUserContactInformationInteractor', () => { it('should throw a ServiceUnavailableError if a Case is currently locked', async () => { await expect( - updateUserContactInformationInteractor(applicationContext, mockRequest), + updateUserContactInformationInteractor( + applicationContext, + mockRequest, + MOCK_PRACTITIONER as UnknownAuthUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -139,7 +143,11 @@ describe('updateUserContactInformationInteractor', () => { it('should return a "retry_async_request" notification with the original request', async () => { await expect( - updateUserContactInformationInteractor(applicationContext, mockRequest), + updateUserContactInformationInteractor( + applicationContext, + mockRequest, + MOCK_PRACTITIONER as UnknownAuthUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -169,6 +177,7 @@ describe('updateUserContactInformationInteractor', () => { await updateUserContactInformationInteractor( applicationContext, mockRequest, + MOCK_PRACTITIONER as UnknownAuthUser, ); expect( @@ -184,6 +193,7 @@ describe('updateUserContactInformationInteractor', () => { await updateUserContactInformationInteractor( applicationContext, mockRequest, + MOCK_PRACTITIONER as UnknownAuthUser, ); expect( diff --git a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.test.ts b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.test.ts index e1db0a7dcf8..109a3bb415d 100644 --- a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.test.ts +++ b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.test.ts @@ -14,6 +14,7 @@ jest.mock('./generateChangeOfAddress'); import { IrsPractitioner } from '@shared/business/entities/IrsPractitioner'; import { Practitioner } from '@shared/business/entities/Practitioner'; import { generateChangeOfAddress } from './generateChangeOfAddress'; +import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; describe('updateUserContactInformationInteractor', () => { let mockUser; @@ -30,10 +31,6 @@ describe('updateUserContactInformationInteractor', () => { state: 'IL', }; - beforeAll(() => { - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - }); - beforeEach(() => { mockUser = { ...irsPractitionerUser, @@ -62,34 +59,43 @@ describe('updateUserContactInformationInteractor', () => { }); it('should throw unauthorized error when user does not have permission to update contact information', async () => { - mockUser = { - role: ROLES.petitionsClerk, - userId: 'asdf1234-f6cd-442c-a168-202db587f16f', - }; + mockUser = mockPetitionsClerkUser; await expect( - updateUserContactInformationInteractor(applicationContext, { - contactInfo, - userId: mockUser.userId, - } as any), + updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + userId: mockUser.userId, + } as any, + mockUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should throw unauthorized error when the user attempts to modify contact information for a different user', async () => { await expect( - updateUserContactInformationInteractor(applicationContext, { - contactInfo, - userId: 'asdf1234-f6cd-442c-a168-202db587f16f', - } as any), + updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + userId: 'asdf1234-f6cd-442c-a168-202db587f16f', + } as any, + mockUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should return without updating user or cases when the contact information has not changed', async () => { - await updateUserContactInformationInteractor(applicationContext, { - contactInfo: mockUser.contact, - firmName: 'broken', - userId: mockUser.userId, - }); + await updateUserContactInformationInteractor( + applicationContext, + { + contactInfo: mockUser.contact, + firmName: 'broken', + userId: mockUser.userId, + }, + mockUser, + ); expect(applicationContext.getUseCases().updateUser).not.toHaveBeenCalled(); expect(generateChangeOfAddress).not.toHaveBeenCalled(); @@ -119,10 +125,14 @@ describe('updateUserContactInformationInteractor', () => { }); await expect( - updateUserContactInformationInteractor(applicationContext, { - contactInfo, - userId: mockUser.userId, - } as any), + updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + userId: mockUser.userId, + } as any, + mockUser, + ), ).rejects.toThrow('something wicked'); expect( @@ -148,10 +158,14 @@ describe('updateUserContactInformationInteractor', () => { practitionerType: PRACTITIONER_TYPE_OPTIONS[0], role: ROLES.irsPractitioner, }; - await updateUserContactInformationInteractor(applicationContext, { - contactInfo, - userId: mockUser.userId, - } as any); + await updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + userId: mockUser.userId, + } as any, + mockUser, + ); expect( applicationContext.getPersistenceGateway().updateUser.mock.calls[0][0] @@ -182,10 +196,14 @@ describe('updateUserContactInformationInteractor', () => { role: ROLES.irsPractitioner, }; - await updateUserContactInformationInteractor(applicationContext, { - contactInfo, - userId: mockUser.userId, - } as any); + await updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + userId: mockUser.userId, + } as any, + mockUser, + ); expect( applicationContext.getPersistenceGateway().updateUser.mock.calls[0][0] @@ -202,10 +220,14 @@ describe('updateUserContactInformationInteractor', () => { }); await expect( - updateUserContactInformationInteractor(applicationContext, { - contactInfo, - userId: mockUser.userId, - } as any), + updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + userId: mockUser.userId, + } as any, + mockUser, + ), ).rejects.toThrow(); expect( @@ -224,10 +246,14 @@ describe('updateUserContactInformationInteractor', () => { }); it('should generate a change of address document', async () => { - await updateUserContactInformationInteractor(applicationContext, { - contactInfo, - userId: mockUser.userId, - } as any); + await updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + userId: mockUser.userId, + } as any, + mockUser, + ); expect(generateChangeOfAddress).toHaveBeenCalled(); }); @@ -235,26 +261,30 @@ describe('updateUserContactInformationInteractor', () => { it('should clean up DB and send websocket message if "generateChangeOfAddress" returns empty array', async () => { (generateChangeOfAddress as jest.Mock).mockReturnValue([]); - await updateUserContactInformationInteractor(applicationContext, { - contactInfo, - userId: mockUser.userId, - } as any); + await updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + userId: mockUser.userId, + } as any, + mockUser, + ); expect( applicationContext.getPersistenceGateway().updateUser.mock.calls[1][0] .isUpdatingInformation, ).not.toBeDefined(); - const notificatsionCalls = + const notificationCalls = applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls; expect( - notificatsionCalls[notificatsionCalls.length - 1][0].message.action, + notificationCalls[notificationCalls.length - 1][0].message.action, ).toEqual('user_contact_full_update_complete'); expect( - notificatsionCalls[notificatsionCalls.length - 1][0].message.user, + notificationCalls[notificationCalls.length - 1][0].message.user, ).toMatchObject({ contact: contactInfo, }); @@ -263,10 +293,14 @@ describe('updateUserContactInformationInteractor', () => { it('should not clean up DB and send websocket message if "generateChangeOfAddress" returns undefined', async () => { (generateChangeOfAddress as jest.Mock).mockReturnValue(undefined); - await updateUserContactInformationInteractor(applicationContext, { - contactInfo, - userId: mockUser.userId, - } as any); + await updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + userId: mockUser.userId, + } as any, + mockUser, + ); expect( applicationContext.getPersistenceGateway().updateUser.mock.calls.length, @@ -282,11 +316,15 @@ describe('updateUserContactInformationInteractor', () => { }); it('should update the firmName if user is a practitioner and firmName is passed in', async () => { - await updateUserContactInformationInteractor(applicationContext, { - contactInfo, - firmName: 'testing', - userId: mockUser.userId, - }); + await updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + firmName: 'testing', + userId: mockUser.userId, + }, + mockUser, + ); expect( applicationContext.getPersistenceGateway().updateUser.mock.calls[0][0] .user, @@ -303,11 +341,15 @@ describe('updateUserContactInformationInteractor', () => { contact: contactInfo, })); - await updateUserContactInformationInteractor(applicationContext, { - contactInfo, - firmName: mockUser.firmName, - userId: mockUser.userId, - }); + await updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + firmName: mockUser.firmName, + userId: mockUser.userId, + }, + mockUser, + ); expect( applicationContext.getPersistenceGateway().updateUser, diff --git a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts index 2c63e7b69bb..0583fe9c487 100644 --- a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts @@ -7,6 +7,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { generateChangeOfAddress } from './generateChangeOfAddress'; import { isArray, isEqual } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -137,12 +138,11 @@ export const updateUserContactInformation = async ( firmName, userId, }: { contactInfo: any; firmName: string; userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authenticatedUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(authenticatedUser, ROLE_PERMISSIONS.UPDATE_CONTACT_INFO) || - authenticatedUser.userId !== userId + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPDATE_CONTACT_INFO) || + authorizedUser?.userId !== userId ) { throw new UnauthorizedError('Unauthorized'); } @@ -161,7 +161,7 @@ export const updateUserContactInformation = async ( action: 'user_contact_update_error', error: (error as Error).toString(), }, - userId: authenticatedUser.userId, + userId: authorizedUser.userId, }); throw error; } @@ -170,9 +170,8 @@ export const updateUserContactInformation = async ( export const handleLockError = async ( applicationContext: ServerApplicationContext, originalRequest: any, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - await applicationContext.getNotificationGateway().sendNotificationToUser({ applicationContext, message: { @@ -180,7 +179,7 @@ export const handleLockError = async ( originalRequest, requestToRetry: 'update_user_contact_information', }, - userId: user.userId, + userId: authorizedUser?.userId || '', }); }; diff --git a/web-api/src/lambdas/users/updateUserContactInformationLambda.ts b/web-api/src/lambdas/users/updateUserContactInformationLambda.ts index 1e8df31f57b..f2fe62132d6 100644 --- a/web-api/src/lambdas/users/updateUserContactInformationLambda.ts +++ b/web-api/src/lambdas/users/updateUserContactInformationLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,14 +7,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateUserContactInformationLambda = event => +export const updateUserContactInformationLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { contactInfo, firmName } = JSON.parse(event.body); return await applicationContext .getUseCases() - .updateUserContactInformationInteractor(applicationContext, { - contactInfo, - firmName, - userId: (event.pathParameters || event.path).userId, - }); + .updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + firmName, + userId: (event.pathParameters || event.path).userId, + }, + authorizedUser, + ); }); From 18f619b89c05356e7ea212fdb4b920aee8c06e57 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:32:33 -0500 Subject: [PATCH 277/523] 10417: remove getCurrentUser from editPaperFilingInteractor --- ...serveCourtIssuedDocumentInteractor.test.ts | 2 - .../editPaperFilingInteractor.test.ts | 417 ++++++++++-------- .../docketEntry/editPaperFilingInteractor.ts | 16 +- .../documents/editPaperFilingLambda.ts | 12 +- 4 files changed, 256 insertions(+), 191 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts index b26bf4e4c68..81976784251 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts @@ -42,8 +42,6 @@ describe('serveCourtIssuedDocumentInteractor', () => { }); it('should throw an error when the user role does not have permission to serve a court issued document', async () => { - // applicationContext.getCurrentUser.mockReturnValue({}); - await expect( serveCourtIssuedDocumentInteractor( applicationContext, diff --git a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.test.ts b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.test.ts index aa6251949e4..e1d7318e0e8 100644 --- a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.test.ts @@ -6,12 +6,13 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { - docketClerkUser, - petitionerUser, -} from '../../../../../shared/src/test/mockUsers'; +import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; import { editPaperFilingInteractor } from './editPaperFilingInteractor'; import { getContactPrimary } from '../../../../../shared/src/business/entities/cases/Case'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('editPaperFilingInteractor', () => { let caseRecord; @@ -73,8 +74,6 @@ describe('editPaperFilingInteractor', () => { ], }; - applicationContext.getCurrentUser.mockImplementation(() => docketClerkUser); - applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); @@ -87,24 +86,24 @@ describe('editPaperFilingInteractor', () => { describe('Save For Later or Serve Agnostic', () => { describe('Sad Path', () => { it('should throw an error when the user is not authorized to edit docket entries', async () => { - applicationContext.getCurrentUser.mockImplementation( - () => petitionerUser, - ); - await expect( - editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'My Document', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filers: [mockPrimaryId], - isFileAttached: false, + editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'My Document', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filers: [mockPrimaryId], + isFileAttached: false, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }), + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -112,12 +111,16 @@ describe('editPaperFilingInteractor', () => { const notFoundDocketEntryId = 'this is not an ID'; await expect( - editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: notFoundDocketEntryId, - documentMetadata: {}, - isSavingForLater: true, - }), + editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: notFoundDocketEntryId, + documentMetadata: {}, + isSavingForLater: true, + }, + mockDocketClerkUser, + ), ).rejects.toThrow( `Docket entry ${notFoundDocketEntryId} was not found.`, ); @@ -125,15 +128,19 @@ describe('editPaperFilingInteractor', () => { it('should throw an error when the docket entry has already been served', async () => { await expect( - editPaperFilingInteractor(applicationContext, { - clientConnectionId, + editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, - docketEntryId: mockServedDocketEntryId, - documentMetadata: { - docketNumber: caseRecord.docketNumber, + docketEntryId: mockServedDocketEntryId, + documentMetadata: { + docketNumber: caseRecord.docketNumber, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }), + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry has already been served'); }); @@ -142,12 +149,16 @@ describe('editPaperFilingInteractor', () => { docketEntry.isPendingService = true; await expect( - editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: docketEntry.docketEntryId, - documentMetadata: docketEntry, - isSavingForLater: false, - }), + editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: docketEntry.docketEntryId, + documentMetadata: docketEntry, + isSavingForLater: false, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry is already being served'); expect( @@ -165,19 +176,23 @@ describe('editPaperFilingInteractor', () => { .getUseCaseHelpers() .countPagesInDocument.mockResolvedValueOnce(2); - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'My Document', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filers: [mockPrimaryId], - isFileAttached: true, + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'My Document', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filers: [mockPrimaryId], + isFileAttached: true, + }, + isSavingForLater: true, }, - isSavingForLater: true, - }); + mockDocketClerkUser, + ); const updatedDocketEntry = applicationContext .getUseCaseHelpers() @@ -194,19 +209,23 @@ describe('editPaperFilingInteractor', () => { }); it('should update the docket entry without updating the page count when the docket entry does NOT have a file attached', async () => { - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'My Document', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filers: [mockPrimaryId], - isFileAttached: false, + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'My Document', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filers: [mockPrimaryId], + isFileAttached: false, + }, + isSavingForLater: true, }, - isSavingForLater: true, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -223,12 +242,16 @@ describe('editPaperFilingInteractor', () => { }); it('should not call the persistence method to set and unset the pending service status on the docket entry', async () => { - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: caseRecord.docketEntries[0], - isSavingForLater: true, - }); + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: caseRecord.docketEntries[0], + isSavingForLater: true, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -237,12 +260,16 @@ describe('editPaperFilingInteractor', () => { }); it('should not generate a paper service url', async () => { - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: caseRecord.docketEntries[0], - isSavingForLater: true, - }); + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: caseRecord.docketEntries[0], + isSavingForLater: true, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -251,12 +278,16 @@ describe('editPaperFilingInteractor', () => { }); it('should send a message to the user when persisting edits has completed', async () => { - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: caseRecord.docketEntries[0], - isSavingForLater: true, - }); + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: caseRecord.docketEntries[0], + isSavingForLater: true, + }, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser, @@ -281,25 +312,30 @@ describe('editPaperFilingInteractor', () => { describe('Single Docketing', () => { describe('Happy Path', () => { it('should update only allowed editable fields on a docket entry document', async () => { - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: { - docketEntryId: - 'maliciously Update Docket Entry Id. DONT SAVE ME.', - docketNumber: 'maliciously Updated Docket Number. DONT SAVE ME.', - documentTitle: 'My Edited Document', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - filers: [mockPrimaryId], - freeText: 'Some text about this document', - hasOtherFilingParty: true, - isFileAttached: true, - isPaper: true, - otherFilingParty: 'Bert Brooks', + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: { + docketEntryId: + 'maliciously Update Docket Entry Id. DONT SAVE ME.', + docketNumber: + 'maliciously Updated Docket Number. DONT SAVE ME.', + documentTitle: 'My Edited Document', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + filers: [mockPrimaryId], + freeText: 'Some text about this document', + hasOtherFilingParty: true, + isFileAttached: true, + isPaper: true, + otherFilingParty: 'Bert Brooks', + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); const updatedDocketEntry = applicationContext .getPersistenceGateway() @@ -318,12 +354,16 @@ describe('editPaperFilingInteractor', () => { }); it('should call the persistence method to set and unset the pending service status on the docket entry', async () => { - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: caseRecord.docketEntries[0], - isSavingForLater: false, - }); + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: caseRecord.docketEntries[0], + isSavingForLater: false, + }, + mockDocketClerkUser, + ); const firstStatusCall = applicationContext.getPersistenceGateway() @@ -345,17 +385,21 @@ describe('editPaperFilingInteractor', () => { pdfUrl: mockPdfUrl, }); - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: { - documentTitle: 'My Document', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - isFileAttached: true, + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: { + documentTitle: 'My Document', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + isFileAttached: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser, @@ -386,12 +430,16 @@ describe('editPaperFilingInteractor', () => { ); await expect( - editPaperFilingInteractor(applicationContext, { - clientConnectionId, - docketEntryId: mockDocketEntryId, - documentMetadata: caseRecord.docketEntries[0], - isSavingForLater: false, - }), + editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: mockDocketEntryId, + documentMetadata: caseRecord.docketEntries[0], + isSavingForLater: false, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('whoops, that is an error!'); const firstStatusCall = @@ -425,18 +473,23 @@ describe('editPaperFilingInteractor', () => { }); const mockConsolidatedGroupDocketNumbers = ['101-23', '101-24']; - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - consolidatedGroupDocketNumbers: mockConsolidatedGroupDocketNumbers, - docketEntryId: mockDocketEntryId, - documentMetadata: { - documentTitle: 'My Document', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - isFileAttached: true, + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + consolidatedGroupDocketNumbers: + mockConsolidatedGroupDocketNumbers, + docketEntryId: mockDocketEntryId, + documentMetadata: { + documentTitle: 'My Document', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + isFileAttached: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); const expectedCount = [ caseRecord.docketNumber, @@ -476,19 +529,23 @@ describe('editPaperFilingInteractor', () => { pdfUrl: mockedPaperServicePdfUrl, }); - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - consolidatedGroupDocketNumbers: ['101-23', '101-24'], - docketEntryId: mockDocketEntryId, - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'My Document', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - isFileAttached: true, + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + consolidatedGroupDocketNumbers: ['101-23', '101-24'], + docketEntryId: mockDocketEntryId, + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'My Document', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + isFileAttached: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -542,19 +599,23 @@ describe('editPaperFilingInteractor', () => { .getUseCaseHelpers() .serveDocumentAndGetPaperServicePdf.mockResolvedValue(undefined); - await editPaperFilingInteractor(applicationContext, { - clientConnectionId, - consolidatedGroupDocketNumbers: ['101-23', '101-24'], - docketEntryId: mockDocketEntryId, - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'My Document', - documentType: 'Memorandum in Support', - eventCode: 'MISP', - isFileAttached: true, + await editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + consolidatedGroupDocketNumbers: ['101-23', '101-24'], + docketEntryId: mockDocketEntryId, + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'My Document', + documentType: 'Memorandum in Support', + eventCode: 'MISP', + isFileAttached: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }); + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser, @@ -593,13 +654,17 @@ describe('editPaperFilingInteractor', () => { }); await expect( - editPaperFilingInteractor(applicationContext, { - clientConnectionId, - consolidatedGroupDocketNumbers: [nonConsolidatedDocketNumber], - docketEntryId: mockDocketEntryId, - documentMetadata: caseRecord.docketEntries[0], - isSavingForLater: false, - }), + editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + consolidatedGroupDocketNumbers: [nonConsolidatedDocketNumber], + docketEntryId: mockDocketEntryId, + documentMetadata: caseRecord.docketEntries[0], + isSavingForLater: false, + }, + mockDocketClerkUser, + ), ).rejects.toThrow( 'Cannot multi-docket on a case that is not consolidated', ); @@ -614,16 +679,20 @@ describe('editPaperFilingInteractor', () => { }); await expect( - editPaperFilingInteractor(applicationContext, { - clientConnectionId, - consolidatedGroupDocketNumbers: ['101-23'], - docketEntryId: mockDocketEntryId, - documentMetadata: { - docketNumber: caseRecord.docketNumber, - isFileAttached: true, + editPaperFilingInteractor( + applicationContext, + { + clientConnectionId, + consolidatedGroupDocketNumbers: ['101-23'], + docketEntryId: mockDocketEntryId, + documentMetadata: { + docketNumber: caseRecord.docketNumber, + isFileAttached: true, + }, + isSavingForLater: false, }, - isSavingForLater: false, - }), + mockDocketClerkUser, + ), ).rejects.toThrow( 'Cannot multi-docket on a case that is not consolidated', ); diff --git a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts index 0c870254a31..87f27f19acc 100644 --- a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts @@ -14,6 +14,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { RawUser } from '@shared/business/entities/User'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { cloneDeep, uniq } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -34,11 +35,14 @@ interface IEditPaperFilingRequest { export const editPaperFiling = async ( applicationContext: ServerApplicationContext, request: IEditPaperFilingRequest, + authorizedUser: UnknownAuthUser, ) => { request.consolidatedGroupDocketNumbers = request.consolidatedGroupDocketNumbers || []; - authorizeRequest(applicationContext); + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY)) { + throw new UnauthorizedError('Unauthorized'); + } const { caseEntity, docketEntryEntity } = await getDocketEntryToEdit({ applicationContext, @@ -370,16 +374,6 @@ const validateMultiDocketPaperFilingRequest = ({ }); }; -const authorizeRequest = ( - applicationContext: ServerApplicationContext, -): void => { - const authorizedUser = applicationContext.getCurrentUser(); - - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY)) { - throw new UnauthorizedError('Unauthorized'); - } -}; - const updateDocketEntry = async ({ applicationContext, caseEntity, diff --git a/web-api/src/lambdas/documents/editPaperFilingLambda.ts b/web-api/src/lambdas/documents/editPaperFilingLambda.ts index ebd94536771..32c15b488dc 100644 --- a/web-api/src/lambdas/documents/editPaperFilingLambda.ts +++ b/web-api/src/lambdas/documents/editPaperFilingLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { editPaperFilingInteractor } from '@web-api/business/useCases/docketEntry/editPaperFilingInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,9 +8,11 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const editPaperFilingLambda = event => +export const editPaperFilingLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .editPaperFilingInteractor(applicationContext, JSON.parse(event.body)); + return await editPaperFilingInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); }); From bc2674862cdf34514fb74285d687a4cb85d47214 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Fri, 19 Jul 2024 09:02:37 -0700 Subject: [PATCH 278/523] 10417: remove appcontext.getCurrentUser from updateDocketEntryMetaInteractor --- .../updateDocketEntryMetaInteractor.test.ts | 409 +++++++++++------- .../updateDocketEntryMetaInteractor.ts | 12 +- .../documents/updateDocketEntryMetaLambda.ts | 24 +- 3 files changed, 272 insertions(+), 173 deletions(-) diff --git a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.ts b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.ts index 87c7ab16acd..1a734e04448 100644 --- a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.ts @@ -6,9 +6,10 @@ import { UnauthorizedError, } from '@web-api/errors/errors'; import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; import { getContactPrimary } from '../../../../../shared/src/business/entities/cases/Case'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { updateDocketEntryMetaInteractor } from './updateDocketEntryMetaInteractor'; describe('updateDocketEntryMetaInteractor', () => { @@ -121,7 +122,7 @@ describe('updateDocketEntryMetaInteractor', () => { }, ]; - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); + // applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); applicationContext .getPersistenceGateway() @@ -155,10 +156,14 @@ describe('updateDocketEntryMetaInteractor', () => { mockLock = MOCK_LOCK; await expect( - updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: mockDocketEntries[0], - docketNumber: MOCK_CASE.docketNumber, - }), + updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: mockDocketEntries[0], + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -167,10 +172,14 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: mockDocketEntries[0], - docketNumber: MOCK_CASE.docketNumber, - }); + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: mockDocketEntries[0], + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -189,13 +198,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should throw an Unauthorized error if the user is not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); + // applicationContext.getCurrentUser.mockReturnValue({}); await expect( - updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: undefined, - docketNumber: MOCK_CASE.docketNumber, - }), + updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: undefined, + docketNumber: MOCK_CASE.docketNumber, + }, + {} as UnknownAuthUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -204,59 +217,83 @@ describe('updateDocketEntryMetaInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(undefined); await expect( - updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: undefined, - docketNumber: '999-99', - }), + updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: undefined, + docketNumber: '999-99', + }, + mockDocketClerkUser, + ), ).rejects.toThrow(NotFoundError); }); it('should throw an error when the docket entry has not been served', async () => { await expect( - updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - docketEntryId: mockDocketEntries[3].docketEntryId, // Order that has not been served + updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + docketEntryId: mockDocketEntries[3].docketEntryId, // Order that has not been served + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }), + mockDocketClerkUser, + ), ).rejects.toThrow('Unable to update unserved docket entry.'); }); it('should throw an error when the docket entry is not found on the case', async () => { await expect( - updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[6], - docketEntryId: 'not-a-guid', + updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[6], + docketEntryId: 'not-a-guid', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }), + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry with id not-a-guid not found.'); }); it("should not throw an error when the docket entry has not been served and it's unservable", async () => { await expect( - updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: mockDocketEntries[4], // Unservable document - docketNumber: MOCK_CASE.docketNumber, - }), + updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: mockDocketEntries[4], // Unservable document + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); }); it("should not throw an error when the docket entry has not been served and it's a minute entry", async () => { await expect( - updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: mockDocketEntries[7], // Minute entry - docketNumber: MOCK_CASE.docketNumber, - }), + updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: mockDocketEntries[7], // Minute entry + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); }); it('should call the persistence method to load the case by its docket number', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: mockDocketEntries[0], - docketNumber: MOCK_CASE.docketNumber, - }); + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: mockDocketEntries[0], + docketNumber: MOCK_CASE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -274,13 +311,17 @@ describe('updateDocketEntryMetaInteractor', () => { servedAt: '2020-01-01T00:01:00.000Z', }; - const result = await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - ...editedFields, + const result = await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + ...editedFields, + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); const updatedDocketEntry = result.docketEntries.find( record => record.index === 1, @@ -289,13 +330,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should update a non-required field to undefined if undefined value is passed in', async () => { - const result = await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - freeText: undefined, + const result = await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + freeText: undefined, + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); const updatedDocketEntry = result.docketEntries.find( record => record.index === 1, @@ -304,13 +349,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should generate a new coversheet for the document if the servedAt field is changed', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - servedAt: '2020-01-01T00:01:00.000Z', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + servedAt: '2020-01-01T00:01:00.000Z', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -318,13 +367,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should NOT generate a new coversheet for the document if the servedAt field metadata formatted as YYYY-MM-DD is equivalent to the strict ISO formatted date on the entity', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - servedAt: '2019-01-01', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + servedAt: '2019-01-01', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -334,15 +387,19 @@ describe('updateDocketEntryMetaInteractor', () => { it('should generate a new coversheet for the document if the filingDate field is changed on a document that requires a coversheet', async () => { mockDocketEntries[3].servedAt = '2012-02-22T02:22:00.000Z'; mockDocketEntries[3].servedParties = [{ name: 'bob evans' }]; - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[3], // originally an Order - documentType: 'U.S.C.A', - eventCode: 'USCA', // changing to USCA - which DOES require a coversheet - filingDate: '2020-02-22T02:22:00.000Z', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[3], // originally an Order + documentType: 'U.S.C.A', + eventCode: 'USCA', // changing to USCA - which DOES require a coversheet + filingDate: '2020-02-22T02:22:00.000Z', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -350,13 +407,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should generate a new coversheet for the document if the filingDate field is changed on a document that requires a coversheet', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[4], // was already a USCA - which DOES require a coversheet - filingDate: '2012-02-22T02:22:00.000Z', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[4], // was already a USCA - which DOES require a coversheet + filingDate: '2012-02-22T02:22:00.000Z', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -376,13 +437,17 @@ describe('updateDocketEntryMetaInteractor', () => { mockDocketEntries[4].servedParties = [{ name: 'bob evans' }]; expect(mockDocketEntries[4].eventCode).toBe('USCA'); // requires a cover sheet. - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[4], - eventCode: 'MISC', // does NOT require a cover sheet + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[4], + eventCode: 'MISC', // does NOT require a cover sheet + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().removeCoversheet, @@ -390,13 +455,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should not generate a coversheet for the document if the filingDate field is changed on a document that does NOT require a coversheet', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[5], // HEAR - which does NOT require a coversheet - filingDate: '2012-02-22T02:22:00.000Z', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[5], // HEAR - which does NOT require a coversheet + filingDate: '2012-02-22T02:22:00.000Z', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -404,13 +473,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should not generate a new coversheet for a court-issued docket entry if the servedAt field is changed', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[1], - servedAt: '2019-01-02T00:01:00.000Z', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[1], + servedAt: '2019-01-02T00:01:00.000Z', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -418,13 +491,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should make a call to update the docketEntryEntity before adding a coversheet when the filingDate field is changed', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - filingDate: '2020-08-01T00:01:00.000Z', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + filingDate: '2020-08-01T00:01:00.000Z', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateDocketEntry.mock @@ -436,13 +513,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should add a new coversheet when filingDate field is changed', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - filingDate: '2020-01-01T00:01:00.000Z', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + filingDate: '2020-01-01T00:01:00.000Z', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor.mock.calls[0][1], @@ -453,14 +534,18 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should NOT generate a new coversheet for the document if the servedAt and filingDate fields are NOT changed', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - filingDate: mockDocketEntries[0].filingDate, - servedAt: mockDocketEntries[0].servedAt, + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + filingDate: mockDocketEntries[0].filingDate, + servedAt: mockDocketEntries[0].servedAt, + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -468,13 +553,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should not call addCoversheetInteractor if filingDate field is changed and the docket entry is a minute entry', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[2], // minute entry - filingDate: '2020-01-01T00:01:00.000Z', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[2], // minute entry + filingDate: '2020-01-01T00:01:00.000Z', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -482,13 +571,17 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should call the updateCase persistence method', async () => { - await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - documentTitle: 'Updated Description', + await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + documentTitle: 'Updated Description', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -497,28 +590,36 @@ describe('updateDocketEntryMetaInteractor', () => { it('should not throw an error when a null certificate of service date is passed for a docket entry without an associated document', async () => { await expect( - updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - action: 'asdf', - certificateOfServiceDate: null, - documentTitle: 'Request for Place of Trial at Houston, Texas', - eventCode: 'RQT', - filingDate: '2020-02-03T08:06:07.539Z', + updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + action: 'asdf', + certificateOfServiceDate: null, + documentTitle: 'Request for Place of Trial at Houston, Texas', + eventCode: 'RQT', + filingDate: '2020-02-03T08:06:07.539Z', + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }), + mockDocketClerkUser, + ), ).resolves.not.toThrow(); }); it('should update the document pending status and the automatic blocked status of the case when setting pending to true', async () => { - const result = await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - pending: true, + const result = await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + pending: true, + }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); const updatedDocketEntry = result.docketEntries.find( record => record.index === 1, @@ -530,15 +631,19 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should update the previousDocument', async () => { - const result = await updateDocketEntryMetaInteractor(applicationContext, { - docketEntryMeta: { - ...mockDocketEntries[0], - previousDocument: { - ...mockDocketEntries[1], + const result = await updateDocketEntryMetaInteractor( + applicationContext, + { + docketEntryMeta: { + ...mockDocketEntries[0], + previousDocument: { + ...mockDocketEntries[1], + }, }, + docketNumber: MOCK_CASE.docketNumber, }, - docketNumber: MOCK_CASE.docketNumber, - }); + mockDocketClerkUser, + ); const updatedDocketEntry = result.docketEntries.find( record => record.index === 1, diff --git a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts index 48e453fdfac..7d1b8dba4d6 100644 --- a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts @@ -10,27 +10,19 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createISODateString } from '../../../../../shared/src/business/utilities/DateHandler'; import { getDocumentTitleWithAdditionalInfo } from '../../../../../shared/src/business/utilities/getDocumentTitleWithAdditionalInfo'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -/** - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.docketEntryMeta the docket entry metadata - * @param {object} providers.docketNumber the docket number of the case to be updated - * @returns {object} the updated case after the documents are added - */ export const updateDocketEntryMeta = async ( applicationContext: ServerApplicationContext, { docketEntryMeta, docketNumber, }: { docketEntryMeta: any; docketNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.EDIT_DOCKET_ENTRY)) { throw new UnauthorizedError('Unauthorized to update docket entry'); } diff --git a/web-api/src/lambdas/documents/updateDocketEntryMetaLambda.ts b/web-api/src/lambdas/documents/updateDocketEntryMetaLambda.ts index 08b6fac5c34..e3264759676 100644 --- a/web-api/src/lambdas/documents/updateDocketEntryMetaLambda.ts +++ b/web-api/src/lambdas/documents/updateDocketEntryMetaLambda.ts @@ -1,17 +1,19 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * lambda which is used for updating a docket entry's meta for a case - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const updateDocketEntryMetaLambda = event => +export const updateDocketEntryMetaLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .updateDocketEntryMetaInteractor(applicationContext, { - ...JSON.parse(event.body), - ...event.pathParameters, - }); + .updateDocketEntryMetaInteractor( + applicationContext, + { + ...JSON.parse(event.body), + ...event.pathParameters, + }, + authorizedUser, + ); }); From d12b0a055765f120c8486158e90d952a8ecc8cee Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Fri, 19 Jul 2024 12:11:52 -0400 Subject: [PATCH 279/523] 10417 rm getCurrentUser and associated functions from applicationContext --- web-client/src/applicationContext.ts | 19 +------------------ .../presenter/actions/clearUserAction.test.ts | 11 ----------- .../src/presenter/actions/clearUserAction.ts | 3 ++- .../presenter/actions/setUserAction.test.ts | 9 +++------ .../src/presenter/actions/setUserAction.ts | 8 +------- 5 files changed, 7 insertions(+), 43 deletions(-) diff --git a/web-client/src/applicationContext.ts b/web-client/src/applicationContext.ts index bf9af77f5d3..a84c87f900e 100644 --- a/web-client/src/applicationContext.ts +++ b/web-client/src/applicationContext.ts @@ -28,9 +28,7 @@ import { getPublicSiteUrl, getUniqueId, } from '../../shared/src/sharedAppContext'; -import { RawIrsPractitioner } from '@shared/business/entities/IrsPractitioner'; -import { RawPractitioner } from '@shared/business/entities/Practitioner'; -import { RawUser, User } from '../../shared/src/business/entities/User'; +import { User } from '../../shared/src/business/entities/User'; import { abbreviateState } from '../../shared/src/business/utilities/abbreviateState'; import { addCaseToTrialSessionInteractor } from '../../shared/src/proxies/trialSessions/addCaseToTrialSessionProxy'; import { addConsolidatedCaseInteractor } from '../../shared/src/proxies/addConsolidatedCaseProxy'; @@ -371,15 +369,6 @@ const reduce = ImageBlobReduce({ let user; let broadcastChannel; -const getCurrentUser = (): RawUser | RawPractitioner | RawIrsPractitioner => { - return user; -}; -const setCurrentUser = ( - newUser: RawUser | RawPractitioner | RawIrsPractitioner, -) => { - user = newUser; -}; - let forceRefreshCallback: () => {}; const allUseCases = { @@ -644,11 +633,6 @@ const applicationContext = { }, getCaseTitle: Case.getCaseTitle, getConstants: () => appConstants, - getCurrentUser, - getCurrentUserPermissions: () => { - const currentUser = getCurrentUser(); - return getUserPermissions(currentUser); - }, getEnvironment, getFileReaderInstance: () => new FileReader(), getForceRefreshCallback() { @@ -811,7 +795,6 @@ const applicationContext = { return getIsFeatureEnabled(featureName, user, getEnvironment().stage); }, isPublicUser: () => false, - setCurrentUser, setForceRefreshCallback(callback) { forceRefreshCallback = callback; }, diff --git a/web-client/src/presenter/actions/clearUserAction.test.ts b/web-client/src/presenter/actions/clearUserAction.test.ts index be2bb3ce77f..bb61f6979d2 100644 --- a/web-client/src/presenter/actions/clearUserAction.test.ts +++ b/web-client/src/presenter/actions/clearUserAction.test.ts @@ -43,15 +43,4 @@ describe('clearUserAction', () => { .key, ).toBe('token'); }); - - it('should make a call to set currentUser to null', async () => { - await runAction(clearUserAction, { - modules: { - presenter, - }, - state: {}, - }); - - expect(applicationContext.setCurrentUser).toHaveBeenCalled(); - }); }); diff --git a/web-client/src/presenter/actions/clearUserAction.ts b/web-client/src/presenter/actions/clearUserAction.ts index 7d704da24fa..11fd3d6a5bc 100644 --- a/web-client/src/presenter/actions/clearUserAction.ts +++ b/web-client/src/presenter/actions/clearUserAction.ts @@ -3,11 +3,13 @@ import { state } from '@web-client/presenter/app.cerebral'; export const clearUserAction = async ({ applicationContext, + get, store, }: ActionProps) => { store.unset(state.user); store.unset(state.token); store.unset(state.permissions); + console.debug('user cleared', get(state.user)); await applicationContext .getUseCases() @@ -20,6 +22,5 @@ export const clearUserAction = async ({ key: 'token', }); - applicationContext.setCurrentUser(null); setCurrentUserToken(''); }; diff --git a/web-client/src/presenter/actions/setUserAction.test.ts b/web-client/src/presenter/actions/setUserAction.test.ts index f12b62e2753..edd73185bd1 100644 --- a/web-client/src/presenter/actions/setUserAction.test.ts +++ b/web-client/src/presenter/actions/setUserAction.test.ts @@ -14,11 +14,11 @@ describe('setUserAction', () => { delete global.window; }); - it('stores the user onto the application context', async () => { + it('stores the user cerebral state', async () => { const user = { userId: 'petitioner', }; - await runAction(setUserAction, { + const { state } = await runAction(setUserAction, { modules: { presenter, }, @@ -27,9 +27,6 @@ describe('setUserAction', () => { }, state: {}, }); - expect(applicationContext.setCurrentUser.mock.calls.length).toEqual(1); - expect(applicationContext.setCurrentUser.mock.calls[0][0]).toMatchObject( - user, - ); + expect(state.user).toEqual(user); }); }); diff --git a/web-client/src/presenter/actions/setUserAction.ts b/web-client/src/presenter/actions/setUserAction.ts index 1c1055c9b68..30f55de36fa 100644 --- a/web-client/src/presenter/actions/setUserAction.ts +++ b/web-client/src/presenter/actions/setUserAction.ts @@ -5,13 +5,7 @@ import { state } from '@web-client/presenter/app.cerebral'; * @param {object} providers the providers object * @param {object} providers.store the cerebral store used for setting state.user * @param {object} providers.props the cerebral props object used for getting the props.user - * @param {object} providers.applicationContext the application context needed for getting the setCurrentUser method */ -export const setUserAction = ({ - applicationContext, - props, - store, -}: ActionProps) => { +export const setUserAction = ({ props, store }: ActionProps) => { store.set(state.user, props.user); - applicationContext.setCurrentUser(props.user); }; From ed6fae2abff5bbafccbd4917bf32b1fd5039b65a Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Fri, 19 Jul 2024 09:19:20 -0700 Subject: [PATCH 280/523] 10417: remove appcontext.getCurrentUser from getDocumentContentsForDocketEntryInteractor --- ...ntContentsForDocketEntryInteractor.test.ts | 76 +++++++++++++------ ...ocumentContentsForDocketEntryInteractor.ts | 14 +--- ...getDocumentContentsForDocketEntryLambda.ts | 13 ++-- 3 files changed, 60 insertions(+), 43 deletions(-) diff --git a/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.test.ts b/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.test.ts index 2eff039af1f..174e74d8e77 100644 --- a/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.test.ts +++ b/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.test.ts @@ -1,14 +1,20 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; +import { ROLES } from '@shared/business/entities/EntityConstants'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getDocumentContentsForDocketEntryInteractor } from './getDocumentContentsForDocketEntryInteractor'; +import { + mockDocketClerkUser, + mockJudgeUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getDocumentContentsForDocketEntryInteractor', () => { const mockDocumentContentsId = '599dbad3-4912-4a61-9525-3da245700893'; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', - role: ROLES.docketClerk, - }); + // applicationContext.getCurrentUser.mockReturnValue({ + // name: 'Tasha Yar', + // role: ROLES.docketClerk, + // }); applicationContext.getPersistenceGateway().getDocument.mockReturnValue( Buffer.from( @@ -21,27 +27,38 @@ describe('getDocumentContentsForDocketEntryInteractor', () => { }); it('should throw an error when the logged in user does not have permission to EDIT_ORDER', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Tasha Yar', + // applicationContext.getCurrentUser.mockReturnValue({ + // name: 'Tasha Yar', + // role: ROLES.inactivePractitioner, + // }); + let authorizedUser = { + ...mockPrivatePractitionerUser, role: ROLES.inactivePractitioner, - }); - + } as UnknownAuthUser; await expect( - getDocumentContentsForDocketEntryInteractor(applicationContext, { - documentContentsId: mockDocumentContentsId, - }), + getDocumentContentsForDocketEntryInteractor( + applicationContext, + { + documentContentsId: mockDocumentContentsId, + }, + authorizedUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should allow the logged in internal user with permissions to edit the order', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Test Judge', - role: ROLES.judge, - }); + // applicationContext.getCurrentUser.mockReturnValue({ + // name: 'Test Judge', + // role: ROLES.judge, + // }); - await getDocumentContentsForDocketEntryInteractor(applicationContext, { - documentContentsId: mockDocumentContentsId, - }); + await getDocumentContentsForDocketEntryInteractor( + applicationContext, + { + documentContentsId: mockDocumentContentsId, + }, + mockJudgeUser, + ); expect( applicationContext.getPersistenceGateway().getDocument.mock.calls[0][0], @@ -49,9 +66,13 @@ describe('getDocumentContentsForDocketEntryInteractor', () => { }); it('should call applicationContext.getPersistenceGateway().getDocument with documentCntentsId as the key', async () => { - await getDocumentContentsForDocketEntryInteractor(applicationContext, { - documentContentsId: mockDocumentContentsId, - }); + await getDocumentContentsForDocketEntryInteractor( + applicationContext, + { + documentContentsId: mockDocumentContentsId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDocument.mock.calls[0][0], @@ -64,6 +85,7 @@ describe('getDocumentContentsForDocketEntryInteractor', () => { { documentContentsId: mockDocumentContentsId, }, + mockDocketClerkUser, ); expect(result).toEqual({ @@ -82,9 +104,13 @@ describe('getDocumentContentsForDocketEntryInteractor', () => { ); await expect( - getDocumentContentsForDocketEntryInteractor(applicationContext, { - documentContentsId: mockDocumentContentsId, - }), + getDocumentContentsForDocketEntryInteractor( + applicationContext, + { + documentContentsId: mockDocumentContentsId, + }, + mockDocketClerkUser, + ), ).rejects.toThrow( `Document contents ${mockDocumentContentsId} could not be found in the S3 bucket.`, ); diff --git a/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.ts b/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.ts index 1bf76b4c815..57d62c2d67b 100644 --- a/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.ts @@ -4,22 +4,14 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * getDocumentContentsForDocketEntryInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {object} providers.documentContentsId document contents id - * @returns {string} url for the generated document on the storage client - */ export const getDocumentContentsForDocketEntryInteractor = async ( applicationContext: ServerApplicationContext, { documentContentsId }: { documentContentsId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.EDIT_ORDER)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.EDIT_ORDER)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/documents/getDocumentContentsForDocketEntryLambda.ts b/web-api/src/lambdas/documents/getDocumentContentsForDocketEntryLambda.ts index 9ca95bd9a58..15a00d3a99e 100644 --- a/web-api/src/lambdas/documents/getDocumentContentsForDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/getDocumentContentsForDocketEntryLambda.ts @@ -1,17 +1,16 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * used for getting the document contents for a docket entry - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const getDocumentContentsForDocketEntryLambda = event => +export const getDocumentContentsForDocketEntryLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() .getDocumentContentsForDocketEntryInteractor( applicationContext, event.pathParameters, + authorizedUser, ); }); From a50fbab1daa9641db21b1aa76bfd9c0086916eb5 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 12:31:56 -0500 Subject: [PATCH 281/523] 10417 remove getCurrentUser from getUserPendingEmailStatusInteractor --- ...etUserPendingEmailStatusInteractor.test.ts | 39 ++++++++----------- .../getUserPendingEmailStatusInteractor.ts | 4 +- .../users/getUserPendingEmailStatusLambda.ts | 16 ++++++-- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/web-api/src/business/useCases/user/getUserPendingEmailStatusInteractor.test.ts b/web-api/src/business/useCases/user/getUserPendingEmailStatusInteractor.test.ts index 30a408172fa..8ad0e2eb369 100644 --- a/web-api/src/business/useCases/user/getUserPendingEmailStatusInteractor.test.ts +++ b/web-api/src/business/useCases/user/getUserPendingEmailStatusInteractor.test.ts @@ -1,35 +1,27 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getUserPendingEmailStatusInteractor } from './getUserPendingEmailStatusInteractor'; +import { + mockPetitionerUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getUserPendingEmailStatusInteractor', () => { - let currentLoggedInUser; const PENDING_EMAIL = 'pending@example.com'; const USER_ID = 'a8024d79-1cd0-4864-bdd9-60325bd6d6b9'; - beforeEach(() => { - currentLoggedInUser = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.privatePractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - - applicationContext.getCurrentUser.mockImplementation( - () => currentLoggedInUser, - ); - }); - it('should throw an error when not authorized', async () => { - currentLoggedInUser = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.inactivePractitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - await expect( - getUserPendingEmailStatusInteractor(applicationContext, { - userId: USER_ID, - }), + getUserPendingEmailStatusInteractor( + applicationContext, + { + userId: USER_ID, + }, + { + ...mockPrivatePractitionerUser, + role: ROLES.inactivePractitioner, + }, + ), ).rejects.toThrow('Unauthorized'); }); @@ -46,6 +38,7 @@ describe('getUserPendingEmailStatusInteractor', () => { { userId: USER_ID, }, + mockPetitionerUser, ); expect(result).toEqual(true); @@ -63,6 +56,7 @@ describe('getUserPendingEmailStatusInteractor', () => { { userId: USER_ID, }, + mockPetitionerUser, ); expect(result).toEqual(false); @@ -78,6 +72,7 @@ describe('getUserPendingEmailStatusInteractor', () => { { userId: USER_ID, }, + mockPetitionerUser, ); expect(result).toBeUndefined(); diff --git a/web-api/src/business/useCases/user/getUserPendingEmailStatusInteractor.ts b/web-api/src/business/useCases/user/getUserPendingEmailStatusInteractor.ts index f4713f3cdf2..4cbde5e1901 100644 --- a/web-api/src/business/useCases/user/getUserPendingEmailStatusInteractor.ts +++ b/web-api/src/business/useCases/user/getUserPendingEmailStatusInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; /** @@ -17,9 +18,8 @@ import { User } from '../../../../../shared/src/business/entities/User'; export const getUserPendingEmailStatusInteractor = async ( applicationContext: ServerApplicationContext, { userId }: { userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if ( !isAuthorized( authorizedUser, diff --git a/web-api/src/lambdas/users/getUserPendingEmailStatusLambda.ts b/web-api/src/lambdas/users/getUserPendingEmailStatusLambda.ts index d232a60955a..e195196c1ec 100644 --- a/web-api/src/lambdas/users/getUserPendingEmailStatusLambda.ts +++ b/web-api/src/lambdas/users/getUserPendingEmailStatusLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getUserPendingEmailStatusLambda = event => +export const getUserPendingEmailStatusLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getUserPendingEmailStatusInteractor(applicationContext, { - userId: event.pathParameters.userId, - }); + .getUserPendingEmailStatusInteractor( + applicationContext, + { + userId: event.pathParameters.userId, + }, + authorizedUser, + ); }); From e96d4fbf6ffc30297710bb2198c6cb73b7e8193a Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 12:37:48 -0500 Subject: [PATCH 282/523] 10417 remove getCurrentUser from getUserPendingEmailInteractor --- .../getUserPendingEmailInteractor.test.ts | 63 ++++++++++--------- .../user/getUserPendingEmailInteractor.ts | 4 +- .../users/getUserPendingEmailLambda.ts | 12 ++-- 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/web-api/src/business/useCases/user/getUserPendingEmailInteractor.test.ts b/web-api/src/business/useCases/user/getUserPendingEmailInteractor.test.ts index 8457e580bed..12ec03fb95f 100644 --- a/web-api/src/business/useCases/user/getUserPendingEmailInteractor.test.ts +++ b/web-api/src/business/useCases/user/getUserPendingEmailInteractor.test.ts @@ -1,35 +1,24 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getUserPendingEmailInteractor } from './getUserPendingEmailInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getUserPendingEmailInteractor', () => { - let currentLoggedInUser; const PENDING_EMAIL = 'pending@example.com'; const USER_ID = 'a8024d79-1cd0-4864-bdd9-60325bd6d6b9'; - beforeEach(() => { - currentLoggedInUser = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - - applicationContext.getCurrentUser.mockImplementation( - () => currentLoggedInUser, - ); - }); - it('should throw an error when not authorized', async () => { - currentLoggedInUser = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; - await expect( - getUserPendingEmailInteractor(applicationContext, { - userId: USER_ID, - }), + getUserPendingEmailInteractor( + applicationContext, + { + userId: USER_ID, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -41,9 +30,13 @@ describe('getUserPendingEmailInteractor', () => { userId: USER_ID, }); - const result = await getUserPendingEmailInteractor(applicationContext, { - userId: USER_ID, - }); + const result = await getUserPendingEmailInteractor( + applicationContext, + { + userId: USER_ID, + }, + mockPetitionsClerkUser, + ); expect(result).toEqual(PENDING_EMAIL); }); @@ -55,9 +48,13 @@ describe('getUserPendingEmailInteractor', () => { userId: USER_ID, }); - const result = await getUserPendingEmailInteractor(applicationContext, { - userId: USER_ID, - }); + const result = await getUserPendingEmailInteractor( + applicationContext, + { + userId: USER_ID, + }, + mockPetitionsClerkUser, + ); expect(result).toBeUndefined(); }); @@ -67,9 +64,13 @@ describe('getUserPendingEmailInteractor', () => { .getPersistenceGateway() .getUserById.mockResolvedValue(undefined); - const result = await getUserPendingEmailInteractor(applicationContext, { - userId: USER_ID, - }); + const result = await getUserPendingEmailInteractor( + applicationContext, + { + userId: USER_ID, + }, + mockPetitionsClerkUser, + ); expect(result).toBeUndefined(); }); diff --git a/web-api/src/business/useCases/user/getUserPendingEmailInteractor.ts b/web-api/src/business/useCases/user/getUserPendingEmailInteractor.ts index 3944fe1d467..0e1d5cbbf5f 100644 --- a/web-api/src/business/useCases/user/getUserPendingEmailInteractor.ts +++ b/web-api/src/business/useCases/user/getUserPendingEmailInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; /** @@ -17,9 +18,8 @@ import { User } from '../../../../../shared/src/business/entities/User'; export const getUserPendingEmailInteractor = async ( applicationContext: ServerApplicationContext, { userId }: { userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.GET_USER_PENDING_EMAIL)) { throw new UnauthorizedError('Unauthorized to get user pending email'); } diff --git a/web-api/src/lambdas/users/getUserPendingEmailLambda.ts b/web-api/src/lambdas/users/getUserPendingEmailLambda.ts index 1b6c2de2d2f..0e6ef04e560 100644 --- a/web-api/src/lambdas/users/getUserPendingEmailLambda.ts +++ b/web-api/src/lambdas/users/getUserPendingEmailLambda.ts @@ -6,11 +6,13 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getUserPendingEmailLambda = event => +export const getUserPendingEmailLambda = (event, authorizedUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getUserPendingEmailInteractor(applicationContext, { + return await applicationContext.getUseCases().getUserPendingEmailInteractor( + applicationContext, + { userId: event.pathParameters.userId, - }); + }, + authorizedUser, + ); }); From f0e9a51dcdf2373d359d1d7f21235f0fb4656e4e Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 12:42:10 -0500 Subject: [PATCH 283/523] 10417 remove getCurrentUser from getPrivatePractitionersBySearchKeyInteractor --- ...PractitionersBySearchKeyInteractor.test.ts | 28 +++++++++---------- ...ivatePractitionersBySearchKeyInteractor.ts | 6 ++-- ...etPrivatePractitionersBySearchKeyLambda.ts | 16 ++++++++--- .../users/getUserPendingEmailLambda.ts | 6 +++- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.test.ts b/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.test.ts index ca365e10d7b..d098456ebc7 100644 --- a/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.test.ts +++ b/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.test.ts @@ -1,29 +1,32 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getPrivatePractitionersBySearchKeyInteractor } from './getPrivatePractitionersBySearchKeyInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; let user; describe('getPrivatePractitionersBySearchKeyInteractor', () => { beforeEach(() => { applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockImplementation(() => user); }); it('should throw an error when not authorized', async () => { let error; - user = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitioner, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; + user = mockPetitionerUser; applicationContext .getPersistenceGateway() .getUsersBySearchKey.mockResolvedValue([]); try { - await getPrivatePractitionersBySearchKeyInteractor(applicationContext, { - searchKey: 'something', - }); + await getPrivatePractitionersBySearchKeyInteractor( + applicationContext, + { + searchKey: 'something', + }, + user, + ); } catch (err) { error = err; } @@ -31,11 +34,7 @@ describe('getPrivatePractitionersBySearchKeyInteractor', () => { }); it('should return users from persistence', async () => { - user = { - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }; + user = mockPetitionsClerkUser; applicationContext .getPersistenceGateway() .getUsersBySearchKey.mockResolvedValue([ @@ -52,6 +51,7 @@ describe('getPrivatePractitionersBySearchKeyInteractor', () => { { searchKey: 'Test Practitioner', }, + user, ); expect(result).toMatchObject([{ name: 'Test Practitioner' }]); diff --git a/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.ts b/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.ts index 47a6e9e0f06..82db824c48d 100644 --- a/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.ts +++ b/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * getPrivatePractitionersBySearchKeyInteractor @@ -17,11 +18,10 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const getPrivatePractitionersBySearchKeyInteractor = async ( applicationContext: ServerApplicationContext, { searchKey }: { searchKey: string }, + authorizedUser: UnknownAuthUser, ) => { - const authenticatedUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(authenticatedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) ) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/users/getPrivatePractitionersBySearchKeyLambda.ts b/web-api/src/lambdas/users/getPrivatePractitionersBySearchKeyLambda.ts index c2d610e1360..3514f865fc6 100644 --- a/web-api/src/lambdas/users/getPrivatePractitionersBySearchKeyLambda.ts +++ b/web-api/src/lambdas/users/getPrivatePractitionersBySearchKeyLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getPrivatePractitionersBySearchKeyLambda = event => +export const getPrivatePractitionersBySearchKeyLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { searchKey } = event.queryStringParameters; return await applicationContext .getUseCases() - .getPrivatePractitionersBySearchKeyInteractor(applicationContext, { - searchKey, - }); + .getPrivatePractitionersBySearchKeyInteractor( + applicationContext, + { + searchKey, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/users/getUserPendingEmailLambda.ts b/web-api/src/lambdas/users/getUserPendingEmailLambda.ts index 0e6ef04e560..f014bfdc447 100644 --- a/web-api/src/lambdas/users/getUserPendingEmailLambda.ts +++ b/web-api/src/lambdas/users/getUserPendingEmailLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,7 +7,10 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getUserPendingEmailLambda = (event, authorizedUser) => +export const getUserPendingEmailLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext.getUseCases().getUserPendingEmailInteractor( applicationContext, From a2dfa455be6711995c9c0461d9d7f571bcd87f26 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 12:45:43 -0500 Subject: [PATCH 284/523] 10417 remove getCurrentUser from getInternalUsersInteractor --- .../user/getInternalUsersInteractor.test.ts | 21 ++++++++----------- .../user/getInternalUsersInteractor.ts | 9 +++----- .../lambdas/users/getInternalUsersLambda.ts | 8 +++++-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/web-api/src/business/useCases/user/getInternalUsersInteractor.test.ts b/web-api/src/business/useCases/user/getInternalUsersInteractor.test.ts index eef79c8a343..82225464cf7 100644 --- a/web-api/src/business/useCases/user/getInternalUsersInteractor.test.ts +++ b/web-api/src/business/useCases/user/getInternalUsersInteractor.test.ts @@ -1,13 +1,12 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getInternalUsersInteractor } from './getInternalUsersInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('Get internal users', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketclerk', - }); applicationContext .getPersistenceGateway() .getInternalUsers.mockReturnValue([ @@ -27,7 +26,10 @@ describe('Get internal users', () => { }); it('returns the same users that were returned from mocked persistence', async () => { - const users = await getInternalUsersInteractor(applicationContext); + const users = await getInternalUsersInteractor( + applicationContext, + mockDocketClerkUser, + ); expect(users).toMatchObject([ { name: 'Saul Goodman', @@ -45,14 +47,9 @@ describe('Get internal users', () => { }); it('throws unauthorized error for unauthorized users', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - name: 'Saul Goodman', - role: ROLES.petitioner, - userId: 'petitioner', - }); let error; try { - await getInternalUsersInteractor(applicationContext); + await getInternalUsersInteractor(applicationContext, mockPetitionerUser); } catch (err) { error = err; } diff --git a/web-api/src/business/useCases/user/getInternalUsersInteractor.ts b/web-api/src/business/useCases/user/getInternalUsersInteractor.ts index d6dcabc19e2..fc2cb2fa529 100644 --- a/web-api/src/business/useCases/user/getInternalUsersInteractor.ts +++ b/web-api/src/business/useCases/user/getInternalUsersInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; /** @@ -14,13 +15,9 @@ import { User } from '../../../../../shared/src/business/entities/User'; */ export const getInternalUsersInteractor = async ( applicationContext: ServerApplicationContext, + authorizedUser: UnknownAuthUser, ) => { - if ( - !isAuthorized( - applicationContext.getCurrentUser(), - ROLE_PERMISSIONS.WORKITEM, - ) - ) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.WORKITEM)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/users/getInternalUsersLambda.ts b/web-api/src/lambdas/users/getInternalUsersLambda.ts index 51956265395..4a077987b37 100644 --- a/web-api/src/lambdas/users/getInternalUsersLambda.ts +++ b/web-api/src/lambdas/users/getInternalUsersLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,9 +7,12 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getInternalUsersLambda = event => +export const getInternalUsersLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getInternalUsersInteractor(applicationContext); + .getInternalUsersInteractor(applicationContext, authorizedUser); }); From 6ad2a59f879b21a886dbb9781382bda8f9191799 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 12:50:04 -0500 Subject: [PATCH 285/523] 10417 remove getCurrentUser from createUserInteractor --- .../user/createUserInteractor.spec.ts | 31 +++++++++---------- .../useCases/user/createUserInteractor.ts | 6 ++-- web-api/src/lambdas/users/createUserLambda.ts | 13 +++++--- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/web-api/src/business/useCases/user/createUserInteractor.spec.ts b/web-api/src/business/useCases/user/createUserInteractor.spec.ts index bcc9ded623f..29aac574cab 100644 --- a/web-api/src/business/useCases/user/createUserInteractor.spec.ts +++ b/web-api/src/business/useCases/user/createUserInteractor.spec.ts @@ -1,8 +1,8 @@ -import { ROLES } from '@shared/business/entities/EntityConstants'; import { applicationContext } from '@shared/business/test/createTestApplicationContext'; import { createOrUpdateUser } from '../../../../../shared/admin-tools/user/admin'; import { createUserInteractor } from '@web-api/business/useCases/user/createUserInteractor'; import { docketClerk1User } from '@shared/test/mockUsers'; +import { mockAdminUser, mockPetitionerUser } from '@shared/test/mockAuthUsers'; jest.mock('../../../../../shared/admin-tools/user/admin', () => ({ createOrUpdateUser: jest.fn(), @@ -10,27 +10,26 @@ jest.mock('../../../../../shared/admin-tools/user/admin', () => ({ describe('createUserInteractor', () => { it('should throw an error if a user with create permissions tries to create a user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.legacyJudge, - userId: '47cc9719-a392-4cb0-b744-ffb243eff3a3', - }); await expect( - createUserInteractor(applicationContext, { - user: { ...docketClerk1User, password: 'junkPass' }, - }), + createUserInteractor( + applicationContext, + { + user: { ...docketClerk1User, password: 'junkPass' }, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); expect(createOrUpdateUser).not.toHaveBeenCalled(); }); it('should create a new user when an admin tries to create a user', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.admin, - userId: '3aa4b9c3-a66a-486a-bd01-fb370f52f45a', - }); - - await createUserInteractor(applicationContext, { - user: { ...docketClerk1User, password: 'junkPass' }, - }); + await createUserInteractor( + applicationContext, + { + user: { ...docketClerk1User, password: 'junkPass' }, + }, + mockAdminUser, + ); expect(createOrUpdateUser).toHaveBeenCalledWith(expect.anything(), { password: 'junkPass', diff --git a/web-api/src/business/useCases/user/createUserInteractor.ts b/web-api/src/business/useCases/user/createUserInteractor.ts index c4222533e59..27e2c45351b 100644 --- a/web-api/src/business/useCases/user/createUserInteractor.ts +++ b/web-api/src/business/useCases/user/createUserInteractor.ts @@ -6,6 +6,7 @@ import { RawPractitioner } from '../../../../../shared/src/business/entities/Pra import { RawUser } from '../../../../../shared/src/business/entities/User'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '../../../errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createOrUpdateUser } from '../../../../../shared/admin-tools/user/admin'; export const createUserInteractor = async ( @@ -17,10 +18,9 @@ export const createUserInteractor = async ( password: string; }; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const requestUser = applicationContext.getCurrentUser(); - - if (!isAuthorized(requestUser, ROLE_PERMISSIONS.CREATE_USER)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CREATE_USER)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/users/createUserLambda.ts b/web-api/src/lambdas/users/createUserLambda.ts index 131da54ebd6..617ae9d327e 100644 --- a/web-api/src/lambdas/users/createUserLambda.ts +++ b/web-api/src/lambdas/users/createUserLambda.ts @@ -1,10 +1,15 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createUserInteractor } from '@web-api/business/useCases/user/createUserInteractor'; import { genericHandler } from '../../genericHandler'; // This is a special lambda that is only meant to be used by admins. -export const createUserLambda = event => +export const createUserLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await createUserInteractor(applicationContext, { - user: JSON.parse(event.body), - }); + return await createUserInteractor( + applicationContext, + { + user: JSON.parse(event.body), + }, + authorizedUser, + ); }); From 09f1e18d71f53f0ecb981047f9824ed7705e38e8 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 12:53:10 -0500 Subject: [PATCH 286/523] 10417 remove getCurrentUser from checkEmailAvailabilityInteractor --- .../checkEmailAvailabilityInteractor.test.ts | 52 +++++++++++-------- .../user/checkEmailAvailabilityInteractor.ts | 4 +- .../users/checkEmailAvailabilityLambda.ts | 16 ++++-- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/web-api/src/business/useCases/user/checkEmailAvailabilityInteractor.test.ts b/web-api/src/business/useCases/user/checkEmailAvailabilityInteractor.test.ts index 8a29d1b09ec..1195b0738cf 100644 --- a/web-api/src/business/useCases/user/checkEmailAvailabilityInteractor.test.ts +++ b/web-api/src/business/useCases/user/checkEmailAvailabilityInteractor.test.ts @@ -3,31 +3,33 @@ import { UserStatusType } from '@aws-sdk/client-cognito-identity-provider'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { checkEmailAvailabilityInteractor } from './checkEmailAvailabilityInteractor'; import { - petitionsClerkUser, - privatePractitionerUser, -} from '@shared/test/mockUsers'; + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('checkEmailAvailabilityInteractor', () => { const mockEmail = 'test@example.com'; - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(privatePractitionerUser); - }); - it('should throw an error when the logged in user is unauthorized to check email availability', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - await expect( - checkEmailAvailabilityInteractor(applicationContext, { - email: mockEmail, - }), + checkEmailAvailabilityInteractor( + applicationContext, + { + email: mockEmail, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Unauthorized to manage emails.'); }); it('should attempt to retrieve the user by email', async () => { - await checkEmailAvailabilityInteractor(applicationContext, { - email: mockEmail, - }); + await checkEmailAvailabilityInteractor( + applicationContext, + { + email: mockEmail, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getUserGateway().getUserByEmail.mock.calls[0][1], @@ -39,9 +41,13 @@ describe('checkEmailAvailabilityInteractor', () => { it('should return true when the specified email is not already in use', async () => { applicationContext.getUserGateway().getUserByEmail.mockReturnValue(); - const result = await checkEmailAvailabilityInteractor(applicationContext, { - email: mockEmail, - }); + const result = await checkEmailAvailabilityInteractor( + applicationContext, + { + email: mockEmail, + }, + mockPrivatePractitionerUser, + ); expect(result.isEmailAvailable).toEqual(true); }); @@ -55,9 +61,13 @@ describe('checkEmailAvailabilityInteractor', () => { userId: '85e2ca3e-6521-4b10-8edb-91c934c78c43', }); - const result = await checkEmailAvailabilityInteractor(applicationContext, { - email: mockEmail, - }); + const result = await checkEmailAvailabilityInteractor( + applicationContext, + { + email: mockEmail, + }, + mockPrivatePractitionerUser, + ); expect(result.isEmailAvailable).toEqual(false); }); diff --git a/web-api/src/business/useCases/user/checkEmailAvailabilityInteractor.ts b/web-api/src/business/useCases/user/checkEmailAvailabilityInteractor.ts index 8729a648732..36436c846df 100644 --- a/web-api/src/business/useCases/user/checkEmailAvailabilityInteractor.ts +++ b/web-api/src/business/useCases/user/checkEmailAvailabilityInteractor.ts @@ -4,14 +4,14 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { UserStatusType } from '@aws-sdk/client-cognito-identity-provider'; export const checkEmailAvailabilityInteractor = async ( applicationContext: ServerApplicationContext, { email }: { email: string }, + authorizedUser: UnknownAuthUser, ): Promise<{ isAccountUnverified: boolean; isEmailAvailable: boolean }> => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.EMAIL_MANAGEMENT)) { throw new UnauthorizedError('Unauthorized to manage emails.'); } diff --git a/web-api/src/lambdas/users/checkEmailAvailabilityLambda.ts b/web-api/src/lambdas/users/checkEmailAvailabilityLambda.ts index 7b57ff78064..5f202d67111 100644 --- a/web-api/src/lambdas/users/checkEmailAvailabilityLambda.ts +++ b/web-api/src/lambdas/users/checkEmailAvailabilityLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const checkEmailAvailabilityLambda = event => +export const checkEmailAvailabilityLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { email } = event.queryStringParameters; return await applicationContext .getUseCases() - .checkEmailAvailabilityInteractor(applicationContext, { - email, - }); + .checkEmailAvailabilityInteractor( + applicationContext, + { + email, + }, + authorizedUser, + ); }); From 25211b009801b123429e4dfdc0f37c3ba8c58b92 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 13:11:55 -0500 Subject: [PATCH 287/523] 10417 remove getCurrentUser from updateTrialSessionWorkingCopyInteractor --- ...eTrialSessionWorkingCopyInteractor.test.ts | 38 +++++++++---------- ...updateTrialSessionWorkingCopyInteractor.ts | 7 +++- .../updateTrialSessionWorkingCopyLambda.ts | 16 ++++++-- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.test.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.test.ts index c6ab86808e4..02b114e12ca 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.test.ts @@ -1,7 +1,7 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { RawTrialSessionWorkingCopy } from '@shared/business/entities/trialSessions/TrialSessionWorkingCopy'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockJudgeUser } from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; import { updateTrialSessionWorkingCopyInteractor } from './updateTrialSessionWorkingCopyInteractor'; @@ -20,7 +20,6 @@ const MOCK_WORKING_COPY = { describe('Update trial session working copy', () => { beforeEach(() => { applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext .getPersistenceGateway() .getTrialSessionWorkingCopy.mockReturnValue(MOCK_WORKING_COPY); @@ -37,19 +36,18 @@ describe('Update trial session working copy', () => { .updateTrialSessionWorkingCopy.mockReturnValue({}); await expect( - updateTrialSessionWorkingCopyInteractor(applicationContext, { - trialSessionWorkingCopyToUpdate: - MOCK_WORKING_COPY as unknown as RawTrialSessionWorkingCopy, - }), + updateTrialSessionWorkingCopyInteractor( + applicationContext, + { + trialSessionWorkingCopyToUpdate: + MOCK_WORKING_COPY as unknown as RawTrialSessionWorkingCopy, + }, + user, + ), ).rejects.toThrow(UnauthorizedError); }); it('throws an error if the entity returned from persistence is invalid', async () => { - user = { - role: ROLES.judge, - userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', - }; - applicationContext .getPersistenceGateway() .getTrialSessionWorkingCopy.mockResolvedValue( @@ -57,19 +55,18 @@ describe('Update trial session working copy', () => { ); await expect( - updateTrialSessionWorkingCopyInteractor(applicationContext, { - trialSessionWorkingCopyToUpdate: - MOCK_WORKING_COPY as unknown as RawTrialSessionWorkingCopy, - }), + updateTrialSessionWorkingCopyInteractor( + applicationContext, + { + trialSessionWorkingCopyToUpdate: + MOCK_WORKING_COPY as unknown as RawTrialSessionWorkingCopy, + }, + mockJudgeUser, + ), ).rejects.toThrow('The TrialSessionWorkingCopy entity was invalid'); }); it('correctly returns data from persistence', async () => { - user = { - role: ROLES.judge, - userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', - }; - applicationContext .getPersistenceGateway() .updateTrialSessionWorkingCopy.mockResolvedValue(MOCK_WORKING_COPY); @@ -80,6 +77,7 @@ describe('Update trial session working copy', () => { trialSessionWorkingCopyToUpdate: MOCK_WORKING_COPY as unknown as RawTrialSessionWorkingCopy, }, + mockJudgeUser, ); expect(result).toMatchObject(MOCK_WORKING_COPY); }); diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.ts index 5770ed9081f..48baa0b4d07 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor.ts @@ -8,6 +8,7 @@ import { } from '../../../../../shared/src/business/entities/trialSessions/TrialSessionWorkingCopy'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * updateTrialSessionWorkingCopyInteractor @@ -22,9 +23,11 @@ export const updateTrialSessionWorkingCopyInteractor = async ( { trialSessionWorkingCopyToUpdate, }: { trialSessionWorkingCopyToUpdate: RawTrialSessionWorkingCopy }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY) + ) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/updateTrialSessionWorkingCopyLambda.ts b/web-api/src/lambdas/trialSessions/updateTrialSessionWorkingCopyLambda.ts index bc6a7754e47..01386d8f843 100644 --- a/web-api/src/lambdas/trialSessions/updateTrialSessionWorkingCopyLambda.ts +++ b/web-api/src/lambdas/trialSessions/updateTrialSessionWorkingCopyLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateTrialSessionWorkingCopyLambda = event => +export const updateTrialSessionWorkingCopyLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .updateTrialSessionWorkingCopyInteractor(applicationContext, { - trialSessionWorkingCopyToUpdate: JSON.parse(event.body), - }); + .updateTrialSessionWorkingCopyInteractor( + applicationContext, + { + trialSessionWorkingCopyToUpdate: JSON.parse(event.body), + }, + authorizedUser, + ); }); From 8871d83b316e91b2cfe05f566a0c77d70a27453c Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 13:35:01 -0500 Subject: [PATCH 288/523] 10417 remove getcurrentuser from updateTrialSessionLambda --- ...dateTrialSessionInteractor.locking.test.ts | 45 ++- ...SessionInteractor.noticeGeneration.test.ts | 191 +++++++---- .../updateTrialSessionInteractor.test.ts | 316 +++++++++++------- .../updateTrialSessionInteractor.ts | 19 +- .../trialSessions/updateTrialSessionLambda.ts | 16 +- 5 files changed, 366 insertions(+), 221 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.locking.test.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.locking.test.ts index 78cd8933255..59adf10045d 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.locking.test.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.locking.test.ts @@ -8,7 +8,7 @@ import { handleLockError, updateTrialSessionInteractor, } from './updateTrialSessionInteractor'; -import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('determineEntitiesToLock', () => { const trialSessionId = '6805d1ab-18d0-43ec-bafb-654e83405416'; @@ -61,20 +61,15 @@ describe('determineEntitiesToLock', () => { }); describe('handleLockError', () => { - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - }); - - it('should determine who the user is based on applicationContext', async () => { - await handleLockError(applicationContext, { foo: 'bar' }); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it('should send a notification to the user with "retry_async_request" and the originalRequest', async () => { const mockOriginalRequest = { foo: 'bar', }; - await handleLockError(applicationContext, mockOriginalRequest); + await handleLockError( + applicationContext, + mockOriginalRequest, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -101,8 +96,6 @@ describe('updateTrialSessionInteractor', () => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => mockLock); - - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); }); describe('is locked', () => { @@ -112,7 +105,11 @@ describe('updateTrialSessionInteractor', () => { it('should throw a ServiceUnavailableError if a Case is currently locked', async () => { await expect( - updateTrialSessionInteractor(applicationContext, mockRequest), + updateTrialSessionInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -122,7 +119,11 @@ describe('updateTrialSessionInteractor', () => { it('should return a "retry_async_request" notification with the original request', async () => { await expect( - updateTrialSessionInteractor(applicationContext, mockRequest), + updateTrialSessionInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -134,7 +135,7 @@ describe('updateTrialSessionInteractor', () => { originalRequest: mockRequest, requestToRetry: 'update_trial_session', }, - userId: docketClerkUser.userId, + userId: mockDocketClerkUser.userId, }); expect( @@ -149,7 +150,11 @@ describe('updateTrialSessionInteractor', () => { }); it('should acquire a lock that lasts for 15 minutes', async () => { - await updateTrialSessionInteractor(applicationContext, mockRequest); + await updateTrialSessionInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ); MOCK_TRIAL_INPERSON.caseOrder!.forEach(({ docketNumber }) => { expect( @@ -163,7 +168,11 @@ describe('updateTrialSessionInteractor', () => { }); it('should remove the lock', async () => { - await updateTrialSessionInteractor(applicationContext, mockRequest); + await updateTrialSessionInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ); let expectedIdentifiers = MOCK_TRIAL_INPERSON.caseOrder!.map( ({ docketNumber }) => `case|${docketNumber}`, diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.noticeGeneration.test.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.noticeGeneration.test.ts index 7ba90636006..1c172f17a27 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.noticeGeneration.test.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.noticeGeneration.test.ts @@ -1,6 +1,5 @@ import { CASE_STATUS_TYPES, - ROLES, TRIAL_SESSION_PROCEEDING_TYPES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; @@ -8,20 +7,12 @@ import { MOCK_TRIAL_INPERSON, MOCK_TRIAL_REMOTE, } from '../../../../../shared/src/test/mockTrial'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { updateTrialSessionInteractor } from './updateTrialSessionInteractor'; describe('updateTrialSessionInteractor should Generate Notices of', () => { - const mockUser = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(mockUser); - applicationContext .getUseCaseHelpers() .saveFileAndGenerateUrl.mockReturnValue({ @@ -57,10 +48,14 @@ describe('updateTrialSessionInteractor should Generate Notices of', () => { trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: inPersonNonCalendaredTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: inPersonNonCalendaredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -96,10 +91,14 @@ describe('updateTrialSessionInteractor should Generate Notices of', () => { trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: inPersonCalendaredTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: inPersonCalendaredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -132,10 +131,14 @@ describe('updateTrialSessionInteractor should Generate Notices of', () => { trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: inPersonCalendaredTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: inPersonCalendaredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -169,10 +172,14 @@ describe('updateTrialSessionInteractor should Generate Notices of', () => { trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: inPersonCalendaredTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: inPersonCalendaredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -207,10 +214,14 @@ describe('updateTrialSessionInteractor should Generate Notices of', () => { trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: remoteCalendaredTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: remoteCalendaredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -246,10 +257,14 @@ describe('updateTrialSessionInteractor should Generate Notices of', () => { trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: remoteCalendaredTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: remoteCalendaredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -283,10 +298,14 @@ describe('updateTrialSessionInteractor should Generate Notices of', () => { trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: remoteTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: remoteTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -333,13 +352,17 @@ describe('Change of Trial Judge', () => { trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...remoteCalendaredTrialSession, - judge: mockJudgeOne, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...remoteCalendaredTrialSession, + judge: mockJudgeOne, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().setNoticeOfChangeOfTrialJudge, @@ -374,13 +397,17 @@ describe('Change of Trial Judge', () => { trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...remoteCalendaredTrialSession, - judge: mockJudgeTwo, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...remoteCalendaredTrialSession, + judge: mockJudgeTwo, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().setNoticeOfChangeOfTrialJudge, @@ -413,13 +440,17 @@ describe('Change of Trial Judge', () => { trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...remoteCalendaredTrialSession, - judge: mockJudgeTwo, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...remoteCalendaredTrialSession, + judge: mockJudgeTwo, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().setNoticeOfChangeOfTrialJudge, @@ -453,13 +484,17 @@ describe('Change of Trial Judge', () => { trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...remoteCalendaredTrialSession, - judge: mockJudgeOne, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...remoteCalendaredTrialSession, + judge: mockJudgeOne, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().setNoticeOfChangeOfTrialJudge, @@ -492,13 +527,17 @@ describe('Change of Trial Judge', () => { trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...remoteCalendaredTrialSession, - judge: undefined, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...remoteCalendaredTrialSession, + judge: undefined, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().setNoticeOfChangeOfTrialJudge, @@ -532,13 +571,17 @@ describe('Change of Trial Judge', () => { trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...remoteCalendaredTrialSession, - judge: mockJudgeTwo, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...remoteCalendaredTrialSession, + judge: mockJudgeTwo, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().setNoticeOfChangeOfTrialJudge, diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.ts index 2a29d0f181e..111906a720b 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.ts @@ -16,6 +16,10 @@ import { petitionerUser, trialClerkUser, } from '@shared/test/mockUsers'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { updateTrialSessionInteractor } from './updateTrialSessionInteractor'; describe('updateTrialSessionInteractor', () => { @@ -38,10 +42,14 @@ describe('updateTrialSessionInteractor', () => { applicationContext.getCurrentUser.mockReturnValue(petitionerUser); await expect( - updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: MOCK_TRIAL_REMOTE, - }), + updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: MOCK_TRIAL_REMOTE, + }, + mockPetitionerUser, + ), ).rejects.toThrow(); }); @@ -54,10 +62,14 @@ describe('updateTrialSessionInteractor', () => { }); await expect( - updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { ...MOCK_TRIAL_REMOTE, startDate: '1776-12-01' }, - }), + updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { ...MOCK_TRIAL_REMOTE, startDate: '1776-12-01' }, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Trial session cannot be updated after its start date'); }); @@ -69,10 +81,14 @@ describe('updateTrialSessionInteractor', () => { }); await expect( - updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: MOCK_TRIAL_REMOTE, - }), + updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: MOCK_TRIAL_REMOTE, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(); }); @@ -81,10 +97,14 @@ describe('updateTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockResolvedValue(MOCK_TRIAL_INPERSON); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: MOCK_TRIAL_INPERSON, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: MOCK_TRIAL_INPERSON, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateTrialSession, @@ -99,13 +119,17 @@ describe('updateTrialSessionInteractor', () => { judge: undefined, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - judge: undefined, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + judge: undefined, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createTrialSessionWorkingCopy, @@ -121,13 +145,17 @@ describe('updateTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockResolvedValue(mockTrialSessionWithJudge); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - judge: judgeUser, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + judge: judgeUser, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createTrialSessionWorkingCopy @@ -149,16 +177,20 @@ describe('updateTrialSessionInteractor', () => { }, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - judge: { - name: 'Judge North', - userId: 'c7d90c05-f6cd-442c-a168-202db587f16f', // different judge id + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + judge: { + name: 'Judge North', + userId: 'c7d90c05-f6cd-442c-a168-202db587f16f', // different judge id + }, }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createTrialSessionWorkingCopy @@ -177,13 +209,17 @@ describe('updateTrialSessionInteractor', () => { trialClerk: undefined, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - trialClerk: trialClerkUser, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + trialClerk: trialClerkUser, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createTrialSessionWorkingCopy @@ -205,16 +241,20 @@ describe('updateTrialSessionInteractor', () => { }, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - trialClerk: { - name: 'Clerk Magni', - userId: 'c7d90c05-f6cd-442c-a168-202db587f16f', // different trial clerk id + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + trialClerk: { + name: 'Clerk Magni', + userId: 'c7d90c05-f6cd-442c-a168-202db587f16f', // different trial clerk id + }, }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createTrialSessionWorkingCopy @@ -237,10 +277,14 @@ describe('updateTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_INPERSON); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: MOCK_TRIAL_INPERSON, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: MOCK_TRIAL_INPERSON, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCaseHearing.mock @@ -265,10 +309,14 @@ describe('updateTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_INPERSON); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: MOCK_TRIAL_INPERSON, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: MOCK_TRIAL_INPERSON, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -318,13 +366,17 @@ describe('updateTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_INPERSON); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - ...updatedFields, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + ...updatedFields, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateTrialSession.mock @@ -344,13 +396,17 @@ describe('updateTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_INPERSON); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - ...updatedFields, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + ...updatedFields, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateTrialSession.mock @@ -369,13 +425,17 @@ describe('updateTrialSessionInteractor', () => { isCalendared: false, }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - isCalendared: true, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + isCalendared: true, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateTrialSession.mock @@ -395,10 +455,14 @@ describe('updateTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_INPERSON); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: MOCK_TRIAL_INPERSON, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: MOCK_TRIAL_INPERSON, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -413,10 +477,14 @@ describe('updateTrialSessionInteractor', () => { caseOrder: [], }); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: MOCK_TRIAL_INPERSON, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: MOCK_TRIAL_INPERSON, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -430,18 +498,22 @@ describe('updateTrialSessionInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_INPERSON); - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - caseOrder: [ - { - docketNumber: mockCaseRemovedFromTrialDocketNumber, - removedFromTrial: true, - }, - ], + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + caseOrder: [ + { + docketNumber: mockCaseRemovedFromTrialDocketNumber, + removedFromTrial: true, + }, + ], + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -454,14 +526,18 @@ describe('updateTrialSessionInteractor', () => { it('should associate swing trial sessions when the current trial session has a swing session', async () => { const mockSwingSessionId = '06419775-e726-4c3b-a7e0-193d379fa39d'; - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: { - ...MOCK_TRIAL_INPERSON, - swingSession: true, - swingSessionId: mockSwingSessionId, + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: { + ...MOCK_TRIAL_INPERSON, + swingSession: true, + swingSessionId: mockSwingSessionId, + }, }, - }); + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().associateSwingTrialSessions, @@ -515,10 +591,14 @@ describe('updateTrialSessionInteractor', () => { desiredTrialSession.judge!.userId = '07a2a119-c142-4811-87e0-7d6bc2d06a1b'; - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: desiredTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: desiredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().setNoticeOfChangeOfTrialJudge, @@ -535,10 +615,14 @@ describe('updateTrialSessionInteractor', () => { originalTrialSession.proceedingType = TRIAL_SESSION_PROCEEDING_TYPES.remote; - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: desiredTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: desiredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -559,10 +643,14 @@ describe('updateTrialSessionInteractor', () => { originalTrialSession.proceedingType = TRIAL_SESSION_PROCEEDING_TYPES.inPerson; - await updateTrialSessionInteractor(applicationContext, { - clientConnectionId: '123', - trialSession: desiredTrialSession, - }); + await updateTrialSessionInteractor( + applicationContext, + { + clientConnectionId: '123', + trialSession: desiredTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers() diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index f2353a05bbc..39aa962ed95 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -13,6 +13,7 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { TrialSessionWorkingCopy } from '../../../../../shared/src/business/entities/trialSessions/TrialSessionWorkingCopy'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { get } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -22,10 +23,9 @@ export const updateTrialSession = async ( clientConnectionId, trialSession, }: { trialSession: RawTrialSession; clientConnectionId: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } @@ -148,7 +148,7 @@ export const updateTrialSession = async ( await updateCasesAndSetNoticeOfChange({ applicationContext, - authorizedUser: user, + authorizedUser, currentTrialSession, paperServicePdfsCombined, shouldIssueNoticeOfChangeOfTrialJudge, @@ -185,7 +185,7 @@ export const updateTrialSession = async ( swingSessionId: trialSession.swingSessionId, trialSessionEntity: updatedTrialSessionEntity, }, - user, + authorizedUser, ); } @@ -204,7 +204,7 @@ export const updateTrialSession = async ( pdfUrl, trialSessionId: trialSession.trialSessionId, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; @@ -254,7 +254,7 @@ const updateCasesAndSetNoticeOfChange = async ({ caseEntity, newPdfDoc: paperServicePdfsCombined, newTrialSessionEntity: updatedTrialSessionEntity, - user: applicationContext.getCurrentUser(), + user: authorizedUser, }); } @@ -373,9 +373,8 @@ export const determineEntitiesToLock = async ( export const handleLockError = async ( applicationContext: ServerApplicationContext, originalRequest: any, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - await applicationContext.getNotificationGateway().sendNotificationToUser({ applicationContext, message: { @@ -383,7 +382,7 @@ export const handleLockError = async ( originalRequest, requestToRetry: 'update_trial_session', }, - userId: user.userId, + userId: authorizedUser?.userId || '', }); }; diff --git a/web-api/src/lambdas/trialSessions/updateTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/updateTrialSessionLambda.ts index e358c470acb..b25af5ffa42 100644 --- a/web-api/src/lambdas/trialSessions/updateTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/updateTrialSessionLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -5,11 +6,16 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const updateTrialSessionLambda = event => +export const updateTrialSessionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateTrialSessionInteractor(applicationContext, { + return await applicationContext.getUseCases().updateTrialSessionInteractor( + applicationContext, + { ...JSON.parse(event.body), - }); + }, + authorizedUser, + ); }); From dc65ec8c05c8f50751b659c3072fd65b269f0d7d Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 13:42:52 -0500 Subject: [PATCH 289/523] 10417 remove getCurrentUser from setTrialSessionCalendarInteractor --- .../setTrialSessionCalendarInteractor.test.ts | 104 +++++++++++------- .../setTrialSessionCalendarInteractor.ts | 12 +- .../setTrialSessionCalendarLambda.ts | 16 ++- 3 files changed, 81 insertions(+), 51 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.ts b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.ts index 2576a0a7f4f..67e22583591 100644 --- a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.ts @@ -1,17 +1,15 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { - PARTY_TYPES, - ROLES, - TRIAL_SESSION_PROCEEDING_TYPES, -} from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { setTrialSessionCalendarInteractor } from './setTrialSessionCalendarInteractor'; describe('setTrialSessionCalendarInteractor', () => { - let user; const MOCK_TRIAL = { chambersPhoneNumber: '1111111', joinPhoneNumber: '0987654321', @@ -38,16 +36,11 @@ describe('setTrialSessionCalendarInteractor', () => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => mockLock); - applicationContext.getCurrentUser.mockImplementation(() => user); }); beforeEach(() => { mockLock = undefined; - user = new User({ - name: 'petitionsClerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + applicationContext .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL); @@ -58,19 +51,18 @@ describe('setTrialSessionCalendarInteractor', () => { }); it('throws an exception when there is a permissions issue', async () => { - user = new User({ - name: PARTY_TYPES.petitioner, - role: ROLES.petitioner, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); applicationContext .getPersistenceGateway() .getEligibleCasesForTrialSession.mockReturnValue([MOCK_CASE]); await expect( - setTrialSessionCalendarInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), + setTrialSessionCalendarInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -101,9 +93,13 @@ describe('setTrialSessionCalendarInteractor', () => { .getPersistenceGateway() .setPriorityOnAllWorkItems.mockReturnValue({}); - await setTrialSessionCalendarInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase, @@ -137,9 +133,13 @@ describe('setTrialSessionCalendarInteractor', () => { }, ]); - await setTrialSessionCalendarInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -175,9 +175,13 @@ describe('setTrialSessionCalendarInteractor', () => { }, ]); - await setTrialSessionCalendarInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().setPriorityOnAllWorkItems, @@ -207,9 +211,13 @@ describe('setTrialSessionCalendarInteractor', () => { .getPersistenceGateway() .getCalendaredCasesForTrialSession.mockReturnValue([]); - await setTrialSessionCalendarInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getEligibleCasesForTrialSession @@ -232,9 +240,13 @@ describe('setTrialSessionCalendarInteractor', () => { }, ]); - await setTrialSessionCalendarInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getEligibleCasesForTrialSession @@ -248,9 +260,13 @@ describe('setTrialSessionCalendarInteractor', () => { mockLock = MOCK_LOCK; await expect( - setTrialSessionCalendarInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), + setTrialSessionCalendarInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -259,9 +275,13 @@ describe('setTrialSessionCalendarInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await setTrialSessionCalendarInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts index 140f4cde47a..dcdc52b09ad 100644 --- a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts @@ -11,16 +11,18 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { TRIAL_SESSION_ELIGIBLE_CASES_BUFFER } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { acquireLock } from '@web-api/business/useCaseHelper/acquireLock'; import { flatten, partition, uniq } from 'lodash'; export const setTrialSessionCalendarInteractor = async ( applicationContext: ServerApplicationContext, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.SET_TRIAL_SESSION_CALENDAR)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.SET_TRIAL_SESSION_CALENDAR) + ) { throw new UnauthorizedError('Unauthorized'); } @@ -102,7 +104,7 @@ export const setTrialSessionCalendarInteractor = async ( * @returns {Promise} the promise of the updateCase call */ const setManuallyAddedCaseAsCalendared = caseRecord => { - const caseEntity = new Case(caseRecord, { authorizedUser: user }); + const caseEntity = new Case(caseRecord, { authorizedUser }); caseEntity.setAsCalendared(trialSessionEntity); @@ -126,7 +128,7 @@ export const setTrialSessionCalendarInteractor = async ( * @returns {Promise} the promises of the updateCase and deleteCaseTrialSortMappingRecords calls */ const setTrialSessionCalendarForEligibleCase = caseRecord => { - const caseEntity = new Case(caseRecord, { authorizedUser: user }); + const caseEntity = new Case(caseRecord, { authorizedUser }); caseEntity.setAsCalendared(trialSessionEntity); trialSessionEntity.addCaseToCalendar(caseEntity); diff --git a/web-api/src/lambdas/trialSessions/setTrialSessionCalendarLambda.ts b/web-api/src/lambdas/trialSessions/setTrialSessionCalendarLambda.ts index 53c9edb5ed9..95bf5c0c6f0 100644 --- a/web-api/src/lambdas/trialSessions/setTrialSessionCalendarLambda.ts +++ b/web-api/src/lambdas/trialSessions/setTrialSessionCalendarLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const setTrialSessionCalendarLambda = event => +export const setTrialSessionCalendarLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; return await applicationContext .getUseCases() - .setTrialSessionCalendarInteractor(applicationContext, { - trialSessionId, - }); + .setTrialSessionCalendarInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); }); From 4b742631aa89b160c1e0cd3c6ecf37f11dbc5c22 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 13:46:43 -0500 Subject: [PATCH 290/523] 10417 remove getCurrentUser from setforHearingInteractor --- .../setForHearingInteractor.test.ts | 100 ++++++++++-------- .../trialSessions/setForHearingInteractor.ts | 8 +- .../trialSessions/setForHearingLambda.ts | 13 ++- 3 files changed, 70 insertions(+), 51 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.test.ts b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.test.ts index dbff4458c6b..ce39c335745 100644 --- a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.test.ts @@ -3,21 +3,18 @@ import { MOCK_CASE_WITH_TRIAL_SESSION, } from '../../../../../shared/src/test/mockCase'; import { MOCK_TRIAL_REMOTE } from '../../../../../shared/src/test/mockTrial'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { setForHearingInteractor } from './setForHearingInteractor'; describe('setForHearingInteractor', () => { - let mockCurrentUser; let mockTrialSession; let mockCase; beforeEach(() => { - mockCurrentUser = { - role: ROLES.docketClerk, - userId: '8675309b-18d0-43ec-bafb-654e83405411', - }; - mockTrialSession = MOCK_TRIAL_REMOTE; mockCase = MOCK_CASE; @@ -32,17 +29,16 @@ describe('setForHearingInteractor', () => { }); it('throws an Unauthorized error if the user role is not allowed to access the method', async () => { - mockCurrentUser = { - role: ROLES.petitioner, - userId: '8675309b-18d0-43ec-bafb-654e83405411', - }; - await expect( - setForHearingInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: mockCase.docketNumber, - trialSessionId: '8675309b-18d0-43ec-bafb-654e83405411', - }), + setForHearingInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: mockCase.docketNumber, + trialSessionId: '8675309b-18d0-43ec-bafb-654e83405411', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -52,11 +48,15 @@ describe('setForHearingInteractor', () => { }; await expect( - setForHearingInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: mockCase.docketNumber, - trialSessionId: MOCK_CASE_WITH_TRIAL_SESSION.trialSessionId, - }), + setForHearingInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: mockCase.docketNumber, + trialSessionId: MOCK_CASE_WITH_TRIAL_SESSION.trialSessionId, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('That Hearing is already assigned to the Case'); }); @@ -69,11 +69,15 @@ describe('setForHearingInteractor', () => { }; await expect( - setForHearingInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: mockCase.docketNumber, - trialSessionId: MOCK_CASE_WITH_TRIAL_SESSION.trialSessionId, - }), + setForHearingInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: mockCase.docketNumber, + trialSessionId: MOCK_CASE_WITH_TRIAL_SESSION.trialSessionId, + }, + mockDocketClerkUser, + ), ).rejects.toThrow('That Hearing is already assigned to the Case'); }); @@ -83,11 +87,15 @@ describe('setForHearingInteractor', () => { hearings: [], }; - await setForHearingInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: mockCase.docketNumber, - trialSessionId: MOCK_CASE_WITH_TRIAL_SESSION.trialSessionId, - }); + await setForHearingInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: mockCase.docketNumber, + trialSessionId: MOCK_CASE_WITH_TRIAL_SESSION.trialSessionId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().addCaseToHearing, @@ -99,11 +107,15 @@ describe('setForHearingInteractor', () => { ...MOCK_CASE_WITH_TRIAL_SESSION, }; - await setForHearingInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: mockCase.docketNumber, - trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, - }); + await setForHearingInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: mockCase.docketNumber, + trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().addCaseToHearing, @@ -127,11 +139,15 @@ describe('setForHearingInteractor', () => { ...MOCK_CASE_WITH_TRIAL_SESSION, }; - await setForHearingInteractor(applicationContext, { - calendarNotes: 'this is a calendarNote', - docketNumber: mockCase.docketNumber, - trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, - }); + await setForHearingInteractor( + applicationContext, + { + calendarNotes: 'this is a calendarNote', + docketNumber: mockCase.docketNumber, + trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().addCaseToHearing, diff --git a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts index 8bbc552eb8a..e2f2ea1a933 100644 --- a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.ts @@ -7,6 +7,7 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * setForHearingInteractor @@ -25,10 +26,9 @@ export const setForHearingInteractor = async ( docketNumber, trialSessionId, }: { calendarNotes: string; docketNumber: string; trialSessionId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.SET_FOR_HEARING)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.SET_FOR_HEARING)) { throw new UnauthorizedError('Unauthorized'); } @@ -50,7 +50,7 @@ export const setForHearingInteractor = async ( docketNumber, }); - const caseEntity = new Case(caseDetails, { authorizedUser: user }); + const caseEntity = new Case(caseDetails, { authorizedUser }); const trialSessionEntity = new TrialSession(trialSession); diff --git a/web-api/src/lambdas/trialSessions/setForHearingLambda.ts b/web-api/src/lambdas/trialSessions/setForHearingLambda.ts index bd4a2d39e15..a0b8801a3a3 100644 --- a/web-api/src/lambdas/trialSessions/setForHearingLambda.ts +++ b/web-api/src/lambdas/trialSessions/setForHearingLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,17 +7,19 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const setForHearingLambda = event => +export const setForHearingLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { const { docketNumber, trialSessionId } = event.pathParameters || event.path || {}; const { calendarNotes } = JSON.parse(event.body); - return await applicationContext - .getUseCases() - .setForHearingInteractor(applicationContext, { + return await applicationContext.getUseCases().setForHearingInteractor( + applicationContext, + { calendarNotes, docketNumber, trialSessionId, - }); + }, + authorizedUser, + ); }); From b9c8abbfa34c7011647cb4befdade8669326a659 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 13:53:23 -0500 Subject: [PATCH 291/523] 10417 remove getCurrentUser from serveThirtyDayNoticeInteractor --- .../serveThirtyDayNoticeInteractor.test.ts | 124 +++++++++++------- .../serveThirtyDayNoticeInteractor.ts | 18 +-- .../serveThirtyDayNoticeLambda.ts | 18 ++- 3 files changed, 100 insertions(+), 60 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.test.ts b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.test.ts index 5623104a5a2..577038ea772 100644 --- a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.test.ts @@ -11,9 +11,9 @@ import { ThirtyDayNoticeOfTrialRequiredInfo } from '../../../../../shared/src/bu import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; import { - docketClerkUser, - petitionsClerkUser, -} from '../../../../../shared/src/test/mockUsers'; + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { serveThirtyDayNoticeInteractor } from './serveThirtyDayNoticeInteractor'; import { testPdfDoc } from '../../../../../shared/src/business/test/getFakeFile'; @@ -34,8 +34,6 @@ describe('serveThirtyDayNoticeInteractor', () => { title: 'clerk of court', })); - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - applicationContext.getUtilities().formatNow.mockReturnValue('02/23/2023'); applicationContext @@ -44,22 +42,28 @@ describe('serveThirtyDayNoticeInteractor', () => { }); it('should throw an unauthorized error when the user is not authorized to serve 30 day notices', async () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - await expect( - serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId: TEST_CLIENT_CONNECTION_ID, - trialSessionId: trialSession.trialSessionId!, - }), + serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId: TEST_CLIENT_CONNECTION_ID, + trialSessionId: trialSession.trialSessionId!, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(new UnauthorizedError('Unauthorized')); }); it('should throw an invalid request error when no trial session id is provided', async () => { await expect( - serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId: TEST_CLIENT_CONNECTION_ID, - trialSessionId: undefined as any, - }), + serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId: TEST_CLIENT_CONNECTION_ID, + trialSessionId: undefined as any, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(new InvalidRequest('No trial Session Id provided')); }); @@ -108,10 +112,14 @@ describe('serveThirtyDayNoticeInteractor', () => { ) .mockResolvedValueOnce(caseWithProSePetitioner); - await serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId: TEST_CLIENT_CONNECTION_ID, - trialSessionId: trialSession.trialSessionId!, - }); + await serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId: TEST_CLIENT_CONNECTION_ID, + trialSessionId: trialSession.trialSessionId!, + }, + mockPetitionsClerkUser, + ); const expectedThirtyDayNoticeInfo: ThirtyDayNoticeOfTrialRequiredInfo = { caseCaptionExtension: expect.anything(), @@ -166,7 +174,7 @@ describe('serveThirtyDayNoticeInteractor', () => { noticePdf: expect.anything(), onlyProSePetitioners: true, }, - petitionsClerkUser, + mockPetitionsClerkUser, ); }); @@ -178,10 +186,14 @@ describe('serveThirtyDayNoticeInteractor', () => { 'thirty_day_notice_paper_service_complete', ]; - await serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId: TEST_CLIENT_CONNECTION_ID, - trialSessionId: trialSession.trialSessionId!, - }); + await serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId: TEST_CLIENT_CONNECTION_ID, + trialSessionId: trialSession.trialSessionId!, + }, + mockPetitionsClerkUser, + ); const actualNotificationOrder = applicationContext .getNotificationGateway() @@ -199,10 +211,14 @@ describe('serveThirtyDayNoticeInteractor', () => { }, ]; - await serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId: TEST_CLIENT_CONNECTION_ID, - trialSessionId: trialSession.trialSessionId!, - }); + await serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId: TEST_CLIENT_CONNECTION_ID, + trialSessionId: trialSession.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().saveFileAndGenerateUrl, @@ -235,7 +251,7 @@ describe('serveThirtyDayNoticeInteractor', () => { hasPaper: true, pdfUrl: mockPdfUrl, }, - userId: petitionsClerkUser.userId, + userId: mockPetitionsClerkUser.userId, }); }); @@ -249,10 +265,14 @@ describe('serveThirtyDayNoticeInteractor', () => { }, ]; - await serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId: TEST_CLIENT_CONNECTION_ID, - trialSessionId: trialSession.trialSessionId!, - }); + await serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId: TEST_CLIENT_CONNECTION_ID, + trialSessionId: trialSession.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser, @@ -263,7 +283,7 @@ describe('serveThirtyDayNoticeInteractor', () => { action: 'thirty_day_notice_paper_service_complete', pdfUrl: undefined, }, - userId: petitionsClerkUser.userId, + userId: mockPetitionsClerkUser.userId, }); }); @@ -275,10 +295,14 @@ describe('serveThirtyDayNoticeInteractor', () => { .getPersistenceGateway() .getDocument.mockResolvedValue(testPdfDoc); - await serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId: TEST_CLIENT_CONNECTION_ID, - trialSessionId: trialSession.trialSessionId!, - }); + await serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId: TEST_CLIENT_CONNECTION_ID, + trialSessionId: trialSession.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getUtilities().combineTwoPdfs, @@ -293,10 +317,14 @@ describe('serveThirtyDayNoticeInteractor', () => { .getPersistenceGateway() .getDocument.mockResolvedValue(testPdfDoc); - await serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId: TEST_CLIENT_CONNECTION_ID, - trialSessionId: trialSession.trialSessionId!, - }); + await serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId: TEST_CLIENT_CONNECTION_ID, + trialSessionId: trialSession.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getUtilities().combineTwoPdfs, @@ -338,10 +366,14 @@ describe('serveThirtyDayNoticeInteractor', () => { }, ]; - await serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId: TEST_CLIENT_CONNECTION_ID, - trialSessionId: trialSession.trialSessionId!, - }); + await serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId: TEST_CLIENT_CONNECTION_ID, + trialSessionId: trialSession.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().thirtyDayNoticeOfTrial, diff --git a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts index 47d0d309a93..864a1cac188 100644 --- a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts @@ -18,6 +18,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { getCaseCaptionMeta } from '../../../../../shared/src/business/utilities/getCaseCaptionMeta'; import { getClinicLetterKey } from '../../../../../shared/src/business/utilities/getClinicLetterKey'; import { replaceBracketed } from '../../../../../shared/src/business/utilities/replaceBracketed'; @@ -31,10 +32,9 @@ export const serveThirtyDayNoticeInteractor = async ( trialSessionId: string; clientConnectionId: string; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const currentUser = applicationContext.getCurrentUser(); - - if (!isAuthorized(currentUser, ROLE_PERMISSIONS.DISMISS_NOTT_REMINDER)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.DISMISS_NOTT_REMINDER)) { throw new UnauthorizedError('Unauthorized'); } @@ -69,7 +69,7 @@ export const serveThirtyDayNoticeInteractor = async ( action: 'thirty_day_notice_paper_service_complete', pdfUrl: undefined, }, - userId: currentUser.userId, + userId: authorizedUser.userId, }); return; } @@ -89,7 +89,7 @@ export const serveThirtyDayNoticeInteractor = async ( action: 'paper_service_started', totalPdfs: trialSession.caseOrder.length, }, - userId: currentUser.userId, + userId: authorizedUser.userId, }); let pdfsAppended: number = 0; @@ -104,7 +104,7 @@ export const serveThirtyDayNoticeInteractor = async ( docketNumber: aCase.docketNumber, }); - const caseEntity = new Case(rawCase, { authorizedUser: currentUser }); + const caseEntity = new Case(rawCase, { authorizedUser }); let clinicLetter; const clinicLetterKey = getClinicLetterKey({ @@ -199,7 +199,7 @@ export const serveThirtyDayNoticeInteractor = async ( noticePdf, onlyProSePetitioners: true, }, - currentUser, + authorizedUser, ); await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ @@ -222,7 +222,7 @@ export const serveThirtyDayNoticeInteractor = async ( action: 'paper_service_updated', pdfsAppended, }, - userId: currentUser.userId, + userId: authorizedUser.userId, }); } }); @@ -267,6 +267,6 @@ export const serveThirtyDayNoticeInteractor = async ( hasPaper: hasPaperService, pdfUrl, }, - userId: currentUser.userId, + userId: authorizedUser.userId, }); }; diff --git a/web-api/src/lambdas/trialSessions/serveThirtyDayNoticeLambda.ts b/web-api/src/lambdas/trialSessions/serveThirtyDayNoticeLambda.ts index edd41a12c17..9ba8f450705 100644 --- a/web-api/src/lambdas/trialSessions/serveThirtyDayNoticeLambda.ts +++ b/web-api/src/lambdas/trialSessions/serveThirtyDayNoticeLambda.ts @@ -1,12 +1,20 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -export const serveThirtyDayNoticeLambda = event => +export const serveThirtyDayNoticeLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { clientConnectionId, trialSessionId } = JSON.parse(event.body); return await applicationContext .getUseCases() - .serveThirtyDayNoticeInteractor(applicationContext, { - clientConnectionId, - trialSessionId, - }); + .serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId, + trialSessionId, + }, + authorizedUser, + ); }); From 88cab81426459123c7488b7beec2ae2a6fb00fe0 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Fri, 19 Jul 2024 11:58:24 -0700 Subject: [PATCH 292/523] 10417: remove appcontext.getCurrentUser from serveExternallyFiledDocumentInteractor --- ...llyFiledDocumentInteractor.locking.test.ts | 46 ++- ...eExternallyFiledDocumentInteractor.test.ts | 390 +++++++++++------- .../serveExternallyFiledDocumentInteractor.ts | 9 +- .../serveExternallyFiledDocumentLambda.ts | 22 +- 4 files changed, 295 insertions(+), 172 deletions(-) diff --git a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.locking.test.ts b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.locking.test.ts index 77937cff6b2..a1b3575c6db 100644 --- a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.locking.test.ts +++ b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.locking.test.ts @@ -9,7 +9,7 @@ import { handleLockError, serveExternallyFiledDocumentInteractor, } from '../../../../../web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor'; -import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { testPdfDoc } from '../../../../../shared/src/business/test/getFakeFile'; describe('determineEntitiesToLock', () => { @@ -49,12 +49,22 @@ describe('handleLockError', () => { beforeAll(() => { applicationContext .getPersistenceGateway() - .getUserById.mockReturnValue(docketClerkUser); + .getUserById.mockReturnValue(mockDocketClerkUser); }); - it('should determine who the user is based on applicationContext', async () => { - await handleLockError(applicationContext, { foo: 'bar' }); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); + it('should determine who the user is based on arguents to handleLockError, not appcontext', async () => { + await handleLockError( + applicationContext, + { foo: 'bar' }, + mockDocketClerkUser, + ); + expect( + applicationContext.getNotificationGateway().sendNotificationToUser, + ).toHaveBeenCalledWith( + expect.objectContaining({ + userId: mockDocketClerkUser.userId, + }), + ); }); it('should send a notification to the user with "retry_async_request" and the originalRequest', async () => { @@ -62,7 +72,11 @@ describe('handleLockError', () => { clientConnectionId: mockClientConnectionId, foo: 'bar', }; - await handleLockError(applicationContext, mockOriginalRequest); + await handleLockError( + applicationContext, + mockOriginalRequest, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -103,7 +117,7 @@ describe('serveExternallyFiledDocumentInteractor', () => { beforeEach(() => { mockLock = undefined; // unlocked - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); + // applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); applicationContext .getUseCaseHelpers() @@ -119,7 +133,7 @@ describe('serveExternallyFiledDocumentInteractor', () => { applicationContext .getPersistenceGateway() - .getUserById.mockReturnValue(docketClerkUser); + .getUserById.mockReturnValue(mockDocketClerkUser); applicationContext .getPersistenceGateway() @@ -133,7 +147,11 @@ describe('serveExternallyFiledDocumentInteractor', () => { it('should throw a ServiceUnavailableError if a Case is currently locked', async () => { await expect( - serveExternallyFiledDocumentInteractor(applicationContext, mockRequest), + serveExternallyFiledDocumentInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -143,7 +161,11 @@ describe('serveExternallyFiledDocumentInteractor', () => { it('should return a "retry_async_request" notification with the original request', async () => { await expect( - serveExternallyFiledDocumentInteractor(applicationContext, mockRequest), + serveExternallyFiledDocumentInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -156,7 +178,7 @@ describe('serveExternallyFiledDocumentInteractor', () => { originalRequest: mockRequest, requestToRetry: 'serve_externally_filed_document', }, - userId: docketClerkUser.userId, + userId: mockDocketClerkUser.userId, }); expect( @@ -174,6 +196,7 @@ describe('serveExternallyFiledDocumentInteractor', () => { await serveExternallyFiledDocumentInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ); expect( @@ -189,6 +212,7 @@ describe('serveExternallyFiledDocumentInteractor', () => { await serveExternallyFiledDocumentInteractor( applicationContext, mockRequest, + mockDocketClerkUser, ); expect( diff --git a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.test.ts b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.test.ts index e7450dce845..6dd2f068a8d 100644 --- a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.test.ts @@ -7,7 +7,9 @@ import { applicationContext } from '../../../../../shared/src/business/test/crea import { serveExternallyFiledDocumentInteractor } from './serveExternallyFiledDocumentInteractor'; jest.mock('../addCoverToPdf'); import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('serveExternallyFiledDocumentInteractor', () => { let mockCase; @@ -31,7 +33,7 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }; - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); + // applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); applicationContext .getPersistenceGateway() @@ -55,15 +57,19 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); it('should throw an error when the user is not authorized to serve externally filed documents', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); + // applicationContext.getCurrentUser.mockReturnValue({}); await expect( - serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: '', - docketNumbers: [], - subjectCaseDocketNumber: '', - }), + serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: '', + docketNumbers: [], + subjectCaseDocketNumber: '', + }, + {} as UnknownAuthUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -71,12 +77,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { const mockNonExistentDocketEntryId = 'd9f645b1-c0b6-4782-a798-091760343573'; await expect( - serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockNonExistentDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: '', - }), + serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockNonExistentDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: '', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry not found'); }); @@ -94,12 +104,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); await expect( - serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: '', - }), + serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: '', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry has already been served'); }); @@ -117,12 +131,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); await expect( - serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: '', - }), + serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: '', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry is already being served'); expect( @@ -144,12 +162,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -177,12 +199,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -206,12 +232,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -233,12 +263,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -260,12 +294,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -287,12 +325,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -301,12 +343,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); it('should set the number of pages in the docket entry as the length of the document plus the coversheet', async () => { - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -328,12 +374,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -357,12 +407,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [mockMemberCaseDocketNumber], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [mockMemberCaseDocketNumber], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase, @@ -388,12 +442,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [mockMemberCaseDocketNumber], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [mockMemberCaseDocketNumber], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase, @@ -418,12 +476,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ], }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -442,12 +504,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { docketNumber: memberCaseDocketNumber, }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [memberCaseDocketNumber], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [memberCaseDocketNumber], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().fileAndServeDocumentOnOneCase.mock @@ -463,12 +529,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { it('should call the persistence method to set and unset the pending service status on the subjectCase`s docket entry ONLY', async () => { const memberCaseDocketNumber = '999-16'; - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [memberCaseDocketNumber], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [memberCaseDocketNumber], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -503,12 +573,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { ); await expect( - serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }), + serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(mockErrorText); expect( @@ -534,12 +608,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); it('should call serveDocumentAndGetPaperServicePdf to generate a paper service pdf', async () => { - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: '', - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: '', + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().serveDocumentAndGetPaperServicePdf @@ -550,12 +628,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); it('should send a serve_document_complete notification to the user', async () => { - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -572,12 +654,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); it('should send a notification including the DOCUMENT_SERVED_MESSAGES.SELECTED_CASES message when the docket entry was served on more than one case', async () => { - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: ['102-34'], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: ['102-34'], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -586,12 +672,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); it('should send a notification including the DOCUMENT_SERVED_MESSAGES.ENTRY_ADDED message when the docket entry was served on exactly one case', async () => { - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -600,12 +690,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); it('should send a notification with a paper service url when at least one of the served cases has paper service parties', async () => { - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -620,12 +714,16 @@ describe('serveExternallyFiledDocumentInteractor', () => { pdfUrl: undefined, }); - await serveExternallyFiledDocumentInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - docketEntryId: mockDocketEntryId, - docketNumbers: [], - subjectCaseDocketNumber: mockCase.docketNumber, - }); + await serveExternallyFiledDocumentInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + docketEntryId: mockDocketEntryId, + docketNumbers: [], + subjectCaseDocketNumber: mockCase.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock diff --git a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts index 7d63cce32aa..77605b70095 100644 --- a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts +++ b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts @@ -11,6 +11,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const serveExternallyFiledDocument = async ( @@ -26,9 +27,8 @@ export const serveExternallyFiledDocument = async ( docketNumbers: string[]; subjectCaseDocketNumber: string; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - const hasPermission = (isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY) || isAuthorized( @@ -221,9 +221,8 @@ export const determineEntitiesToLock = ( export const handleLockError = async ( applicationContext: ServerApplicationContext, originalRequest: any, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - await applicationContext.getNotificationGateway().sendNotificationToUser({ applicationContext, clientConnectionId: originalRequest.clientConnectionId, @@ -232,7 +231,7 @@ export const handleLockError = async ( originalRequest, requestToRetry: 'serve_externally_filed_document', }, - userId: user.userId, + userId: authorizedUser!.userId, }); }; diff --git a/web-api/src/lambdas/documents/serveExternallyFiledDocumentLambda.ts b/web-api/src/lambdas/documents/serveExternallyFiledDocumentLambda.ts index 8ebdd98273c..8367e554f83 100644 --- a/web-api/src/lambdas/documents/serveExternallyFiledDocumentLambda.ts +++ b/web-api/src/lambdas/documents/serveExternallyFiledDocumentLambda.ts @@ -1,16 +1,18 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * used for serving externally filed documents - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const serveExternallyFiledDocumentLambda = event => +export const serveExternallyFiledDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .serveExternallyFiledDocumentInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .serveExternallyFiledDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); From 4664d48883647ed3991eb93ea94fc02e669d5bb1 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 14:02:00 -0500 Subject: [PATCH 293/523] 10417 remove getCurrentuser from saveCalendarNoteInteractor --- .../saveCalendarNoteInteractor.test.ts | 104 ++++++++++-------- .../saveCalendarNoteInteractor.ts | 7 +- .../trialSessions/saveCalendarNoteLambda.ts | 16 ++- 3 files changed, 75 insertions(+), 52 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.test.ts b/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.test.ts index 2b5159c5ddb..2657f798d5e 100644 --- a/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.test.ts @@ -2,15 +2,15 @@ import { MOCK_CASE, MOCK_CASE_WITH_TRIAL_SESSION, } from '../../../../../shared/src/test/mockCase'; -import { - ROLES, - TRIAL_SESSION_PROCEEDING_TYPES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { saveCalendarNoteInteractor } from './saveCalendarNoteInteractor'; describe('saveCalendarNotes', () => { - let mockCurrentUser; let mockTrialSession; let mockCase; @@ -27,16 +27,10 @@ describe('saveCalendarNotes', () => { }; beforeEach(() => { - mockCurrentUser = { - role: ROLES.docketClerk, - userId: '8675309b-18d0-43ec-bafb-654e83405411', - }; - mockTrialSession = { ...MOCK_TRIAL }; mockCase = { ...MOCK_CASE }; - applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser); applicationContext .getPersistenceGateway() .getTrialSessionById.mockImplementation(() => mockTrialSession); @@ -46,19 +40,19 @@ describe('saveCalendarNotes', () => { }); it('throws an Unauthorized error if the user role is not allowed to access the method', async () => { - mockCurrentUser = { - role: ROLES.petitioner, - userId: '8675309b-18d0-43ec-bafb-654e83405411', - }; const mockTrialSessionId = '8675309b-18d0-43ec-bafb-654e83405411'; mockCase.trialSessionId = mockTrialSessionId; await expect( - saveCalendarNoteInteractor(applicationContext, { - calendarNote: 'testing', - docketNumber: mockCase.docketNumber, - trialSessionId: mockTrialSessionId, - }), + saveCalendarNoteInteractor( + applicationContext, + { + calendarNote: 'testing', + docketNumber: mockCase.docketNumber, + trialSessionId: mockTrialSessionId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -71,11 +65,15 @@ describe('saveCalendarNotes', () => { '8675309b-18d0-43ec-bafb-654e83405411', ); - await saveCalendarNoteInteractor(applicationContext, { - calendarNote: 'whatever', - docketNumber: mockCase.docketNumber, - trialSessionId: MOCK_CASE_WITH_TRIAL_SESSION.trialSessionId, - }); + await saveCalendarNoteInteractor( + applicationContext, + { + calendarNote: 'whatever', + docketNumber: mockCase.docketNumber, + trialSessionId: MOCK_CASE_WITH_TRIAL_SESSION.trialSessionId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getTrialSessionById, @@ -102,11 +100,15 @@ describe('saveCalendarNotes', () => { mockCase.trialSessionId = mockTrialSession.trialSessionId; - const result = await saveCalendarNoteInteractor(applicationContext, { - calendarNote: 'this is a calendarNote', - docketNumber: mockCase.docketNumber, - trialSessionId: mockTrialSession.trialSessionId, - }); + const result = await saveCalendarNoteInteractor( + applicationContext, + { + calendarNote: 'this is a calendarNote', + docketNumber: mockCase.docketNumber, + trialSessionId: mockTrialSession.trialSessionId, + }, + mockDocketClerkUser, + ); expect(result.trialSessionId).toEqual(mockTrialSession.trialSessionId); expect( @@ -130,11 +132,15 @@ describe('saveCalendarNotes', () => { }); it('does not update the case hearing record if the given trial session is not a hearing on the case', async () => { - await saveCalendarNoteInteractor(applicationContext, { - calendarNote: 'this is a calendarNote', - docketNumber: mockCase.docketNumber, - trialSessionId: mockTrialSession.trialSessionId, - }); + await saveCalendarNoteInteractor( + applicationContext, + { + calendarNote: 'this is a calendarNote', + docketNumber: mockCase.docketNumber, + trialSessionId: mockTrialSession.trialSessionId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -166,11 +172,15 @@ describe('saveCalendarNotes', () => { trialSessionId: '8885309b-18d0-43ec-bafb-654e83405412', }; - await saveCalendarNoteInteractor(applicationContext, { - calendarNote: 'just updating the hearing note', - docketNumber: mockCase.docketNumber, - trialSessionId: '9995309b-18d0-43ec-bafb-654e83405412', - }); + await saveCalendarNoteInteractor( + applicationContext, + { + calendarNote: 'just updating the hearing note', + docketNumber: mockCase.docketNumber, + trialSessionId: '9995309b-18d0-43ec-bafb-654e83405412', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, @@ -202,11 +212,15 @@ describe('saveCalendarNotes', () => { trialSessionId: '8885309b-18d0-43ec-bafb-654e83405412', }; - await saveCalendarNoteInteractor(applicationContext, { - calendarNote: 'just updating the hearing note', - docketNumber: mockCase.docketNumber, - trialSessionId: '9995309b-18d0-43ec-bafb-654e83405412', - }); + await saveCalendarNoteInteractor( + applicationContext, + { + calendarNote: 'just updating the hearing note', + docketNumber: mockCase.docketNumber, + trialSessionId: '9995309b-18d0-43ec-bafb-654e83405412', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, diff --git a/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.ts b/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.ts index 6ddc1f45c2b..43ffaefd900 100644 --- a/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/saveCalendarNoteInteractor.ts @@ -6,6 +6,7 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * saveCalendarNoteInteractor @@ -24,9 +25,11 @@ export const saveCalendarNoteInteractor = async ( docketNumber, trialSessionId, }: { calendarNote: string; docketNumber: string; trialSessionId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - if (!isAuthorized(user, ROLE_PERMISSIONS.ADD_CASE_TO_TRIAL_SESSION)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_CASE_TO_TRIAL_SESSION) + ) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/saveCalendarNoteLambda.ts b/web-api/src/lambdas/trialSessions/saveCalendarNoteLambda.ts index ac0d7f7d237..eef2656dba0 100644 --- a/web-api/src/lambdas/trialSessions/saveCalendarNoteLambda.ts +++ b/web-api/src/lambdas/trialSessions/saveCalendarNoteLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,16 +7,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const saveCalendarNoteLambda = event => +export const saveCalendarNoteLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const lambdaArguments = { ...event.pathParameters, ...JSON.parse(event.body), }; - return await applicationContext - .getUseCases() - .saveCalendarNoteInteractor(applicationContext, { + return await applicationContext.getUseCases().saveCalendarNoteInteractor( + applicationContext, + { ...lambdaArguments, - }); + }, + authorizedUser, + ); }); From bf618dae7e3f0532c423a35f4583b8e0690f4f60 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 14:06:07 -0500 Subject: [PATCH 294/523] 10417 removeGetCurrentUser from runTrialSessionPlanningReportInteractor --- ...ialSessionPlanningReportInteractor.test.ts | 81 +++++++++++-------- ...runTrialSessionPlanningReportInteractor.ts | 6 +- .../runTrialSessionPlanningReportLambda.ts | 16 +++- 3 files changed, 61 insertions(+), 42 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.test.ts b/web-api/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.test.ts index af846e9ff3a..13d8d55ebe1 100644 --- a/web-api/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.test.ts @@ -1,20 +1,15 @@ -import { - ROLES, - TRIAL_CITIES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { TRIAL_CITIES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { runTrialSessionPlanningReportInteractor } from './runTrialSessionPlanningReportInteractor'; describe('run trial session planning report', () => { const mockPdfUrl = 'www.example.com'; - let user; beforeEach(() => { - user = { - role: ROLES.petitionsClerk, - userId: 'petitionsClerk', - }; - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext .getUseCaseHelpers() .saveFileAndGenerateUrl.mockReturnValue(mockPdfUrl); @@ -30,20 +25,19 @@ describe('run trial session planning report', () => { }); it('throws error if user is unauthorized', async () => { - user = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - applicationContext .getPersistenceGateway() .getEligibleCasesForTrialCity.mockReturnValue([]); await expect( - runTrialSessionPlanningReportInteractor(applicationContext, { - term: 'winter', - year: '2020', - }), + runTrialSessionPlanningReportInteractor( + applicationContext, + { + term: 'winter', + year: '2020', + }, + mockPetitionerUser, + ), ).rejects.toThrow(); }); @@ -114,6 +108,7 @@ describe('run trial session planning report', () => { term: 'winter', year: '2020', }, + mockPetitionsClerkUser, ); expect( @@ -149,10 +144,14 @@ describe('run trial session planning report', () => { }); it('sorts trial locations by city', async () => { - await runTrialSessionPlanningReportInteractor(applicationContext, { - term: 'winter', - year: '2020', - }); + await runTrialSessionPlanningReportInteractor( + applicationContext, + { + term: 'winter', + year: '2020', + }, + mockPetitionsClerkUser, + ); const actualtrialLocationData = applicationContext.getDocumentGenerators().trialSessionPlanningReport.mock @@ -171,10 +170,14 @@ describe('run trial session planning report', () => { describe('previous terms', () => { it('returns previous terms when the term is winter', async () => { - await runTrialSessionPlanningReportInteractor(applicationContext, { - term: 'winter', - year: '2020', - }); + await runTrialSessionPlanningReportInteractor( + applicationContext, + { + term: 'winter', + year: '2020', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().trialSessionPlanningReport @@ -187,10 +190,14 @@ describe('run trial session planning report', () => { }); it('returns previous terms when the term is fall', async () => { - await runTrialSessionPlanningReportInteractor(applicationContext, { - term: 'fall', - year: '2020', - }); + await runTrialSessionPlanningReportInteractor( + applicationContext, + { + term: 'fall', + year: '2020', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().trialSessionPlanningReport @@ -203,10 +210,14 @@ describe('run trial session planning report', () => { }); it('returns previous terms when the term is spring', async () => { - await runTrialSessionPlanningReportInteractor(applicationContext, { - term: 'spring', - year: '2020', - }); + await runTrialSessionPlanningReportInteractor( + applicationContext, + { + term: 'spring', + year: '2020', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().trialSessionPlanningReport diff --git a/web-api/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.ts b/web-api/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.ts index 609359d258c..272fd2764dc 100644 --- a/web-api/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor.ts @@ -10,6 +10,7 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { capitalize, invert } from 'lodash'; export type PreviousTerm = { @@ -30,13 +31,12 @@ export type TrialLocationData = { export const runTrialSessionPlanningReportInteractor = async ( applicationContext: ServerApplicationContext, { term, year }: { term: string; year: string }, + authorizedUser: UnknownAuthUser, ): Promise<{ fileId: string; url: string; }> => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/runTrialSessionPlanningReportLambda.ts b/web-api/src/lambdas/trialSessions/runTrialSessionPlanningReportLambda.ts index 06e67990d8d..7ce22fbe88b 100644 --- a/web-api/src/lambdas/trialSessions/runTrialSessionPlanningReportLambda.ts +++ b/web-api/src/lambdas/trialSessions/runTrialSessionPlanningReportLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,15 +7,22 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const runTrialSessionPlanningReportLambda = event => +export const runTrialSessionPlanningReportLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .runTrialSessionPlanningReportInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .runTrialSessionPlanningReportInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); From 9020d254ccf80cfb6cc056b0fcf6f373ab078ec7 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 14:11:59 -0500 Subject: [PATCH 295/523] 10417 remove getCurrentUser from removeCaseFromTrialInteractor --- .../removeCaseFromTrialInteractor.test.ts | 191 ++++++++++-------- .../removeCaseFromTrialInteractor.ts | 14 +- 2 files changed, 117 insertions(+), 88 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.test.ts b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.test.ts index 98782da9c87..4efcd2162f1 100644 --- a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.test.ts @@ -13,14 +13,13 @@ import { import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; import { - petitionerUser, - petitionsClerkUser, -} from '../../../../../shared/src/test/mockUsers'; + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { removeCaseFromTrialInteractor } from './removeCaseFromTrialInteractor'; describe('removeCaseFromTrialInteractor', () => { let mockLock; - let mockUser; let mockTrialSession: RawTrialSession; beforeAll(() => { @@ -31,10 +30,7 @@ describe('removeCaseFromTrialInteractor', () => { beforeEach(() => { mockLock = undefined; - mockUser = petitionsClerkUser; mockTrialSession = cloneDeep(MOCK_TRIAL_INPERSON); - - applicationContext.getCurrentUser.mockImplementation(() => mockUser); applicationContext .getPersistenceGateway() .getTrialSessionById.mockResolvedValue(mockTrialSession); @@ -56,30 +52,37 @@ describe('removeCaseFromTrialInteractor', () => { }); it('should throw an error when the user is unauthorized to remove a case from a trial session', async () => { - mockUser = petitionerUser; await expect( - removeCaseFromTrialInteractor(applicationContext, { - associatedJudge: '123', - associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', - caseStatus: 'new', - disposition: 'because', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }), + removeCaseFromTrialInteractor( + applicationContext, + { + associatedJudge: '123', + associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', + caseStatus: 'new', + disposition: 'because', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('calls getTrialSessionById, updateTrialSession, getCaseByDocketNumber, and updateCase persistence methods with correct parameters for a calendared session', async () => { mockTrialSession.isCalendared = true; - await removeCaseFromTrialInteractor(applicationContext, { - associatedJudge: '123', - associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', - caseStatus: CASE_STATUS_TYPES.generalDocketReadyForTrial, - disposition: 'because', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: mockTrialSession.trialSessionId!, - }); + await removeCaseFromTrialInteractor( + applicationContext, + { + associatedJudge: '123', + associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', + caseStatus: CASE_STATUS_TYPES.generalDocketReadyForTrial, + disposition: 'because', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: mockTrialSession.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getTrialSessionById, @@ -139,14 +142,18 @@ describe('removeCaseFromTrialInteractor', () => { it('calls getTrialSessionById, updateTrialSession, getCaseByDocketNumber, updateCaseAutomaticBlock, and updateCase persistence methods with correct parameters for a not calendared session', async () => { mockTrialSession.isCalendared = false; - await removeCaseFromTrialInteractor(applicationContext, { - associatedJudge: '123', - associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', - caseStatus: CASE_STATUS_TYPES.generalDocketReadyForTrial, - disposition: 'because', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }); + await removeCaseFromTrialInteractor( + applicationContext, + { + associatedJudge: '123', + associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', + caseStatus: CASE_STATUS_TYPES.generalDocketReadyForTrial, + disposition: 'because', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getTrialSessionById.mock @@ -187,14 +194,18 @@ describe('removeCaseFromTrialInteractor', () => { it('updates work items to be not high priority', async () => { mockTrialSession.isCalendared = true; - await removeCaseFromTrialInteractor(applicationContext, { - associatedJudge: '123', - associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', - caseStatus: 'New', - disposition: 'because', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }); + await removeCaseFromTrialInteractor( + applicationContext, + { + associatedJudge: '123', + associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', + caseStatus: 'New', + disposition: 'because', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().setPriorityOnAllWorkItems, @@ -222,14 +233,18 @@ describe('removeCaseFromTrialInteractor', () => { trialSessionId: '959c4338-0fac-42eb-b0eb-d53b8d0195cc', }); - await removeCaseFromTrialInteractor(applicationContext, { - associatedJudge: '123', - associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', - caseStatus: 'New', - disposition: 'because', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }); + await removeCaseFromTrialInteractor( + applicationContext, + { + associatedJudge: '123', + associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', + caseStatus: 'New', + disposition: 'because', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -251,14 +266,18 @@ describe('removeCaseFromTrialInteractor', () => { trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId, }); - await removeCaseFromTrialInteractor(applicationContext, { - associatedJudge: '123', - associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', - caseStatus: 'New', - disposition: 'because', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }); + await removeCaseFromTrialInteractor( + applicationContext, + { + associatedJudge: '123', + associatedJudgeId: '67f246a0-8803-4aef-bbd2-687ef57e3e3f', + caseStatus: 'New', + disposition: 'because', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getTrialSessionById, @@ -306,14 +325,18 @@ describe('removeCaseFromTrialInteractor', () => { it('sets the associatedJudge and caseStatus when provided', async () => { mockTrialSession.isCalendared = true; - const result = await removeCaseFromTrialInteractor(applicationContext, { - associatedJudge: 'Judge Dredd', - associatedJudgeId: 'e5eaf0ac-6a1f-4a5d-a44d-d59f199b7ab5', - caseStatus: CASE_STATUS_TYPES.cav, - disposition: 'because', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }); + const result = await removeCaseFromTrialInteractor( + applicationContext, + { + associatedJudge: 'Judge Dredd', + associatedJudgeId: 'e5eaf0ac-6a1f-4a5d-a44d-d59f199b7ab5', + caseStatus: CASE_STATUS_TYPES.cav, + disposition: 'because', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect(result.associatedJudge).toEqual('Judge Dredd'); expect(result.associatedJudgeId).toEqual( @@ -326,14 +349,18 @@ describe('removeCaseFromTrialInteractor', () => { mockLock = MOCK_LOCK; await expect( - removeCaseFromTrialInteractor(applicationContext, { - associatedJudge: 'Judge Dredd', - associatedJudgeId: 'e5eaf0ac-6a1f-4a5d-a44d-d59f199b7ab5', - caseStatus: CASE_STATUS_TYPES.cav, - disposition: 'because', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }), + removeCaseFromTrialInteractor( + applicationContext, + { + associatedJudge: 'Judge Dredd', + associatedJudgeId: 'e5eaf0ac-6a1f-4a5d-a44d-d59f199b7ab5', + caseStatus: CASE_STATUS_TYPES.cav, + disposition: 'because', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -342,14 +369,18 @@ describe('removeCaseFromTrialInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await removeCaseFromTrialInteractor(applicationContext, { - associatedJudge: 'Judge Dredd', - associatedJudgeId: 'e5eaf0ac-6a1f-4a5d-a44d-d59f199b7ab5', - caseStatus: CASE_STATUS_TYPES.cav, - disposition: 'because', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }); + await removeCaseFromTrialInteractor( + applicationContext, + { + associatedJudge: 'Judge Dredd', + associatedJudgeId: 'e5eaf0ac-6a1f-4a5d-a44d-d59f199b7ab5', + caseStatus: CASE_STATUS_TYPES.cav, + disposition: 'because', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts index 20ffa2b369a..29eb9e594d8 100644 --- a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts @@ -7,6 +7,7 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const removeCaseFromTrial = async ( @@ -26,10 +27,9 @@ export const removeCaseFromTrial = async ( docketNumber: string; trialSessionId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } @@ -64,13 +64,13 @@ export const removeCaseFromTrial = async ( docketNumber, }); - const caseEntity = new Case(myCase, { authorizedUser: user }); + const caseEntity = new Case(myCase, { authorizedUser }); if (!caseEntity.isHearing(trialSessionId)) { caseEntity.removeFromTrial({ associatedJudge, associatedJudgeId, - changedBy: user.name, + changedBy: authorizedUser?.name, updatedCaseStatus: caseStatus, }); @@ -104,9 +104,7 @@ export const removeCaseFromTrial = async ( caseToUpdate: caseEntity, }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const removeCaseFromTrialInteractor = withLocking( From 42af38776c159146626e7eee982228c3361d5b1a Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 14:20:39 -0500 Subject: [PATCH 296/523] 10417 remove getCurrentUser from getTrialSessionWorkingCopyInteractor --- ...tTrialSessionWorkingCopyInteractor.test.ts | 78 +++++++++++-------- .../getTrialSessionWorkingCopyInteractor.ts | 13 ++-- .../getTrialSessionWorkingCopyLambda.ts | 16 +++- 3 files changed, 67 insertions(+), 40 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.ts index 028351c2ac7..35652a4d81c 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.ts @@ -2,6 +2,12 @@ import { ROLES } from '../../../../../shared/src/business/entities/EntityConstan import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getTrialSessionWorkingCopyInteractor } from './getTrialSessionWorkingCopyInteractor'; +import { + mockChambersUser, + mockJudgeUser, + mockPetitionerUser, + mockTrialClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; const MOCK_WORKING_COPY = { @@ -58,15 +64,14 @@ describe('Get trial session working copy', () => { }); it('throws error if user is unauthorized', async () => { - user = { - role: 'unauthorizedRole', - userId: 'unauthorizedUser', - }; - await expect( - getTrialSessionWorkingCopyInteractor(applicationContext, { - trialSessionId: MOCK_WORKING_COPY.trialSessionId, - }), + getTrialSessionWorkingCopyInteractor( + applicationContext, + { + trialSessionId: MOCK_WORKING_COPY.trialSessionId, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -78,9 +83,13 @@ describe('Get trial session working copy', () => { ); await expect( - getTrialSessionWorkingCopyInteractor(applicationContext, { - trialSessionId: MOCK_WORKING_COPY.trialSessionId, - }), + getTrialSessionWorkingCopyInteractor( + applicationContext, + { + trialSessionId: MOCK_WORKING_COPY.trialSessionId, + }, + mockJudgeUser, + ), ).rejects.toThrow('The TrialSessionWorkingCopy entity was invalid'); }); @@ -90,12 +99,14 @@ describe('Get trial session working copy', () => { { trialSessionId: MOCK_WORKING_COPY.trialSessionId, }, + mockJudgeUser, ); expect(result).toMatchObject(MOCK_WORKING_COPY); }); it('does not return data if none is returned from persistence', async () => { user = { + ...mockJudgeUser, name: 'judge who cannot create working copy', role: ROLES.judge, userId: 'something else', @@ -108,17 +119,18 @@ describe('Get trial session working copy', () => { .getJudgeInSectionHelper.mockReturnValue(null); await expect( - getTrialSessionWorkingCopyInteractor(applicationContext, { - trialSessionId: MOCK_WORKING_COPY.trialSessionId, - }), + getTrialSessionWorkingCopyInteractor( + applicationContext, + { + trialSessionId: MOCK_WORKING_COPY.trialSessionId, + }, + mockJudgeUser, + ), ).rejects.toThrow('Trial session working copy not found'); }); it('correctly returns data from persistence for a trial clerk user', async () => { - user = { - role: ROLES.trialClerk, - userId: 'a9ae05ba-d48a-43a6-9981-ee536a7601be', - }; + user = mockTrialClerkUser; applicationContext .getUseCaseHelpers() .getJudgeInSectionHelper.mockImplementation(() => {}); @@ -128,12 +140,13 @@ describe('Get trial session working copy', () => { { trialSessionId: MOCK_WORKING_COPY.trialSessionId, }, + user, ); expect( applicationContext.getPersistenceGateway().getTrialSessionWorkingCopy.mock .calls[0][0], ).toMatchObject({ - userId: 'a9ae05ba-d48a-43a6-9981-ee536a7601be', + userId: mockTrialClerkUser.userId, }); expect(result).toMatchObject(MOCK_WORKING_COPY); }); @@ -185,15 +198,16 @@ describe('Get trial session working copy', () => { trialClerk: undefined, trialLocation: 'Birmingham, Alabama', }); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.judge, - userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', - }); + applicationContext.getCurrentUser.mockReturnValue(); const result = await getTrialSessionWorkingCopyInteractor( applicationContext, { trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, + { + ...mockJudgeUser, + userId: 'd7d90c05-f6cd-442c-a168-202db587f16f', + }, ); expect( applicationContext.getPersistenceGateway().getTrialSessionById, @@ -212,15 +226,16 @@ describe('Get trial session working copy', () => { applicationContext .getUseCaseHelpers() .getJudgeInSectionHelper.mockReturnValueOnce(undefined); - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.trialClerk, - userId: 'ffd90c05-f6cd-442c-a168-202db587f16f', - }); + const result = await getTrialSessionWorkingCopyInteractor( applicationContext, { trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, + { + ...mockTrialClerkUser, + userId: 'ffd90c05-f6cd-442c-a168-202db587f16f', + }, ); expect( applicationContext.getPersistenceGateway().getTrialSessionById, @@ -236,15 +251,16 @@ describe('Get trial session working copy', () => { }); it('for current user who is a chambers user whose associated judge is on this trial session', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.chambers, - userId: 'ffd90c05-f6cd-442c-a168-202db587f16f', - }); const result = await getTrialSessionWorkingCopyInteractor( applicationContext, { trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, + { + ...mockChambersUser, + role: ROLES.chambers, + userId: 'ffd90c05-f6cd-442c-a168-202db587f16f', + }, ); expect( applicationContext.getPersistenceGateway().getTrialSessionById, diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.ts index 2a984ac64bf..b448ba5c306 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.ts @@ -6,6 +6,7 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { TrialSessionWorkingCopy } from '../../../../../shared/src/business/entities/trialSessions/TrialSessionWorkingCopy'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { User } from '../../../../../shared/src/business/entities/User'; /** @@ -19,16 +20,17 @@ import { User } from '../../../../../shared/src/business/entities/User'; export const getTrialSessionWorkingCopyInteractor = async ( applicationContext: ServerApplicationContext, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY) + ) { throw new UnauthorizedError('Unauthorized'); } const rawUser = await applicationContext.getPersistenceGateway().getUserById({ applicationContext, - userId: user.userId, + userId: authorizedUser?.userId || '', }); const userEntity = new User(rawUser); @@ -39,7 +41,8 @@ export const getTrialSessionWorkingCopyInteractor = async ( section: userEntity.section, }); - const chambersUserId = (judgeUser && judgeUser.userId) || user.userId; + const chambersUserId = + (judgeUser && judgeUser.userId) || authorizedUser?.userId || ''; let trialSessionWorkingCopyEntity, validRawTrialSessionWorkingCopyEntity; diff --git a/web-api/src/lambdas/trialSessions/getTrialSessionWorkingCopyLambda.ts b/web-api/src/lambdas/trialSessions/getTrialSessionWorkingCopyLambda.ts index ff90a692db0..df8f4524ca9 100644 --- a/web-api/src/lambdas/trialSessions/getTrialSessionWorkingCopyLambda.ts +++ b/web-api/src/lambdas/trialSessions/getTrialSessionWorkingCopyLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getTrialSessionWorkingCopyLambda = event => +export const getTrialSessionWorkingCopyLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; return await applicationContext .getUseCases() - .getTrialSessionWorkingCopyInteractor(applicationContext, { - trialSessionId, - }); + .getTrialSessionWorkingCopyInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); }); From beb4ad0315b6614d62e5e86112f5edd7a71e51e5 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 14:27:23 -0500 Subject: [PATCH 297/523] 10417 remove getCurrentUser from getTrialSessionsForJudgeInteractor --- .../getTrialSessionsForJudgeInteractor.test.ts | 18 ++++++++++-------- .../getTrialSessionsForJudgeInteractor.ts | 6 +++--- .../getTrialSessionsForJudgeLambda.ts | 7 ++++++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.test.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.test.ts index b9f3939a7b6..40b82c14228 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.test.ts @@ -1,6 +1,9 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getTrialSessionsForJudgeInteractor } from './getTrialSessionsForJudgeInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; const MOCK_TRIAL_SESSION = { maxCases: 100, @@ -21,17 +24,15 @@ describe('getTrialSessionsForJudgeInteractor', () => { ); await expect( - getTrialSessionsForJudgeInteractor(applicationContext, JUDGE_ID), + getTrialSessionsForJudgeInteractor( + applicationContext, + JUDGE_ID, + mockPetitionerUser, + ), ).rejects.toThrow(); }); it('should only return trial sessions associated with the judgeId', async () => { - applicationContext.getCurrentUser.mockImplementation(() => { - return { - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }; - }); applicationContext .getPersistenceGateway() .getTrialSessions.mockResolvedValue([ @@ -47,6 +48,7 @@ describe('getTrialSessionsForJudgeInteractor', () => { const trialSessions = await getTrialSessionsForJudgeInteractor( applicationContext, JUDGE_ID, + mockPetitionsClerkUser, ); expect(trialSessions.length).toEqual(1); diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.ts index 4b0f2df10a5..8e9d11cde39 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor.ts @@ -6,6 +6,7 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { TrialSessionInfoDTO } from '../../../../../shared/src/business/dto/trialSessions/TrialSessionInfoDTO'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * getTrialSessionsForJudgeInteractor @@ -16,10 +17,9 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const getTrialSessionsForJudgeInteractor = async ( applicationContext: ServerApplicationContext, judgeId: string, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/getTrialSessionsForJudgeLambda.ts b/web-api/src/lambdas/trialSessions/getTrialSessionsForJudgeLambda.ts index ab395104279..69f4d67faed 100644 --- a/web-api/src/lambdas/trialSessions/getTrialSessionsForJudgeLambda.ts +++ b/web-api/src/lambdas/trialSessions/getTrialSessionsForJudgeLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +7,16 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getTrialSessionsForJudgeLambda = event => +export const getTrialSessionsForJudgeLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() .getTrialSessionsForJudgeInteractor( applicationContext, event.pathParameters.judgeId, + authorizedUser, ); }); From b673983473207c81cc51ec11e27a3314a5528a09 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 14:42:09 -0500 Subject: [PATCH 298/523] 10417 remove getCurrentUser from getTrialSessionDetailsInteractor --- .../getTrialSessionDetailsInteractor.test.ts | 57 +++++++++++-------- .../getTrialSessionDetailsInteractor.ts | 5 +- .../getTrialSessionDetailsLambda.ts | 16 ++++-- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.test.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.test.ts index 051bf63e734..9d80a54ea29 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.test.ts @@ -1,10 +1,11 @@ -import { - ROLES, - TRIAL_SESSION_PROCEEDING_TYPES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getTrialSessionDetailsInteractor } from './getTrialSessionDetailsInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('Get trial session details', () => { @@ -19,23 +20,19 @@ describe('Get trial session details', () => { trialSessionId: '208a959f-9526-4db5-b262-e58c476a4604', }; - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }); - }); - it('throws error if user is unauthorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); applicationContext .getPersistenceGateway() .getTrialSessionById.mockReturnValue({}); await expect( - getTrialSessionDetailsInteractor(applicationContext, { - trialSessionId: MOCK_TRIAL_SESSION.trialSessionId, - }), + getTrialSessionDetailsInteractor( + applicationContext, + { + trialSessionId: MOCK_TRIAL_SESSION.trialSessionId, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -47,9 +44,13 @@ describe('Get trial session details', () => { ); await expect( - getTrialSessionDetailsInteractor(applicationContext, { - trialSessionId: MOCK_TRIAL_SESSION.trialSessionId, - }), + getTrialSessionDetailsInteractor( + applicationContext, + { + trialSessionId: MOCK_TRIAL_SESSION.trialSessionId, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('The TrialSession entity was invalid'); }); @@ -59,9 +60,13 @@ describe('Get trial session details', () => { .getTrialSessionById.mockResolvedValue(null); await expect( - getTrialSessionDetailsInteractor(applicationContext, { - trialSessionId: MOCK_TRIAL_SESSION.trialSessionId, - }), + getTrialSessionDetailsInteractor( + applicationContext, + { + trialSessionId: MOCK_TRIAL_SESSION.trialSessionId, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow( 'Trial session 208a959f-9526-4db5-b262-e58c476a4604 was not found.', ); @@ -72,9 +77,13 @@ describe('Get trial session details', () => { .getPersistenceGateway() .getTrialSessionById.mockResolvedValue(MOCK_TRIAL_SESSION); - const result = await getTrialSessionDetailsInteractor(applicationContext, { - trialSessionId: MOCK_TRIAL_SESSION.trialSessionId, - }); + const result = await getTrialSessionDetailsInteractor( + applicationContext, + { + trialSessionId: MOCK_TRIAL_SESSION.trialSessionId, + }, + mockPetitionsClerkUser, + ); expect(result).toMatchObject(MOCK_TRIAL_SESSION); }); }); diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.ts index 9becc981c83..650b8abcdde 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionDetailsInteractor.ts @@ -8,13 +8,14 @@ import { TrialSession, } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const getTrialSessionDetailsInteractor = async ( applicationContext: ServerApplicationContext, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/getTrialSessionDetailsLambda.ts b/web-api/src/lambdas/trialSessions/getTrialSessionDetailsLambda.ts index d57ee20f1c3..7d98ac52fdf 100644 --- a/web-api/src/lambdas/trialSessions/getTrialSessionDetailsLambda.ts +++ b/web-api/src/lambdas/trialSessions/getTrialSessionDetailsLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getTrialSessionDetailsLambda = event => +export const getTrialSessionDetailsLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; return await applicationContext .getUseCases() - .getTrialSessionDetailsInteractor(applicationContext, { - trialSessionId, - }); + .getTrialSessionDetailsInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); }); From 7410697a2abbb8315de08836cb350b87ef82fe1a Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 14:45:24 -0500 Subject: [PATCH 299/523] 10417 remove getCurrentUser from getEligibleCasesForTrialSessionInteractor --- ...ibleCasesForTrialSessionInteractor.test.ts | 51 ++++++++++--------- ...tEligibleCasesForTrialSessionInteractor.ts | 6 +-- .../getEligibleCasesForTrialSessionLambda.ts | 16 ++++-- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.test.ts index 32e4f90a035..429b3c6e3ef 100644 --- a/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.test.ts @@ -3,17 +3,16 @@ import { MOCK_ELIGIBLE_CASE, MOCK_ELIGIBLE_CASE_WITH_PRACTITIONERS, } from '../../../../../shared/src/test/mockCase'; -import { - ROLES, - TRIAL_SESSION_PROCEEDING_TYPES, -} from '../../../../../shared/src/business/entities/EntityConstants'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; import { getEligibleCasesForTrialSessionInteractor } from './getEligibleCasesForTrialSessionInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getEligibleCasesForTrialSessionInteractor', () => { - let mockCurrentUser; let mockTrial; const MOCK_TRIAL = { @@ -32,15 +31,8 @@ describe('getEligibleCasesForTrialSessionInteractor', () => { }; beforeEach(() => { - mockCurrentUser = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - mockTrial = MOCK_TRIAL; - applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser); applicationContext .getPersistenceGateway() .getTrialSessionById.mockImplementation(() => mockTrial); @@ -55,27 +47,37 @@ describe('getEligibleCasesForTrialSessionInteractor', () => { }); it('throws an exception when it fails to find the cases for a trial session', async () => { - mockCurrentUser = {}; - await expect( - getEligibleCasesForTrialSessionInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), + getEligibleCasesForTrialSessionInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionerUser, + ), ).rejects.toThrow(); }); it('should find the cases for a trial session successfully', async () => { await expect( - getEligibleCasesForTrialSessionInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), + getEligibleCasesForTrialSessionInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); }); it('should call getEligibleCasesForTrialSession with correct limit', async () => { - await getEligibleCasesForTrialSessionInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await getEligibleCasesForTrialSessionInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().getEligibleCasesForTrialSession @@ -111,6 +113,7 @@ describe('getEligibleCasesForTrialSessionInteractor', () => { { trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', }, + mockDocketClerkUser, ); } catch (e) { error = e; diff --git a/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.ts index 4de085e4cc4..687bb4f4566 100644 --- a/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor.ts @@ -11,6 +11,7 @@ import { } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { TRIAL_SESSION_ELIGIBLE_CASES_BUFFER } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * get eligible cases for trial session @@ -23,10 +24,9 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const getEligibleCasesForTrialSessionInteractor = async ( applicationContext: ServerApplicationContext, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/getEligibleCasesForTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/getEligibleCasesForTrialSessionLambda.ts index 6b5696412b8..85457b0dadb 100644 --- a/web-api/src/lambdas/trialSessions/getEligibleCasesForTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/getEligibleCasesForTrialSessionLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getEligibleCasesForTrialSessionLambda = event => +export const getEligibleCasesForTrialSessionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; return await applicationContext .getUseCases() - .getEligibleCasesForTrialSessionInteractor(applicationContext, { - trialSessionId, - }); + .getEligibleCasesForTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); }); From 8a45eddc034b75ff10f8ef845c878b5432f435fe Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Fri, 19 Jul 2024 15:48:04 -0400 Subject: [PATCH 300/523] 10417 update getTrialSessionsInteractor and Lambda --- .../getTrialSessionsInteractor.test.ts | 14 +++++++------- .../trialSessions/getTrialSessionsInteractor.ts | 7 ++++--- .../trialSessions/getTrialSessionsLambda.ts | 8 ++++++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts index a1754bdeb8b..3abbd63f244 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts @@ -14,14 +14,12 @@ import { describe('getTrialSessionsInteractor', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); + //applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); }); it('should throw an unauthorized error when the user does not have permission to view trial sessions', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - await expect( - getTrialSessionsInteractor(applicationContext), + getTrialSessionsInteractor(applicationContext, petitionerUser), ).rejects.toThrow(new UnauthorizedError('Unauthorized')); }); @@ -33,7 +31,7 @@ describe('getTrialSessionsInteractor', () => { ]); await expect( - getTrialSessionsInteractor(applicationContext), + getTrialSessionsInteractor(applicationContext, petitionsClerkUser), ).rejects.toThrow('The TrialSession entity was invalid.'); }); @@ -45,8 +43,10 @@ describe('getTrialSessionsInteractor', () => { MOCK_TRIAL_REGULAR, ]); - const trialSessionDTOs = - await getTrialSessionsInteractor(applicationContext); + const trialSessionDTOs = await getTrialSessionsInteractor( + applicationContext, + petitionsClerkUser, + ); trialSessionDTOs.forEach(trialSessionDTO => { expect(trialSessionDTO instanceof TrialSessionInfoDTO).toBe(true); diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts index bef3f8fca13..181bad45c29 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts @@ -6,13 +6,14 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { TrialSessionInfoDTO } from '../../../../../shared/src/business/dto/trialSessions/TrialSessionInfoDTO'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const getTrialSessionsInteractor = async ( applicationContext: ServerApplicationContext, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + console.debug('Unauthorized'); throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts b/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts index 395074488a6..b06bddea703 100644 --- a/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts +++ b/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,9 +7,12 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getTrialSessionsLambda = event => +export const getTrialSessionsLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getTrialSessionsInteractor(applicationContext); + .getTrialSessionsInteractor(applicationContext, authorizedUser); }); From 01037ae9a40ecace9a0d795fa50bc3a57654f6e9 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 14:49:10 -0500 Subject: [PATCH 301/523] 10417 remove getCurrentUser from getCalendaredCasesForTrialInteractor --- ...aredCasesForTrialSessionInteractor.test.ts | 47 +++++++++---------- ...alendaredCasesForTrialSessionInteractor.ts | 5 +- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.test.ts index 6802e75469c..d5cb3acf4f7 100644 --- a/web-api/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.test.ts @@ -1,48 +1,41 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; -import { - PARTIES_CODES, - PARTY_TYPES, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { PARTIES_CODES } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getCalendaredCasesForTrialSessionInteractor } from './getCalendaredCasesForTrialSessionInteractor'; - -const user = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', -}); +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getCalendaredCasesForTrialSessionInteractor', () => { beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(user); applicationContext .getPersistenceGateway() .getCalendaredCasesForTrialSession.mockReturnValue([MOCK_CASE]); }); it('throws an exception when the user is unauthorized', async () => { - const unAuthedUser = new User({ - name: PARTY_TYPES.petitioner, - role: ROLES.petitioner, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - applicationContext.getCurrentUser.mockReturnValueOnce(unAuthedUser); - await expect( - getCalendaredCasesForTrialSessionInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), + getCalendaredCasesForTrialSessionInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should find the cases for a trial session successfully', async () => { await expect( - getCalendaredCasesForTrialSessionInteractor(applicationContext, { - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), + getCalendaredCasesForTrialSessionInteractor( + applicationContext, + { + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); }); @@ -74,6 +67,7 @@ describe('getCalendaredCasesForTrialSessionInteractor', () => { { trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', }, + mockDocketClerkUser, ); expect(cases[0].PMTServedPartiesCode).toEqual(PARTIES_CODES.PETITIONER); @@ -89,6 +83,7 @@ describe('getCalendaredCasesForTrialSessionInteractor', () => { { trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', }, + mockDocketClerkUser, ); removedFields.forEach(field => { diff --git a/web-api/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.ts index 933209df281..f694430ee72 100644 --- a/web-api/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor.ts @@ -5,13 +5,14 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const getCalendaredCasesForTrialSessionInteractor = async ( applicationContext: ServerApplicationContext, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } From 4a889692efc016a735bdf104e29dd281883d2ee1 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 19 Jul 2024 14:50:45 -0500 Subject: [PATCH 302/523] 10417 pass in user at getCalandaredCasesForTrialSessionLambda --- .../getCalendaredCasesForTrialSessionLambda.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/web-api/src/lambdas/trialSessions/getCalendaredCasesForTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/getCalendaredCasesForTrialSessionLambda.ts index 851268ca194..af93e721ac5 100644 --- a/web-api/src/lambdas/trialSessions/getCalendaredCasesForTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/getCalendaredCasesForTrialSessionLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCalendaredCasesForTrialSessionLambda = event => +export const getCalendaredCasesForTrialSessionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; return await applicationContext .getUseCases() - .getCalendaredCasesForTrialSessionInteractor(applicationContext, { - trialSessionId, - }); + .getCalendaredCasesForTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); }); From f1c793d83e8f93640f8896253d2cc13c28d5f300 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Fri, 19 Jul 2024 15:18:30 -0700 Subject: [PATCH 303/523] 10417: remove appcontext.getCurrentUser from fileExternalDocumentInteractor --- .../fileExternalDocumentInteractor.test.ts | 260 ++++++++++-------- .../fileExternalDocumentInteractor.ts | 4 +- .../fileExternalDocumentToCaseLambda.ts | 7 +- 3 files changed, 156 insertions(+), 115 deletions(-) diff --git a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.test.ts b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.test.ts index fdae30c6f39..0c9108981bf 100644 --- a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.test.ts @@ -11,11 +11,13 @@ import { SIMULTANEOUS_DOCUMENT_EVENT_CODES, } from '@shared/business/entities/EntityConstants'; import { MOCK_LOCK } from '@shared/test/mockLock'; -import { MOCK_USERS, docketClerkUser } from '@shared/test/mockUsers'; import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '@shared/business/entities/User'; import { applicationContext } from '@shared/business/test/createTestApplicationContext'; import { fileExternalDocumentInteractor } from './fileExternalDocumentInteractor'; +import { + mockDocketClerkUser, + mockIrsPractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('fileExternalDocumentInteractor', () => { const mockDocketEntryId = applicationContext.getUniqueId(); @@ -103,17 +105,9 @@ describe('fileExternalDocumentInteractor', () => { userId: '0e97c6b4-d299-44f5-af99-2ce905d520f2', }; - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'irsPractitioner', - role: ROLES.irsPractitioner, - userId: 'f7d90c05-f6cd-442c-a168-202db587f16f', - }), - ); - applicationContext .getPersistenceGateway() - .getUserById.mockImplementation(({ userId }) => MOCK_USERS[userId]); + .getUserById.mockReturnValue(mockIrsPractitionerUser); applicationContext .getPersistenceGateway() @@ -121,34 +115,40 @@ describe('fileExternalDocumentInteractor', () => { }); it('should throw an error when the user is not authorized to file an external document on a case', async () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - await expect( - fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'A', - filedBy: 'Test Petitioner', - primaryDocumentId: mockDocketEntryId, + fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'A', + filedBy: 'Test Petitioner', + primaryDocumentId: mockDocketEntryId, + }, }, - }), + mockDocketClerkUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should validate docket entry entities before adding them to the case and not call service or persistence methods', async () => { await expect( - fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'XYZ', - filedBy: 'Test Petitioner', - primaryDocumentId: mockDocketEntryId, + fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'XYZ', + filedBy: 'Test Petitioner', + primaryDocumentId: mockDocketEntryId, + }, }, - }), + mockIrsPractitionerUser, + ), ).rejects.toThrow('The DocketEntry entity was invalid.'); expect( @@ -178,6 +178,7 @@ describe('fileExternalDocumentInteractor', () => { primaryDocumentId: mockDocketEntryId, }, }, + mockIrsPractitionerUser, ); expect( @@ -192,7 +193,7 @@ describe('fileExternalDocumentInteractor', () => { expect( applicationContext.getUseCaseHelpers().sendServedPartiesEmails, ).toHaveBeenCalled(); - expect(updatedCase.docketEntries[4].servedAt).toBeDefined(); + expect(updatedCase!.docketEntries[4].servedAt).toBeDefined(); }); it('should add documents and workitems and auto-serve the documents on the parties with an electronic service indicator across consolidated cases', async () => { @@ -295,6 +296,7 @@ describe('fileExternalDocumentInteractor', () => { primaryDocumentId: mockDocketEntryId, }, }, + mockIrsPractitionerUser, ); expect( @@ -312,20 +314,24 @@ describe('fileExternalDocumentInteractor', () => { expect( applicationContext.getUseCaseHelpers().sendServedPartiesEmails, ).toHaveBeenCalledTimes(2); - expect(updatedCase.docketEntries[4].servedAt).toBeDefined(); + expect(updatedCase!.docketEntries[4].servedAt).toBeDefined(); }); it('should use original case caption to create case title when creating work item', async () => { - await fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'A', - filedBy: 'Test Petitioner', - primaryDocumentId: mockDocketEntryId, + await fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'A', + filedBy: 'Test Petitioner', + primaryDocumentId: mockDocketEntryId, + }, }, - }); + mockIrsPractitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem.mock.calls[0][0] @@ -377,11 +383,12 @@ describe('fileExternalDocumentInteractor', () => { ], }, }, + mockIrsPractitionerUser, ); expect( applicationContext.getPersistenceGateway().updateCase, ).toHaveBeenCalled(); - expect(updatedCase.docketEntries).toMatchObject([ + expect(updatedCase!.docketEntries).toMatchObject([ {}, // first 4 docs were already on the case {}, {}, @@ -424,6 +431,7 @@ describe('fileExternalDocumentInteractor', () => { primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', }, }, + mockIrsPractitionerUser, ); expect( @@ -438,8 +446,8 @@ describe('fileExternalDocumentInteractor', () => { expect( applicationContext.getUseCaseHelpers().sendServedPartiesEmails, ).not.toHaveBeenCalled(); - expect(updatedCase.docketEntries[3].status).toBeUndefined(); - expect(updatedCase.docketEntries[3].servedAt).toBeUndefined(); + expect(updatedCase!.docketEntries[3].status).toBeUndefined(); + expect(updatedCase!.docketEntries[3].servedAt).toBeUndefined(); }); it('should create a high-priority work item if the case status is calendared', async () => { @@ -447,16 +455,20 @@ describe('fileExternalDocumentInteractor', () => { caseRecord.trialDate = '2019-03-01T21:40:46.415Z'; caseRecord.trialSessionId = 'c54ba5a9-b37b-479d-9201-067ec6e335bc'; - await fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Simultaneous Memoranda of Law', - documentType: 'Simultaneous Memoranda of Law', - eventCode: 'A', - filedBy: 'Test Petitioner', - primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + await fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Simultaneous Memoranda of Law', + documentType: 'Simultaneous Memoranda of Law', + eventCode: 'A', + filedBy: 'Test Petitioner', + primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, }, - }); + mockIrsPractitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem, @@ -471,16 +483,20 @@ describe('fileExternalDocumentInteractor', () => { it('should create a not-high-priority work item if the case status is not calendared', async () => { caseRecord.status = CASE_STATUS_TYPES.new; - await fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Simultaneous Memoranda of Law', - documentType: 'Simultaneous Memoranda of Law', - eventCode: 'A', - filedBy: 'test Petitioner', - primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + await fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Simultaneous Memoranda of Law', + documentType: 'Simultaneous Memoranda of Law', + eventCode: 'A', + filedBy: 'test Petitioner', + primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, }, - }); + mockIrsPractitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveWorkItem, @@ -493,17 +509,21 @@ describe('fileExternalDocumentInteractor', () => { }); it('should automatically block the case if the document filed is a tracked document', async () => { - await fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - category: 'Application', - docketNumber: caseRecord.docketNumber, - documentTitle: 'Application for Waiver of Filing Fee', - documentType: 'Application for Waiver of Filing Fee', - eventCode: 'APPW', - filedBy: 'Test Petitioner', - primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + await fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + category: 'Application', + docketNumber: caseRecord.docketNumber, + documentTitle: 'Application for Waiver of Filing Fee', + documentType: 'Application for Waiver of Filing Fee', + eventCode: 'APPW', + filedBy: 'Test Petitioner', + primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, }, - }); + mockIrsPractitionerUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -528,17 +548,21 @@ describe('fileExternalDocumentInteractor', () => { }, ]); - await fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - category: 'Application', - docketNumber: caseRecord.docketNumber, - documentTitle: 'Application for Waiver of Filing Fee', - documentType: 'Application for Waiver of Filing Fee', - eventCode: 'APPW', - filedBy: 'Test Petitioner', - primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + await fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + category: 'Application', + docketNumber: caseRecord.docketNumber, + documentTitle: 'Application for Waiver of Filing Fee', + documentType: 'Application for Waiver of Filing Fee', + eventCode: 'APPW', + filedBy: 'Test Petitioner', + primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, }, - }); + mockIrsPractitionerUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -555,16 +579,20 @@ describe('fileExternalDocumentInteractor', () => { }); it('should not sendServedPartiesEmails if docketEntryId is undefined', async () => { - await fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Memorandum in Support', - documentType: 'Memorandum in Support', - eventCode: 'XYZ', - filedBy: 'Test Petitioner', - primaryDocumentId: undefined, + await fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + docketNumber: caseRecord.docketNumber, + documentTitle: 'Memorandum in Support', + documentType: 'Memorandum in Support', + eventCode: 'XYZ', + filedBy: 'Test Petitioner', + primaryDocumentId: undefined, + }, }, - }); + mockIrsPractitionerUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -578,17 +606,21 @@ describe('fileExternalDocumentInteractor', () => { mockLock = MOCK_LOCK; await expect( - fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - category: 'Application', - docketNumber: caseRecord.docketNumber, - documentTitle: 'Application for Waiver of Filing Fee', - documentType: 'Application for Waiver of Filing Fee', - eventCode: 'APPW', - filedBy: 'Test Petitioner', - primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + category: 'Application', + docketNumber: caseRecord.docketNumber, + documentTitle: 'Application for Waiver of Filing Fee', + documentType: 'Application for Waiver of Filing Fee', + eventCode: 'APPW', + filedBy: 'Test Petitioner', + primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, }, - }), + mockIrsPractitionerUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -597,17 +629,21 @@ describe('fileExternalDocumentInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await fileExternalDocumentInteractor(applicationContext, { - documentMetadata: { - category: 'Application', - docketNumber: caseRecord.docketNumber, - documentTitle: 'Application for Waiver of Filing Fee', - documentType: 'Application for Waiver of Filing Fee', - eventCode: 'APPW', - filedBy: 'Test Petitioner', - primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + await fileExternalDocumentInteractor( + applicationContext, + { + documentMetadata: { + category: 'Application', + docketNumber: caseRecord.docketNumber, + documentTitle: 'Application for Waiver of Filing Fee', + documentType: 'Application for Waiver of Filing Fee', + eventCode: 'APPW', + filedBy: 'Test Petitioner', + primaryDocumentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, }, - }); + mockIrsPractitionerUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts index 70224b11122..ac5f7a174e3 100644 --- a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts +++ b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts @@ -11,6 +11,7 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '@shared/business/entities/WorkItem'; import { aggregatePartiesForService } from '@shared/business/utilities/aggregatePartiesForService'; import { pick } from 'lodash'; @@ -26,9 +27,8 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const fileExternalDocument = async ( applicationContext: ServerApplicationContext, { documentMetadata }: { documentMetadata: any }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.FILE_EXTERNAL_DOCUMENT)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/documents/fileExternalDocumentToCaseLambda.ts b/web-api/src/lambdas/documents/fileExternalDocumentToCaseLambda.ts index c4e5a88efb9..c72e251fab1 100644 --- a/web-api/src/lambdas/documents/fileExternalDocumentToCaseLambda.ts +++ b/web-api/src/lambdas/documents/fileExternalDocumentToCaseLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +7,16 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const fileExternalDocumentToCaseLambda = event => +export const fileExternalDocumentToCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() .fileExternalDocumentInteractor( applicationContext, JSON.parse(event.body), + authorizedUser, ); }); From 4598db61fa4b5c03126dd70bd9988459e913f65b Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Fri, 19 Jul 2024 18:47:25 -0400 Subject: [PATCH 304/523] 10417 rm log statements add param to docstring --- .../useCases/trialSessions/getTrialSessionsInteractor.ts | 1 - web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts index 181bad45c29..854d6a181f6 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts @@ -13,7 +13,6 @@ export const getTrialSessionsInteractor = async ( authorizedUser: UnknownAuthUser, ): Promise => { if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { - console.debug('Unauthorized'); throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts b/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts index b06bddea703..5c34971e717 100644 --- a/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts +++ b/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts @@ -5,6 +5,7 @@ import { genericHandler } from '../../genericHandler'; * gets all trial sessions * * @param {object} event the AWS event object + * @param {object} authorizedUser the user object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getTrialSessionsLambda = ( From cd69c7aab50d9e9b31bd02c13461c512f6dd5c6b Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Fri, 19 Jul 2024 18:57:09 -0400 Subject: [PATCH 305/523] 10417 rm getCurrentUser from generateNoticesForCaseTrialSessionInteractor fix tests and affected code --- .../business/entities/authUser/AuthUser.ts | 11 +++++++++ ...CaseTrialSessionCalendarInteractor.test.ts | 24 +++++++++++++++++++ ...esForCaseTrialSessionCalendarInteractor.ts | 17 +++++++++---- .../lambdas/trial-session/trial-session.ts | 14 ++++++++--- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/shared/src/business/entities/authUser/AuthUser.ts b/shared/src/business/entities/authUser/AuthUser.ts index a03007a774e..31011ea26b0 100644 --- a/shared/src/business/entities/authUser/AuthUser.ts +++ b/shared/src/business/entities/authUser/AuthUser.ts @@ -8,6 +8,17 @@ export type AuthUser = { name: string; }; +export class UserUndefinedError extends Error { + constructor(message: string) { + super(message); + this.name = 'UserUndefinedError'; + // Maintains proper stack trace for where our error was thrown (only available on V8) + if (Error.captureStackTrace) { + Error.captureStackTrace(this, UserUndefinedError); + } + } +} + export type UnknownAuthUser = AuthUser | undefined; export function isAuthUser(user): user is AuthUser { diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.test.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.test.ts index 3ef64845009..23fdbf03585 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.test.ts @@ -86,6 +86,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { }); await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); expect( @@ -96,6 +97,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should set the job status to processing the first time the job executes', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); expect( @@ -107,6 +109,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should decrement the job counter when a worker has processed a pdf file', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); expect( @@ -117,6 +120,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should save a copy of the combined notice of trial issued letter and a clinic letter for pro se petitioners', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); @@ -142,6 +146,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); @@ -165,6 +170,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { }); await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); @@ -207,6 +213,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); @@ -242,6 +249,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); expect( @@ -264,6 +272,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); expect( @@ -278,6 +287,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should send out notifications emails for the notice docket entry AND standing pretrial notice', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); expect( @@ -306,6 +316,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should NOT save pdf copies of notices, standing pretrial and the address page for electronic parties', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); @@ -335,6 +346,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); @@ -361,6 +373,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); @@ -379,6 +392,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); @@ -397,6 +411,7 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should set the presiding judge on the generated SPTO and persist it to the case', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + docketClerkUser, interactorParamObject, ); @@ -412,4 +427,13 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { signedJudgeName: undefined, }); }); + it('should throw an error if the user is not defined', async () => { + await expect( + generateNoticesForCaseTrialSessionCalendarInteractor( + applicationContext, + undefined, + interactorParamObject, + ), + ).rejects.toThrow('User was not defined.'); + }); }); diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index 4edb4e2fefe..7f3c50d60b2 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -9,6 +9,10 @@ import { TrialSession, } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { + UnknownAuthUser, + UserUndefinedError, +} from '@shared/business/entities/authUser/AuthUser'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; import { copyPagesAndAppendToTargetPdf } from '../../../../../shared/src/business/utilities/copyPagesAndAppendToTargetPdf'; import { shouldAppendClinicLetter } from '../../../../../shared/src/business/utilities/shouldAppendClinicLetter'; @@ -199,7 +203,7 @@ const setNoticeForCase = async ({ signedAt: applicationContext.getUtilities().createISODateString(), // The signature is in the template of the document being generated trialLocation: trialSessionEntity.trialLocation, }, - { authorizedUser: applicationContext.getCurrentUser() }, + { authorizedUser: user }, ); noticeOfTrialDocketEntry.setFiledBy(user); @@ -325,18 +329,21 @@ const setNoticeForCase = async ({ export const generateNoticesForCaseTrialSessionCalendarInteractor = async ( applicationContext: ServerApplicationContext, + authorizedUser: UnknownAuthUser, { docketNumber, jobId, trialSession, - userId, }: { docketNumber: string; jobId: string; trialSession: RawTrialSession; - userId: string; }, ) => { + if (!authorizedUser) { + throw new UserUndefinedError('User was not defined.'); + } + const jobStatus = await applicationContext .getPersistenceGateway() .getTrialSessionJobStatusForCase({ @@ -353,7 +360,7 @@ export const generateNoticesForCaseTrialSessionCalendarInteractor = async ( const user = await applicationContext.getPersistenceGateway().getUserById({ applicationContext, - userId, + userId: authorizedUser.userId, }); await applicationContext @@ -403,6 +410,6 @@ export const generateNoticesForCaseTrialSessionCalendarInteractor = async ( message: { action: 'notice_generation_updated', }, - userId, + userId: authorizedUser.userId, }); }; diff --git a/web-api/src/lambdas/trial-session/trial-session.ts b/web-api/src/lambdas/trial-session/trial-session.ts index 68f09983849..28e24f51940 100644 --- a/web-api/src/lambdas/trial-session/trial-session.ts +++ b/web-api/src/lambdas/trial-session/trial-session.ts @@ -1,12 +1,20 @@ import { DeleteMessageCommand, SQSClient } from '@aws-sdk/client-sqs'; +import { + UnknownAuthUser, + UserUndefinedError, +} from '@shared/business/entities/authUser/AuthUser'; import { createApplicationContext } from '../../applicationContext'; -export const handler = async event => { +export const handler = async (event, authorizedUser: UnknownAuthUser) => { const applicationContext = createApplicationContext({}); + if (!authorizedUser) { + throw new UserUndefinedError('User was not defined.'); + } + try { const { Records } = event; const { body, receiptHandle } = Records[0]; - const { docketNumber, jobId, trialSession, userId } = JSON.parse(body); + const { docketNumber, jobId, trialSession } = JSON.parse(body); applicationContext.logger.info( `received an event to generate notices for trial session ${trialSession.trialSessionId} on case ${docketNumber} for job ${jobId}`, @@ -17,11 +25,11 @@ export const handler = async event => { .getUseCases() .generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, + authorizedUser, { docketNumber, jobId, trialSession, - userId, }, ); From 2cd073001d094c494c2fc02b2545144e31e66231 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Fri, 19 Jul 2024 19:31:10 -0400 Subject: [PATCH 306/523] 10417 rm getCurrentUser from dismissNOTReminderForTrial code and tests --- ...missNOTTReminderForTrialInteractor.test.ts | 20 +++++++++++++------ .../dismissNOTTReminderForTrialInteractor.ts | 2 ++ .../dismissNOTTReminderForTrialLambda.ts | 16 +++++++++++---- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.test.ts b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.test.ts index 8b2047e3466..0bec7ed27d9 100644 --- a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.test.ts @@ -19,16 +19,24 @@ describe('dismissNOTTReminderForTrialInteractor', () => { applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); await expect( - dismissNOTTReminderForTrialInteractor(applicationContext, { - trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId!, - }), + dismissNOTTReminderForTrialInteractor( + applicationContext, + docketClerkUser, + { + trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId!, + }, + ), ).rejects.toThrow('Unauthorized to dismiss NOTT reminder'); }); it('should update the trial session with a flag indicating that the NOTT filing reminder has been dismissed', async () => { - await dismissNOTTReminderForTrialInteractor(applicationContext, { - trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId!, - }); + await dismissNOTTReminderForTrialInteractor( + applicationContext, + docketClerkUser, + { + trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId!, + }, + ); expect( applicationContext.getPersistenceGateway().updateTrialSession.mock diff --git a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts index c37f4b349bf..176f9a2acca 100644 --- a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts @@ -6,6 +6,7 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '../../../../../shared/src/business/entities/authUser/AuthUser'; /** * dismissNOTTReminderForTrialInteractor @@ -15,6 +16,7 @@ import { UnauthorizedError } from '@web-api/errors/errors'; */ export const dismissNOTTReminderForTrialInteractor = async ( applicationContext: ServerApplicationContext, + authorizedUser: UnknownAuthUser, { trialSessionId }: { trialSessionId: string }, ): Promise => { const user = applicationContext.getCurrentUser(); diff --git a/web-api/src/lambdas/trialSessions/dismissNOTTReminderForTrialLambda.ts b/web-api/src/lambdas/trialSessions/dismissNOTTReminderForTrialLambda.ts index 78b5a516c83..8f91fec2225 100644 --- a/web-api/src/lambdas/trialSessions/dismissNOTTReminderForTrialLambda.ts +++ b/web-api/src/lambdas/trialSessions/dismissNOTTReminderForTrialLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -5,11 +6,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const dismissNOTTReminderForTrialLambda = event => +export const dismissNOTTReminderForTrialLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .dismissNOTTReminderForTrialInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .dismissNOTTReminderForTrialInteractor( + applicationContext, + authorizedUser, + { + ...JSON.parse(event.body), + }, + ); }); From daff56323efa3f1099e2a9481302995a36c05539 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 09:44:40 -0500 Subject: [PATCH 307/523] 10417 remove getCurrentUser from deleteTrialSessionInteractor --- .../deleteTrialSessionInteractor.test.ts | 102 ++++++++++++------ .../deleteTrialSessionInteractor.ts | 9 +- .../dismissNOTTReminderForTrialInteractor.ts | 2 +- ...esForCaseTrialSessionCalendarInteractor.ts | 2 +- .../lambdas/trial-session/trial-session.ts | 2 +- .../trialSessions/deleteTrialSessionLambda.ts | 16 ++- 6 files changed, 86 insertions(+), 47 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.ts index 95b09d8b13a..7b6d55aeaf9 100644 --- a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.ts @@ -3,9 +3,12 @@ import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { MOCK_TRIAL_REGULAR } from '../../../../../shared/src/test/mockTrial'; import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { deleteTrialSessionInteractor } from './deleteTrialSessionInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('deleteTrialSessionInteractor', () => { let mockTrialSession; @@ -25,13 +28,6 @@ describe('deleteTrialSessionInteractor', () => { mockTrialSession = MOCK_TRIAL_REGULAR; applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), - ); }); it('throws error if user is unauthorized', async () => { @@ -41,9 +37,13 @@ describe('deleteTrialSessionInteractor', () => { }); await expect( - deleteTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + deleteTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -51,9 +51,13 @@ describe('deleteTrialSessionInteractor', () => { mockTrialSession = null; await expect( - deleteTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + deleteTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow( 'Trial session c54ba5a9-b37b-479d-9201-067ec6e335bb was not found.', ); @@ -65,9 +69,13 @@ describe('deleteTrialSessionInteractor', () => { }; await expect( - deleteTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + deleteTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Trial session cannot be updated after its start date'); }); @@ -79,9 +87,13 @@ describe('deleteTrialSessionInteractor', () => { }; await expect( - deleteTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + deleteTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Trial session cannot be deleted after it is calendared'); }); @@ -95,9 +107,13 @@ describe('deleteTrialSessionInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); - await deleteTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await deleteTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteTrialSessionWorkingCopy, @@ -125,9 +141,13 @@ describe('deleteTrialSessionInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); - await deleteTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await deleteTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteTrialSessionWorkingCopy, @@ -147,9 +167,13 @@ describe('deleteTrialSessionInteractor', () => { preferredTrialCity: null, }); - await deleteTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await deleteTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway() @@ -170,9 +194,13 @@ describe('deleteTrialSessionInteractor', () => { mockLock = MOCK_LOCK; await expect( - deleteTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + deleteTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -190,9 +218,13 @@ describe('deleteTrialSessionInteractor', () => { .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); - await deleteTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + await deleteTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, ).toHaveBeenCalledTimes(mockTrialSession.caseOrder.length); diff --git a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts index 74c57ab2481..e40c8dfb972 100644 --- a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts @@ -6,6 +6,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { acquireLock } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -18,10 +19,9 @@ import { acquireLock } from '@web-api/business/useCaseHelper/acquireLock'; export const deleteTrialSessionInteractor = async ( applicationContext: ServerApplicationContext, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } @@ -56,6 +56,7 @@ export const deleteTrialSessionInteractor = async ( await acquireLock({ applicationContext, + authorizedUser, identifiers: docketNumbers?.map(item => `case|${item}`), }); @@ -67,7 +68,7 @@ export const deleteTrialSessionInteractor = async ( docketNumber: order.docketNumber, }); - const caseEntity = new Case(myCase, { authorizedUser: user }); + const caseEntity = new Case(myCase, { authorizedUser }); caseEntity.removeFromTrial({}); diff --git a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts index 176f9a2acca..1fb2ec9f8a2 100644 --- a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts @@ -19,7 +19,7 @@ export const dismissNOTTReminderForTrialInteractor = async ( authorizedUser: UnknownAuthUser, { trialSessionId }: { trialSessionId: string }, ): Promise => { - const user = applicationContext.getCurrentUser(); + const user = applicationContext.getCurrentUser(); // TODO 10417 remove this if (!isAuthorized(user, ROLE_PERMISSIONS.DISMISS_NOTT_REMINDER)) { throw new UnauthorizedError('Unauthorized to dismiss NOTT reminder'); diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index 7f3c50d60b2..3a7b8c7fec4 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -329,7 +329,7 @@ const setNoticeForCase = async ({ export const generateNoticesForCaseTrialSessionCalendarInteractor = async ( applicationContext: ServerApplicationContext, - authorizedUser: UnknownAuthUser, + authorizedUser: UnknownAuthUser, // TODO 10417: did we need this change or should we stick with the passed-in userId coming from the event that triggers this? { docketNumber, jobId, diff --git a/web-api/src/lambdas/trial-session/trial-session.ts b/web-api/src/lambdas/trial-session/trial-session.ts index 28e24f51940..3cc65e5c803 100644 --- a/web-api/src/lambdas/trial-session/trial-session.ts +++ b/web-api/src/lambdas/trial-session/trial-session.ts @@ -14,7 +14,7 @@ export const handler = async (event, authorizedUser: UnknownAuthUser) => { try { const { Records } = event; const { body, receiptHandle } = Records[0]; - const { docketNumber, jobId, trialSession } = JSON.parse(body); + const { docketNumber, jobId, trialSession } = JSON.parse(body); // TODO 10417 should we be changing something coming in from an event external to this lambda? applicationContext.logger.info( `received an event to generate notices for trial session ${trialSession.trialSessionId} on case ${docketNumber} for job ${jobId}`, diff --git a/web-api/src/lambdas/trialSessions/deleteTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/deleteTrialSessionLambda.ts index c44b11ee602..af67e0a4caa 100644 --- a/web-api/src/lambdas/trialSessions/deleteTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/deleteTrialSessionLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const deleteTrialSessionLambda = event => +export const deleteTrialSessionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .deleteTrialSessionInteractor(applicationContext, { + return await applicationContext.getUseCases().deleteTrialSessionInteractor( + applicationContext, + { trialSessionId, - }); + }, + authorizedUser, + ); }); From 5deb4a68ce0e15a537806b8afe75cfa50bee182b Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 09:50:11 -0500 Subject: [PATCH 308/523] 10417 remove getCurrentUser from createTrialSessionInteractor --- .../createTrialSessionInteractor.test.ts | 129 ++++++++++-------- .../createTrialSessionInteractor.ts | 8 +- .../trialSessions/createTrialSessionLambda.ts | 16 ++- 3 files changed, 87 insertions(+), 66 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.test.ts index dec590dd09a..610c0a33d67 100644 --- a/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.test.ts @@ -1,11 +1,8 @@ -import { - ROLES, - TRIAL_SESSION_SCOPE_TYPES, -} from '../../../../../shared/src/business/entities/EntityConstants'; import { RawTrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; -import { User } from '../../../../../shared/src/business/entities/User'; +import { TRIAL_SESSION_SCOPE_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createTrialSessionInteractor } from './createTrialSessionInteractor'; +import { mockDocketClerkUser, mockJudgeUser } from '@shared/test/mockAuthUsers'; const MOCK_TRIAL = { maxCases: 100, @@ -17,17 +14,8 @@ const MOCK_TRIAL = { }; describe('createTrialSessionInteractor', () => { - let user; - beforeEach(() => { - user = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext .getUseCaseHelpers() @@ -37,15 +25,14 @@ describe('createTrialSessionInteractor', () => { }); it('should throw an error when user is unauthorized', async () => { - user = new User({ - role: ROLES.judge, - userId: 'judge', - }); - await expect( - createTrialSessionInteractor(applicationContext, { - trialSession: MOCK_TRIAL as RawTrialSession, - }), + createTrialSessionInteractor( + applicationContext, + { + trialSession: MOCK_TRIAL as RawTrialSession, + }, + mockJudgeUser, + ), ).rejects.toThrow(); }); @@ -57,16 +44,24 @@ describe('createTrialSessionInteractor', () => { }); await expect( - createTrialSessionInteractor(applicationContext, { - trialSession: MOCK_TRIAL as RawTrialSession, - }), + createTrialSessionInteractor( + applicationContext, + { + trialSession: MOCK_TRIAL as RawTrialSession, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(''); }); it('should successfully create a trial session', async () => { - await createTrialSessionInteractor(applicationContext, { - trialSession: MOCK_TRIAL as RawTrialSession, - }); + await createTrialSessionInteractor( + applicationContext, + { + trialSession: MOCK_TRIAL as RawTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().createTrialSessionAndWorkingCopy, @@ -74,47 +69,63 @@ describe('createTrialSessionInteractor', () => { }); it('should set the trial session as calendared when it is a Motion/Hearing session type', async () => { - const result = await createTrialSessionInteractor(applicationContext, { - trialSession: { - ...MOCK_TRIAL, - sessionType: 'Motion/Hearing', - } as RawTrialSession, - }); + const result = await createTrialSessionInteractor( + applicationContext, + { + trialSession: { + ...MOCK_TRIAL, + sessionType: 'Motion/Hearing', + } as RawTrialSession, + }, + mockDocketClerkUser, + ); expect(result.isCalendared).toEqual(true); }); it(`should set the trial session as calendared when the sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote}`, async () => { - const result = await createTrialSessionInteractor(applicationContext, { - trialSession: { - ...MOCK_TRIAL, - sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, - sessionType: 'Something Else', - } as RawTrialSession, - }); + const result = await createTrialSessionInteractor( + applicationContext, + { + trialSession: { + ...MOCK_TRIAL, + sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, + sessionType: 'Something Else', + } as RawTrialSession, + }, + mockDocketClerkUser, + ); expect(result.isCalendared).toEqual(true); }); it('should set the trial session as calendared when it is a Special session type', async () => { - const result = await createTrialSessionInteractor(applicationContext, { - trialSession: { - ...MOCK_TRIAL, - sessionType: 'Special', - } as RawTrialSession, - }); + const result = await createTrialSessionInteractor( + applicationContext, + { + trialSession: { + ...MOCK_TRIAL, + sessionType: 'Special', + } as RawTrialSession, + }, + mockDocketClerkUser, + ); expect(result.isCalendared).toEqual(true); }); it('should associate swing trial sessions when the current trial session has a swing session', async () => { - await createTrialSessionInteractor(applicationContext, { - trialSession: { - ...MOCK_TRIAL, - swingSession: true, - swingSessionId: '1234', - } as RawTrialSession, - }); + await createTrialSessionInteractor( + applicationContext, + { + trialSession: { + ...MOCK_TRIAL, + swingSession: true, + swingSessionId: '1234', + } as RawTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().associateSwingTrialSessions, @@ -126,9 +137,13 @@ describe('createTrialSessionInteractor', () => { }); it('shoud not set the trial session as calendared when it is a Regular session type', async () => { - const result = await createTrialSessionInteractor(applicationContext, { - trialSession: MOCK_TRIAL as RawTrialSession, - }); + const result = await createTrialSessionInteractor( + applicationContext, + { + trialSession: MOCK_TRIAL as RawTrialSession, + }, + mockDocketClerkUser, + ); expect(result.isCalendared).toEqual(false); }); diff --git a/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts index a642167ef7c..3f41171500c 100644 --- a/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/createTrialSessionInteractor.ts @@ -8,14 +8,14 @@ import { } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const createTrialSessionInteractor = async ( applicationContext: ServerApplicationContext, { trialSession }: { trialSession: RawTrialSession }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.CREATE_TRIAL_SESSION)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CREATE_TRIAL_SESSION)) { throw new UnauthorizedError('Unauthorized'); } @@ -35,7 +35,7 @@ export const createTrialSessionInteractor = async ( swingSessionId: trialSessionToAdd.swingSessionId, trialSessionEntity: trialSessionToAdd, }, - user, + authorizedUser, ); } diff --git a/web-api/src/lambdas/trialSessions/createTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/createTrialSessionLambda.ts index c19b1b75307..07b36fc2520 100644 --- a/web-api/src/lambdas/trialSessions/createTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/createTrialSessionLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +7,16 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const createTrialSessionLambda = event => +export const createTrialSessionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createTrialSessionInteractor(applicationContext, { + return await applicationContext.getUseCases().createTrialSessionInteractor( + applicationContext, + { trialSession: JSON.parse(event.body), - }); + }, + authorizedUser, + ); }); From 239b1027c18aa29690d04dbb3fdb39349610e994 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 10:17:30 -0500 Subject: [PATCH 309/523] 10417 remove getCurrentUser from closeTrialSessionInteractor --- .../closeTrialSessionInteractor.test.ts | 135 ++++++++---------- .../closeTrialSessionInteractor.ts | 5 +- .../trialSessions/closeTrialSessionLambda.ts | 16 ++- 3 files changed, 74 insertions(+), 82 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.test.ts index 2f1988f6005..18ee1b5517f 100644 --- a/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.test.ts @@ -1,16 +1,17 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_TRIAL_REGULAR } from '../../../../../shared/src/test/mockTrial'; import { - ROLES, TRIAL_SESSION_PROCEEDING_TYPES, TRIAL_SESSION_SCOPE_TYPES, } from '../../../../../shared/src/business/entities/EntityConstants'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { closeTrialSessionInteractor } from './closeTrialSessionInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('closeTrialSessionInteractor', () => { - let user; let mockTrialSession; const FUTURE_DATE = '2090-11-25T15:00:00.000Z'; @@ -20,7 +21,6 @@ describe('closeTrialSessionInteractor', () => { mockTrialSession = MOCK_TRIAL_REGULAR; applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext .getPersistenceGateway() @@ -28,43 +28,34 @@ describe('closeTrialSessionInteractor', () => { }); it('throws error if user is unauthorized', async () => { - user = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( - closeTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + closeTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('throws an exception when it fails to find a trial session', async () => { - user = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - mockTrialSession = null; await expect( - closeTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + closeTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow( 'Trial session c54ba5a9-b37b-479d-9201-067ec6e335bb was not found.', ); }); it('throws error when trial session is not standalone remote', async () => { - user = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - mockTrialSession = { ...MOCK_TRIAL_REGULAR, sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, @@ -72,21 +63,19 @@ describe('closeTrialSessionInteractor', () => { }; await expect( - closeTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + closeTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow( 'Only standalone remote trial sessions can be closed manually', ); }); it('throws error when trial session start date is in the future', async () => { - user = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - mockTrialSession = { ...MOCK_TRIAL_REGULAR, sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, @@ -94,21 +83,19 @@ describe('closeTrialSessionInteractor', () => { }; await expect( - closeTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + closeTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow( 'Trial session cannot be closed until after its start date', ); }); it('throws an error when there are active cases on the trial session', async () => { - user = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - mockTrialSession = { ...MOCK_TRIAL_REGULAR, caseOrder: [ @@ -119,19 +106,17 @@ describe('closeTrialSessionInteractor', () => { }; await expect( - closeTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + closeTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Trial session cannot be closed with open cases'); }); it('does not throw an error when there are no cases on the trial session', async () => { - user = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - mockTrialSession = { ...MOCK_TRIAL_REGULAR, caseOrder: undefined, @@ -140,19 +125,17 @@ describe('closeTrialSessionInteractor', () => { }; await expect( - closeTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + closeTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.not.toThrow('Trial session cannot be closed with open cases'); }); it('should not close the trial session and throws an error instead', async () => { - user = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - mockTrialSession = { ...MOCK_TRIAL_REGULAR, caseOrder: [ @@ -164,19 +147,17 @@ describe('closeTrialSessionInteractor', () => { }; await expect( - closeTrialSessionInteractor(applicationContext, { - trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), + closeTrialSessionInteractor( + applicationContext, + { + trialSessionId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Trial session cannot be closed with open cases'); }); it('closes the trial session and invokes expected persistence methods', async () => { - user = new User({ - name: 'Docket Clerk', - role: ROLES.docketClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - mockTrialSession = { ...MOCK_TRIAL_REGULAR, caseOrder: [ @@ -198,9 +179,13 @@ describe('closeTrialSessionInteractor', () => { startDate: PAST_DATE, }; - await closeTrialSessionInteractor(applicationContext, { - trialSessionId: mockTrialSession.trialSessionId, - }); + await closeTrialSessionInteractor( + applicationContext, + { + trialSessionId: mockTrialSession.trialSessionId, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateTrialSession.mock diff --git a/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.ts index 3acf698be4f..8351ea79c0c 100644 --- a/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/closeTrialSessionInteractor.ts @@ -7,6 +7,7 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; import { TRIAL_SESSION_SCOPE_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { isEmpty, isEqual } from 'lodash'; /** @@ -19,9 +20,9 @@ import { isEmpty, isEqual } from 'lodash'; export const closeTrialSessionInteractor = async ( applicationContext: ServerApplicationContext, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/trialSessions/closeTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/closeTrialSessionLambda.ts index 3d8429854d5..182940644cc 100644 --- a/web-api/src/lambdas/trialSessions/closeTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/closeTrialSessionLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const closeTrialSessionLambda = event => +export const closeTrialSessionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .closeTrialSessionInteractor(applicationContext, { + return await applicationContext.getUseCases().closeTrialSessionInteractor( + applicationContext, + { trialSessionId, - }); + }, + authorizedUser, + ); }); From 214aa68bad9362589126022a3aa8a388731f7255 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 08:59:53 -0700 Subject: [PATCH 310/523] 10417: remove appcontext.getCurrentUser from generateDocketRecordPdfInteractor --- .../generateDocketRecordPdfInteractor.test.ts | 125 ++++++++++++------ .../generateDocketRecordPdfInteractor.ts | 32 ++--- .../cases/generateDocketRecordPdfLambda.ts | 21 +-- 3 files changed, 108 insertions(+), 70 deletions(-) diff --git a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.test.ts b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.test.ts index 85af501b656..2e228f6515c 100644 --- a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.test.ts +++ b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.test.ts @@ -6,13 +6,18 @@ import { } from '../../../../shared/src/business/entities/EntityConstants'; import { MOCK_PRACTITIONER, - docketClerkUser, petitionerUser, - petitionsClerkUser, privatePractitionerUser, } from '../../../../shared/src/test/mockUsers'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { generateDocketRecordPdfInteractor } from './generateDocketRecordPdfInteractor'; +import { + mockDocketClerkUser, + mockPetitionerUser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('generateDocketRecordPdfInteractor', () => { const mockId = '12345'; @@ -57,7 +62,6 @@ describe('generateDocketRecordPdfInteractor', () => { privatePractitioners: [], }; - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(true); @@ -76,10 +80,14 @@ describe('generateDocketRecordPdfInteractor', () => { }); it('Calls docketRecord document generator to build a PDF', async () => { - await generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - includePartyDetail: true, - }); + await generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + includePartyDetail: true, + }, + mockDocketClerkUser, + ); expect( applicationContext.getDocumentGenerators().docketRecord.mock.calls[0][0] @@ -95,10 +103,14 @@ describe('generateDocketRecordPdfInteractor', () => { caseDetail.privatePractitioners = [mockPractitionerOnCase, {}]; - await generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - includePartyDetail: true, - }); + await generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + includePartyDetail: true, + }, + mockDocketClerkUser, + ); expect( applicationContext.getDocumentGenerators().docketRecord.mock.calls[0][0] @@ -118,10 +130,14 @@ describe('generateDocketRecordPdfInteractor', () => { caseDetail.privatePractitioners = [mockPractitionerOnCase, {}]; - await generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - includePartyDetail: true, - }); + await generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + includePartyDetail: true, + }, + mockPractitionerOnCase, + ); expect( applicationContext.getDocumentGenerators().docketRecord.mock.calls[0][0] @@ -132,10 +148,14 @@ describe('generateDocketRecordPdfInteractor', () => { }); it('Returns a file ID and url to the generated file', async () => { - const result = await generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - includePartyDetail: true, - }); + const result = await generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + includePartyDetail: true, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().saveFileAndGenerateUrl, @@ -144,9 +164,13 @@ describe('generateDocketRecordPdfInteractor', () => { }); it('defaults includePartyDetail to false when a value has not been provided', async () => { - await generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - } as any); + await generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getDocumentGenerators().docketRecord.mock.calls[0][0] @@ -155,7 +179,6 @@ describe('generateDocketRecordPdfInteractor', () => { }); it('throws an Unauthorized error for an unassociated user attempting to view a sealed case', async () => { - applicationContext.getCurrentUser.mockReturnValue(privatePractitionerUser); applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(false); @@ -169,14 +192,17 @@ describe('generateDocketRecordPdfInteractor', () => { }); await expect( - generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - } as any), + generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + } as any, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('Unauthorized to view sealed case.'); }); it('throws an Unauthorized error for a public user attempting to view a sealed case', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); //public user applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(false); @@ -188,14 +214,17 @@ describe('generateDocketRecordPdfInteractor', () => { }); await expect( - generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - } as any), + generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + } as any, + {} as UnknownAuthUser, + ), ).rejects.toThrow('Unauthorized to view sealed case.'); }); it('returns a PDF url for an internal user attempting to view a sealed case', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(false); @@ -206,15 +235,18 @@ describe('generateDocketRecordPdfInteractor', () => { sealedDate: '2019-08-25T05:00:00.000Z', }); - const result = await generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - } as any); + const result = await generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + } as any, + mockPetitionsClerkUser, + ); expect(result).toEqual(mockPdfUrlAndID); }); it('returns a PDF url for an external, associated user attempting to view a sealed case', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(true); @@ -225,15 +257,18 @@ describe('generateDocketRecordPdfInteractor', () => { userId: petitionerUser.userId, }); - const result = await generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - } as any); + const result = await generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + } as any, + mockPetitionerUser, + ); expect(result).toEqual(mockPdfUrlAndID); }); it('returns a PDF url for an external, indirectly associated user attempting to view a sealed case', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); applicationContext .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(false); @@ -244,10 +279,14 @@ describe('generateDocketRecordPdfInteractor', () => { userId: petitionerUser.userId, }); - const result = await generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: caseDetail.docketNumber, - isIndirectlyAssociated: true, - } as any); + const result = await generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: caseDetail.docketNumber, + isIndirectlyAssociated: true, + } as any, + mockPetitionerUser, + ); expect(result).toEqual(mockPdfUrlAndID); }); diff --git a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts index a18f2f16a20..c2638e6b603 100644 --- a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts +++ b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts @@ -8,15 +8,9 @@ import { } from '../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { getCaseCaptionMeta } from '../../../../shared/src/business/utilities/getCaseCaptionMeta'; -/** - * generateDocketRecordPdfInteractor - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.docketNumber the docket number for the docket record to be generated - * @returns {Uint8Array} docket record pdf - */ export const generateDocketRecordPdfInteractor = async ( applicationContext: ServerApplicationContext, { @@ -30,14 +24,17 @@ export const generateDocketRecordPdfInteractor = async ( includePartyDetail: boolean; isIndirectlyAssociated?: boolean; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); + if (!authorizedUser) { + throw new UnauthorizedError('Unauthorized to generate docket record.'); + } const isDirectlyAssociated = await applicationContext .getPersistenceGateway() .verifyCaseForUser({ applicationContext, docketNumber, - userId: user.userId, + userId: authorizedUser.userId, }); const caseSource = await applicationContext @@ -54,9 +51,9 @@ export const generateDocketRecordPdfInteractor = async ( .isSealedCase(caseSource); if (isSealedCase) { - if (user.userId) { + if (authorizedUser.userId) { const isAuthorizedToViewSealedCase = isAuthorized( - user, + authorizedUser, ROLE_PERMISSIONS.VIEW_SEALED_CASE, ); @@ -65,7 +62,7 @@ export const generateDocketRecordPdfInteractor = async ( isDirectlyAssociated || isIndirectlyAssociated ) { - caseEntity = new Case(caseSource, { authorizedUser: user }); + caseEntity = new Case(caseSource, { authorizedUser }); } else { // unassociated user viewing sealed case throw new UnauthorizedError('Unauthorized to view sealed case.'); @@ -75,14 +72,14 @@ export const generateDocketRecordPdfInteractor = async ( throw new UnauthorizedError('Unauthorized to view sealed case.'); } } else { - caseEntity = new Case(caseSource, { authorizedUser: user }); + caseEntity = new Case(caseSource, { authorizedUser }); } const formattedCaseDetail = applicationContext .getUtilities() .getFormattedCaseDetail({ applicationContext, - authorizedUser: user, + authorizedUser, caseDetail: caseEntity, docketRecordSort, }); @@ -90,10 +87,9 @@ export const generateDocketRecordPdfInteractor = async ( formattedCaseDetail.petitioners.forEach(petitioner => { petitioner.counselDetails = []; - const practitioners = getPractitionersRepresenting( - formattedCaseDetail, - petitioner.contactId, - ); + const practitioners = + getPractitionersRepresenting(formattedCaseDetail, petitioner.contactId) || + []; if (practitioners.length > 0) { practitioners.forEach(practitioner => { diff --git a/web-api/src/lambdas/cases/generateDocketRecordPdfLambda.ts b/web-api/src/lambdas/cases/generateDocketRecordPdfLambda.ts index 194ce469a38..45df95a2947 100644 --- a/web-api/src/lambdas/cases/generateDocketRecordPdfLambda.ts +++ b/web-api/src/lambdas/cases/generateDocketRecordPdfLambda.ts @@ -1,19 +1,22 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * used for generating a printable PDF of a docket record - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const generateDocketRecordPdfLambda = event => +export const generateDocketRecordPdfLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .generateDocketRecordPdfInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .generateDocketRecordPdfInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); From 927e9094782005a44463096d9f01a75fcda5a27e Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 10:00:03 -0700 Subject: [PATCH 311/523] 10417: remove appcontext.getCurrentUser from getCasesClosedByJudgeInteractor --- .../getCasesClosedByJudgeInteractor.test.ts | 32 +++++++++++-------- .../getCasesClosedByJudgeInteractor.ts | 6 ++-- .../reports/getCasesClosedByJudgeLambda.ts | 21 ++++++------ 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/web-api/src/business/useCases/judgeActivityReport/getCasesClosedByJudgeInteractor.test.ts b/web-api/src/business/useCases/judgeActivityReport/getCasesClosedByJudgeInteractor.test.ts index 1f802aac235..e0ad59c550b 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getCasesClosedByJudgeInteractor.test.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getCasesClosedByJudgeInteractor.test.ts @@ -9,10 +9,11 @@ import { createEndOfDayISO, createStartOfDayISO, } from '../../../../../shared/src/business/utilities/DateHandler'; +import { judgeUser } from '../../../../../shared/src/test/mockUsers'; import { - judgeUser, - petitionsClerkUser, -} from '../../../../../shared/src/test/mockUsers'; + mockJudgeUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; const mockClosedCases = 3; const mockClosedDismissedCases = 2; @@ -50,8 +51,6 @@ describe('getCasesClosedByJudgeInteractor', () => { }; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(judgeUser); - applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(judgeUser); @@ -62,20 +61,26 @@ describe('getCasesClosedByJudgeInteractor', () => { }); it('should return an error when the user is not authorized to generate the report', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - await expect( - getCasesClosedByJudgeInteractor(applicationContext, mockValidRequest), + getCasesClosedByJudgeInteractor( + applicationContext, + mockValidRequest, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should return an error when the search parameters are not valid', async () => { await expect( - getCasesClosedByJudgeInteractor(applicationContext, { - endDate: 'baddabingbaddaboom', - judges: [judgeUser.name], - startDate: 'yabbadabbadoo', - }), + getCasesClosedByJudgeInteractor( + applicationContext, + { + endDate: 'baddabingbaddaboom', + judges: [judgeUser.name], + startDate: 'yabbadabbadoo', + }, + mockJudgeUser, + ), ).rejects.toThrow(); }); @@ -83,6 +88,7 @@ describe('getCasesClosedByJudgeInteractor', () => { const closedCases = await getCasesClosedByJudgeInteractor( applicationContext, mockValidRequest, + mockJudgeUser, ); expect( diff --git a/web-api/src/business/useCases/judgeActivityReport/getCasesClosedByJudgeInteractor.ts b/web-api/src/business/useCases/judgeActivityReport/getCasesClosedByJudgeInteractor.ts index ca4a257ad00..3afd9e013a9 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getCasesClosedByJudgeInteractor.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getCasesClosedByJudgeInteractor.ts @@ -7,6 +7,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export type CasesClosedReturnType = { aggregations: { @@ -19,9 +20,8 @@ export type CasesClosedReturnType = { export const getCasesClosedByJudgeInteractor = async ( applicationContext: ServerApplicationContext, params: JudgeActivityStatisticsRequest, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.JUDGE_ACTIVITY_REPORT)) { throw new UnauthorizedError('Unauthorized'); } @@ -29,7 +29,7 @@ export const getCasesClosedByJudgeInteractor = async ( const searchEntity = new JudgeActivityReportSearch(params); if (!searchEntity.isValid()) { - throw new InvalidRequest(); + throw new InvalidRequest('Invalid search terms'); } return await applicationContext diff --git a/web-api/src/lambdas/reports/getCasesClosedByJudgeLambda.ts b/web-api/src/lambdas/reports/getCasesClosedByJudgeLambda.ts index 23b65351c7d..aeeff0bd5ca 100644 --- a/web-api/src/lambdas/reports/getCasesClosedByJudgeLambda.ts +++ b/web-api/src/lambdas/reports/getCasesClosedByJudgeLambda.ts @@ -1,19 +1,22 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * retrieves closed cases associated with the specified judge - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const getCasesClosedByJudgeLambda = event => +export const getCasesClosedByJudgeLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getCasesClosedByJudgeInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .getCasesClosedByJudgeInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); From 879dd38fd82eb0f290f1623e39ab17de9ba78d68 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 10:06:50 -0700 Subject: [PATCH 312/523] cd69c7aab50d9e9b31bd02c13461c512f6dd5c6b --- .../business/entities/authUser/AuthUser.ts | 11 --------- ...CaseTrialSessionCalendarInteractor.test.ts | 24 ------------------- ...esForCaseTrialSessionCalendarInteractor.ts | 17 ++++--------- .../lambdas/trial-session/trial-session.ts | 14 +++-------- 4 files changed, 8 insertions(+), 58 deletions(-) diff --git a/shared/src/business/entities/authUser/AuthUser.ts b/shared/src/business/entities/authUser/AuthUser.ts index 31011ea26b0..a03007a774e 100644 --- a/shared/src/business/entities/authUser/AuthUser.ts +++ b/shared/src/business/entities/authUser/AuthUser.ts @@ -8,17 +8,6 @@ export type AuthUser = { name: string; }; -export class UserUndefinedError extends Error { - constructor(message: string) { - super(message); - this.name = 'UserUndefinedError'; - // Maintains proper stack trace for where our error was thrown (only available on V8) - if (Error.captureStackTrace) { - Error.captureStackTrace(this, UserUndefinedError); - } - } -} - export type UnknownAuthUser = AuthUser | undefined; export function isAuthUser(user): user is AuthUser { diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.test.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.test.ts index 23fdbf03585..3ef64845009 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.test.ts @@ -86,7 +86,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { }); await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); expect( @@ -97,7 +96,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should set the job status to processing the first time the job executes', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); expect( @@ -109,7 +107,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should decrement the job counter when a worker has processed a pdf file', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); expect( @@ -120,7 +117,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should save a copy of the combined notice of trial issued letter and a clinic letter for pro se petitioners', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); @@ -146,7 +142,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); @@ -170,7 +165,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { }); await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); @@ -213,7 +207,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); @@ -249,7 +242,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); expect( @@ -272,7 +264,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); expect( @@ -287,7 +278,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should send out notifications emails for the notice docket entry AND standing pretrial notice', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); expect( @@ -316,7 +306,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should NOT save pdf copies of notices, standing pretrial and the address page for electronic parties', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); @@ -346,7 +335,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); @@ -373,7 +361,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); @@ -392,7 +379,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); @@ -411,7 +397,6 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { it('should set the presiding judge on the generated SPTO and persist it to the case', async () => { await generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - docketClerkUser, interactorParamObject, ); @@ -427,13 +412,4 @@ describe('generateNoticesForCaseTrialSessionCalendarInteractor', () => { signedJudgeName: undefined, }); }); - it('should throw an error if the user is not defined', async () => { - await expect( - generateNoticesForCaseTrialSessionCalendarInteractor( - applicationContext, - undefined, - interactorParamObject, - ), - ).rejects.toThrow('User was not defined.'); - }); }); diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index 3a7b8c7fec4..4edb4e2fefe 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -9,10 +9,6 @@ import { TrialSession, } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { ServerApplicationContext } from '@web-api/applicationContext'; -import { - UnknownAuthUser, - UserUndefinedError, -} from '@shared/business/entities/authUser/AuthUser'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; import { copyPagesAndAppendToTargetPdf } from '../../../../../shared/src/business/utilities/copyPagesAndAppendToTargetPdf'; import { shouldAppendClinicLetter } from '../../../../../shared/src/business/utilities/shouldAppendClinicLetter'; @@ -203,7 +199,7 @@ const setNoticeForCase = async ({ signedAt: applicationContext.getUtilities().createISODateString(), // The signature is in the template of the document being generated trialLocation: trialSessionEntity.trialLocation, }, - { authorizedUser: user }, + { authorizedUser: applicationContext.getCurrentUser() }, ); noticeOfTrialDocketEntry.setFiledBy(user); @@ -329,21 +325,18 @@ const setNoticeForCase = async ({ export const generateNoticesForCaseTrialSessionCalendarInteractor = async ( applicationContext: ServerApplicationContext, - authorizedUser: UnknownAuthUser, // TODO 10417: did we need this change or should we stick with the passed-in userId coming from the event that triggers this? { docketNumber, jobId, trialSession, + userId, }: { docketNumber: string; jobId: string; trialSession: RawTrialSession; + userId: string; }, ) => { - if (!authorizedUser) { - throw new UserUndefinedError('User was not defined.'); - } - const jobStatus = await applicationContext .getPersistenceGateway() .getTrialSessionJobStatusForCase({ @@ -360,7 +353,7 @@ export const generateNoticesForCaseTrialSessionCalendarInteractor = async ( const user = await applicationContext.getPersistenceGateway().getUserById({ applicationContext, - userId: authorizedUser.userId, + userId, }); await applicationContext @@ -410,6 +403,6 @@ export const generateNoticesForCaseTrialSessionCalendarInteractor = async ( message: { action: 'notice_generation_updated', }, - userId: authorizedUser.userId, + userId, }); }; diff --git a/web-api/src/lambdas/trial-session/trial-session.ts b/web-api/src/lambdas/trial-session/trial-session.ts index 3cc65e5c803..68f09983849 100644 --- a/web-api/src/lambdas/trial-session/trial-session.ts +++ b/web-api/src/lambdas/trial-session/trial-session.ts @@ -1,20 +1,12 @@ import { DeleteMessageCommand, SQSClient } from '@aws-sdk/client-sqs'; -import { - UnknownAuthUser, - UserUndefinedError, -} from '@shared/business/entities/authUser/AuthUser'; import { createApplicationContext } from '../../applicationContext'; -export const handler = async (event, authorizedUser: UnknownAuthUser) => { +export const handler = async event => { const applicationContext = createApplicationContext({}); - if (!authorizedUser) { - throw new UserUndefinedError('User was not defined.'); - } - try { const { Records } = event; const { body, receiptHandle } = Records[0]; - const { docketNumber, jobId, trialSession } = JSON.parse(body); // TODO 10417 should we be changing something coming in from an event external to this lambda? + const { docketNumber, jobId, trialSession, userId } = JSON.parse(body); applicationContext.logger.info( `received an event to generate notices for trial session ${trialSession.trialSessionId} on case ${docketNumber} for job ${jobId}`, @@ -25,11 +17,11 @@ export const handler = async (event, authorizedUser: UnknownAuthUser) => { .getUseCases() .generateNoticesForCaseTrialSessionCalendarInteractor( applicationContext, - authorizedUser, { docketNumber, jobId, trialSession, + userId, }, ); From a7cea82b7f871afa0a72d959343139b320162455 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 10:28:07 -0700 Subject: [PATCH 313/523] 10417 remove getCurrentUser from generateNoticesForCaseTrialSessionCalendarInteractor --- .../generateNoticesForCaseTrialSessionCalendarInteractor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index 4edb4e2fefe..7aff933867f 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -128,7 +128,7 @@ const setNoticeForCase = async ({ trialSessionEntity, user, }) => { - const caseEntity = new Case(caseRecord, { authorizedUser: user }); + const caseEntity = new Case(caseRecord, { authorizedUser: undefined }); const { procedureType } = caseRecord; let noticeOfTrialIssued = await applicationContext @@ -199,7 +199,7 @@ const setNoticeForCase = async ({ signedAt: applicationContext.getUtilities().createISODateString(), // The signature is in the template of the document being generated trialLocation: trialSessionEntity.trialLocation, }, - { authorizedUser: applicationContext.getCurrentUser() }, + { authorizedUser: undefined }, ); noticeOfTrialDocketEntry.setFiledBy(user); From 9aee4cda5ec9036d46ffc10a56a712e8f7c60cc9 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 10:32:58 -0700 Subject: [PATCH 314/523] 10417 remove getCurrentUser --- ...ismissNOTTReminderForTrialInteractor.test.ts | 14 +++++--------- .../dismissNOTTReminderForTrialInteractor.ts | 6 ++---- .../dismissNOTTReminderForTrialLambda.ts | 17 ++++++++--------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.test.ts b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.test.ts index 0bec7ed27d9..45c1dd4367f 100644 --- a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.test.ts @@ -2,29 +2,25 @@ import { MOCK_TRIAL_REGULAR } from '../../../../../shared/src/test/mockTrial'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { dismissNOTTReminderForTrialInteractor } from './dismissNOTTReminderForTrialInteractor'; import { - docketClerkUser, - petitionsClerkUser, -} from '../../../../../shared/src/test/mockUsers'; + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('dismissNOTTReminderForTrialInteractor', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - applicationContext .getPersistenceGateway() .getTrialSessionById.mockReturnValue(MOCK_TRIAL_REGULAR); }); it('should throw an error when the user is unauthorized to dismiss NOTT alerts', async () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - await expect( dismissNOTTReminderForTrialInteractor( applicationContext, - docketClerkUser, { trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId!, }, + mockDocketClerkUser, ), ).rejects.toThrow('Unauthorized to dismiss NOTT reminder'); }); @@ -32,10 +28,10 @@ describe('dismissNOTTReminderForTrialInteractor', () => { it('should update the trial session with a flag indicating that the NOTT filing reminder has been dismissed', async () => { await dismissNOTTReminderForTrialInteractor( applicationContext, - docketClerkUser, { trialSessionId: MOCK_TRIAL_REGULAR.trialSessionId!, }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts index 1fb2ec9f8a2..6c6672042f0 100644 --- a/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor.ts @@ -16,12 +16,10 @@ import { UnknownAuthUser } from '../../../../../shared/src/business/entities/aut */ export const dismissNOTTReminderForTrialInteractor = async ( applicationContext: ServerApplicationContext, - authorizedUser: UnknownAuthUser, { trialSessionId }: { trialSessionId: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); // TODO 10417 remove this - - if (!isAuthorized(user, ROLE_PERMISSIONS.DISMISS_NOTT_REMINDER)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.DISMISS_NOTT_REMINDER)) { throw new UnauthorizedError('Unauthorized to dismiss NOTT reminder'); } diff --git a/web-api/src/lambdas/trialSessions/dismissNOTTReminderForTrialLambda.ts b/web-api/src/lambdas/trialSessions/dismissNOTTReminderForTrialLambda.ts index 8f91fec2225..71c30c1e93e 100644 --- a/web-api/src/lambdas/trialSessions/dismissNOTTReminderForTrialLambda.ts +++ b/web-api/src/lambdas/trialSessions/dismissNOTTReminderForTrialLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { dismissNOTTReminderForTrialInteractor } from '@web-api/business/useCases/trialSessions/dismissNOTTReminderForTrialInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -11,13 +12,11 @@ export const dismissNOTTReminderForTrialLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .dismissNOTTReminderForTrialInteractor( - applicationContext, - authorizedUser, - { - ...JSON.parse(event.body), - }, - ); + return await dismissNOTTReminderForTrialInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); From d00fa56e2f71e8387cfe3d18350d8663bfa1a5c7 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 10:55:18 -0700 Subject: [PATCH 315/523] 10417 remove getCurrentUser --- .../addCaseToTrialSessionInteractor.test.ts | 129 +++++++++++------- .../addCaseToTrialSessionInteractor.ts | 14 +- .../addCaseToTrialSessionLambda.ts | 17 ++- 3 files changed, 96 insertions(+), 64 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.test.ts index a2e8f8c5b13..ba6047fed74 100644 --- a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.test.ts @@ -1,7 +1,6 @@ import { CASE_STATUS_TYPES, CHIEF_JUDGE, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; @@ -9,9 +8,12 @@ import { MOCK_TRIAL_REMOTE } from '../../../../../shared/src/test/mockTrial'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { addCaseToTrialSessionInteractor } from './addCaseToTrialSessionInteractor'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('addCaseToTrialSessionInteractor', () => { - let mockCurrentUser; let mockTrialSession; let mockCase; let mockLock; @@ -20,7 +22,6 @@ describe('addCaseToTrialSessionInteractor', () => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => mockLock); - applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser); applicationContext .getPersistenceGateway() .getTrialSessionById.mockImplementation(() => mockTrialSession); @@ -31,26 +32,21 @@ describe('addCaseToTrialSessionInteractor', () => { beforeEach(() => { mockLock = undefined; - mockCurrentUser = { - role: ROLES.petitionsClerk, - userId: '8675309b-18d0-43ec-bafb-654e83405411', - }; mockTrialSession = MOCK_TRIAL_REMOTE; mockCase = MOCK_CASE; }); it('throws an Unauthorized error if the user role is not allowed to access the method', async () => { - mockCurrentUser = { - role: ROLES.petitioner, - userId: '8675309b-18d0-43ec-bafb-654e83405411', - }; - await expect( - addCaseToTrialSessionInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: mockCase.docketNumber, - trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, - }), + addCaseToTrialSessionInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: mockCase.docketNumber, + trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -61,11 +57,15 @@ describe('addCaseToTrialSessionInteractor', () => { }; await expect( - addCaseToTrialSessionInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: mockCase.docketNumber, - trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, - }), + addCaseToTrialSessionInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: mockCase.docketNumber, + trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('The case is already calendared'); }); @@ -77,11 +77,15 @@ describe('addCaseToTrialSessionInteractor', () => { }; await expect( - addCaseToTrialSessionInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, - }), + addCaseToTrialSessionInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow('The case is already part of this trial session.'); }); @@ -99,6 +103,7 @@ describe('addCaseToTrialSessionInteractor', () => { docketNumber: MOCK_CASE.docketNumber, trialSessionId: mockTrialSession.trialSessionId, }, + mockPetitionsClerkUser, ); expect(latestCase).toMatchObject({ @@ -118,11 +123,15 @@ describe('addCaseToTrialSessionInteractor', () => { isCalendared: true, }; - await addCaseToTrialSessionInteractor(applicationContext, { - calendarNotes: 'Test', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, - }); + await addCaseToTrialSessionInteractor( + applicationContext, + { + calendarNotes: 'Test', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, + }, + mockPetitionsClerkUser, + ); const caseWithCalendarNotes = applicationContext .getPersistenceGateway() @@ -139,11 +148,15 @@ describe('addCaseToTrialSessionInteractor', () => { isCalendared: true, }; - await addCaseToTrialSessionInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, - }); + await addCaseToTrialSessionInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().setPriorityOnAllWorkItems.mock @@ -161,11 +174,15 @@ describe('addCaseToTrialSessionInteractor', () => { isCalendared: false, }; - await addCaseToTrialSessionInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, - }); + await addCaseToTrialSessionInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: MOCK_TRIAL_REMOTE.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().setPriorityOnAllWorkItems, @@ -176,11 +193,15 @@ describe('addCaseToTrialSessionInteractor', () => { mockLock = MOCK_LOCK; await expect( - addCaseToTrialSessionInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: mockTrialSession.trialSessionId, - }), + addCaseToTrialSessionInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: mockTrialSession.trialSessionId, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -189,11 +210,15 @@ describe('addCaseToTrialSessionInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await addCaseToTrialSessionInteractor(applicationContext, { - calendarNotes: 'testing', - docketNumber: MOCK_CASE.docketNumber, - trialSessionId: mockTrialSession.trialSessionId, - }); + await addCaseToTrialSessionInteractor( + applicationContext, + { + calendarNotes: 'testing', + docketNumber: MOCK_CASE.docketNumber, + trialSessionId: mockTrialSession.trialSessionId, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts index 5939b856adc..1a726b3744d 100644 --- a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts @@ -7,6 +7,7 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; /** @@ -29,10 +30,11 @@ export const addCaseToTrialSession = async ( docketNumber: string; trialSessionId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.ADD_CASE_TO_TRIAL_SESSION)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_CASE_TO_TRIAL_SESSION) + ) { throw new UnauthorizedError('Unauthorized'); } @@ -54,7 +56,7 @@ export const addCaseToTrialSession = async ( docketNumber, }); - const caseEntity = new Case(caseDetails, { authorizedUser: user }); + const caseEntity = new Case(caseDetails, { authorizedUser }); const trialSessionEntity = new TrialSession(trialSession); @@ -100,9 +102,7 @@ export const addCaseToTrialSession = async ( trialSessionToUpdate: trialSessionEntity.validate().toRawObject(), }); - return new Case(updatedCase, { authorizedUser: user }) - .validate() - .toRawObject(); + return new Case(updatedCase, { authorizedUser }).validate().toRawObject(); }; export const addCaseToTrialSessionInteractor = withLocking( diff --git a/web-api/src/lambdas/trialSessions/addCaseToTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/addCaseToTrialSessionLambda.ts index 7187d83c42f..a7a115a1f52 100644 --- a/web-api/src/lambdas/trialSessions/addCaseToTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/addCaseToTrialSessionLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { addCaseToTrialSessionInteractor } from '@web-api/business/useCases/trialSessions/addCaseToTrialSessionInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,16 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const addCaseToTrialSessionLambda = event => +export const addCaseToTrialSessionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { docketNumber, trialSessionId } = event.pathParameters || event.path; const { calendarNotes } = JSON.parse(event.body); - return await applicationContext - .getUseCases() - .addCaseToTrialSessionInteractor(applicationContext, { + return await addCaseToTrialSessionInteractor( + applicationContext, + { calendarNotes, docketNumber, trialSessionId, - }); + }, + authorizedUser, + ); }); From 8769ffe3c165f643765cc4a0eb752ac554c18404 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 11:08:30 -0700 Subject: [PATCH 316/523] 10417 remove getCurrentUser from generatePrinatbleTrialSessionCopyReportInteractor --- ...leTrialSessionCopyReportInteractor.test.ts | 79 ++++++++++--------- ...intableTrialSessionCopyReportInteractor.ts | 3 +- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.test.ts b/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.test.ts index bcf10204b05..5b1d91010ea 100644 --- a/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.test.ts +++ b/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.test.ts @@ -1,22 +1,17 @@ import { Case } from '@shared/business/entities/cases/Case'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_TRIAL_REGULAR } from '../../../../../shared/src/test/mockTrial'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generatePrintableTrialSessionCopyReportInteractor } from './generatePrintableTrialSessionCopyReportInteractor'; +import { + mockPetitionerUser, + mockTrialClerkUser, +} from '@shared/test/mockAuthUsers'; describe('generatePrintableTrialSessionCopyReportInteractor', () => { - let mockUser; let mockTrialSession; beforeEach(() => { - mockUser = { - role: ROLES.trialClerk, - userId: 'trialclerk', - }; - - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - applicationContext .getPersistenceGateway() .getDownloadPolicyUrl.mockReturnValue({ url: 'https://example.com' }); @@ -31,32 +26,33 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { }); it('should throw an error when the user is not authorized to generate a printable trial session report', async () => { - mockUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( - generatePrintableTrialSessionCopyReportInteractor(applicationContext, { - filters: { - aBasisReached: true, - continued: true, - dismissed: true, - recall: true, - rule122: true, - setForTrial: true, - settled: true, - showAll: true, - statusUnassigned: true, - takenUnderAdvisement: true, + generatePrintableTrialSessionCopyReportInteractor( + applicationContext, + { + filters: { + aBasisReached: true, + continued: true, + dismissed: true, + recall: true, + rule122: true, + setForTrial: true, + settled: true, + showAll: true, + statusUnassigned: true, + takenUnderAdvisement: true, + }, + formattedCases: [ + new Case(MOCK_CASE, { authorizedUser: mockTrialClerkUser }), + ], + formattedTrialSession: mockTrialSession, + sessionNotes: 'session notes', + showCaseNotes: true, + sort: 'docket', + userHeading: 'Yggdrasil - Session Copy', }, - formattedCases: [new Case(MOCK_CASE, { applicationContext })], - formattedTrialSession: mockTrialSession, - sessionNotes: 'session notes', - showCaseNotes: true, - sort: 'docket', - userHeading: 'Yggdrasil - Session Copy', - }), + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -76,13 +72,16 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { statusUnassigned: true, takenUnderAdvisement: true, }, - formattedCases: [new Case(MOCK_CASE, { applicationContext })], + formattedCases: [ + new Case(MOCK_CASE, { authorizedUser: mockTrialClerkUser }), + ], formattedTrialSession: mockTrialSession, sessionNotes: 'session notes', showCaseNotes: true, sort: 'docket', userHeading: 'Yggdrasil - Session Copy', }, + mockTrialClerkUser, ); expect( @@ -103,7 +102,9 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { statusUnassigned: true, takenUnderAdvisement: true, }, - formattedCases: [new Case(MOCK_CASE, { applicationContext })], + formattedCases: [ + new Case(MOCK_CASE, { authorizedUser: mockTrialClerkUser }), + ], formattedTrialSession: mockTrialSession, sessionNotes: 'session notes', showCaseNotes: true, @@ -129,13 +130,14 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { statusUnassigned: true, takenUnderAdvisement: true, }, - formattedCases: [new Case(MOCK_CASE, { applicationContext })], + formattedCases: [new Case(MOCK_CASE, { mockTrialClerkUser })], formattedTrialSession: mockTrialSession, sessionNotes: 'session notes', showCaseNotes: true, sort: 'docket', userHeading: 'Yggdrasil - Session Copy', }, + mockTrialClerkUser, ); expect( @@ -159,13 +161,16 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { statusUnassigned: true, takenUnderAdvisement: true, }, - formattedCases: [new Case(MOCK_CASE, { applicationContext })], + formattedCases: [ + new Case(MOCK_CASE, { authorizedUser: mockTrialClerkUser }), + ], formattedTrialSession: mockTrialSession, sessionNotes: 'session notes', showCaseNotes: true, sort: 'docket', userHeading: 'Yggdrasil - Session Copy', }, + mockTrialClerkUser, ); expect( diff --git a/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.ts b/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.ts index f71f7edb7f1..4d3dd92f2f5 100644 --- a/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.ts +++ b/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.ts @@ -6,6 +6,7 @@ import { import { RawTrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const generatePrintableTrialSessionCopyReportInteractor = async ( applicationContext: ServerApplicationContext, @@ -26,8 +27,8 @@ export const generatePrintableTrialSessionCopyReportInteractor = async ( sort: string; userHeading: string; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); if ( !isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSION_WORKING_COPY) ) { From d94386e3238a87f605cf6f2dbec333ca777ea567 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Mon, 22 Jul 2024 15:13:42 -0400 Subject: [PATCH 317/523] 10417 rm getCurrentUser update affected tests updating test was moot but changed for consistency and documentation --- ...tPublicDownloadPolicyUrlInteractor.test.ts | 66 +++++++++++++------ .../getPublicDownloadPolicyUrlInteractor.ts | 6 +- .../getPublicDocumentDownloadUrlLambda.ts | 18 +++-- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts index f4587320024..7892fba48c1 100644 --- a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts +++ b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts @@ -7,6 +7,7 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; import { getPublicDownloadPolicyUrlInteractor } from './getPublicDownloadPolicyUrlInteractor'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('getPublicDownloadPolicyUrlInteractor', () => { let mockCase; @@ -27,11 +28,15 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { jest.spyOn(DocketEntry, 'isPublic').mockReturnValueOnce(false); await expect( - getPublicDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: '123-20', - isTerminalUser: false, - key: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - }), + getPublicDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: '123-20', + isTerminalUser: false, + key: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + }, + mockDocketClerkUser, + ), ).rejects.toThrow('Unauthorized to access private document'); }); @@ -43,6 +48,7 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { isTerminalUser: true, key: '9de27a7d-7c6b-434b-803b-7655f82d5e07', }, + mockDocketClerkUser, ); expect( @@ -90,10 +96,14 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { ), ); await expect( - getPublicDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: '123-20', - key: '5a3ea70f-c539-4118-81a3-0be94be3b4f1', - } as any), + getPublicDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: '123-20', + key: '5a3ea70f-c539-4118-81a3-0be94be3b4f1', + } as any, + mockDocketClerkUser, + ), ).rejects.toThrow('Unauthorized to access documents in a sealed case'); }); @@ -126,6 +136,7 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { docketNumber: '123-20', key: '83813a24-7687-418e-a186-c416b4bb0ad4', } as any, + mockDocketClerkUser, ); expect(result).toEqual({ url: 'localhost' }); }); @@ -153,16 +164,21 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { docketNumber: '123-20', key: '8008b288-8b6b-48e3-8239-599266b13b8b', } as any, + mockDocketClerkUser, ); expect(result).toEqual({ url: 'localhost' }); }); it('should throw a not found error for a document that is not found on the case', async () => { await expect( - getPublicDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: '123-20', - key: 'b907f4e5-4d4d-44b3-bcfd-224a6f31d889', - } as any), + getPublicDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: '123-20', + key: 'b907f4e5-4d4d-44b3-bcfd-224a6f31d889', + } as any, + mockDocketClerkUser, + ), ).rejects.toThrow( 'Docket entry b907f4e5-4d4d-44b3-bcfd-224a6f31d889 was not found.', ); @@ -185,10 +201,14 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { ); await expect( - getPublicDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: '123-20', - key: '8205c4bc-879f-4648-a3ba-9280384c4c00', - } as any), + getPublicDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: '123-20', + key: '8205c4bc-879f-4648-a3ba-9280384c4c00', + } as any, + mockDocketClerkUser, + ), ).rejects.toThrow( 'Docket entry 8205c4bc-879f-4648-a3ba-9280384c4c00 does not have an attached file.', ); @@ -214,10 +234,14 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { ); await expect( - getPublicDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: '123-20', - key: '8205c4bc-879f-4648-a3ba-9280384c4c00', - } as any), + getPublicDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: '123-20', + key: '8205c4bc-879f-4648-a3ba-9280384c4c00', + } as any, + mockDocketClerkUser, + ), ).rejects.toThrow('Docket entry has been sealed.'); }); }); diff --git a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts index ded504affb9..4493995eb96 100644 --- a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts +++ b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts @@ -9,6 +9,7 @@ import { import { DocketEntry } from '@shared/business/entities/DocketEntry'; import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const getPublicDownloadPolicyUrlInteractor = async ( applicationContext: ServerApplicationContext, @@ -17,6 +18,7 @@ export const getPublicDownloadPolicyUrlInteractor = async ( isTerminalUser, key, }: { docketNumber: string; isTerminalUser: boolean; key: string }, + authorizdeUser: UnknownAuthUser, ): Promise<{ url: string }> => { const caseToCheck: any = await applicationContext .getPersistenceGateway() @@ -29,9 +31,7 @@ export const getPublicDownloadPolicyUrlInteractor = async ( throw new NotFoundError(`Case ${docketNumber} was not found.`); } - const caseEntity = new Case(caseToCheck, { - authorizedUser: applicationContext.getCurrentUser(), - }); + const caseEntity = new Case(caseToCheck, { authorizedUser: authorizdeUser }); const docketEntryEntity = caseEntity.getDocketEntryById({ docketEntryId: key, diff --git a/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts index e3738e20a22..185a7240bf6 100644 --- a/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts @@ -1,3 +1,4 @@ +import { UnknownUserAuth } from '../../../shared/src/auth/UserAuthType'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +7,19 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getPublicDocumentDownloadUrlLambda = event => +export const getPublicDocumentDownloadUrlLambda = ( + event, + authorizdeUser: UnknownUserAuth, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getPublicDownloadPolicyUrlInteractor(applicationContext, { - ...event.pathParameters, - isTerminalUser: event.isTerminalUser, - }); + .getPublicDownloadPolicyUrlInteractor( + applicationContext, + { + ...event.pathParameters, + isTerminalUser: event.isTerminalUser, + }, + authorizdeUser, + ); }); From 971e43f9f37dca16e32a367b2acfb51fa6632b9c Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 12:23:18 -0700 Subject: [PATCH 318/523] 10417: remove appcontext.getCurrentUser from getCountOfCaseDocumentsFiledByJudgesInteractor --- ...seDocumentsFiledByJudgesInteractor.test.ts | 31 +++++++++++++------ ...tOfCaseDocumentsFiledByJudgesInteractor.ts | 4 ++- ...CountOfCaseDocumentsFiledByJudgesLambda.ts | 11 +++---- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.test.ts b/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.test.ts index 54e74d5838c..94169391ed8 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.test.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.test.ts @@ -1,16 +1,20 @@ import { AggregatedEventCodesType } from '../../../persistence/elasticsearch/fetchEventCodesCountForJudges'; import { - JudgeActivityReportFilters, + GetCountOfCaseDocumentsFiledByJudgesRequest, getCountOfCaseDocumentsFiledByJudgesInteractor, } from './getCountOfCaseDocumentsFiledByJudgesInteractor'; import { OPINION_EVENT_CODES_WITH_BENCH_OPINION } from '../../../../../shared/src/business/entities/EntityConstants'; import { addDocumentTypeToEventCodeAggregation } from './addDocumentTypeToEventCodeAggregation'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { judgeUser, petitionsClerkUser } from '@shared/test/mockUsers'; +import { judgeUser } from '@shared/test/mockUsers'; import { mockCountOfOpinionsIssuedByJudge, mockCountOfOrdersIssuedByJudge, } from '@shared/test/mockSearchResults'; +import { + mockJudgeUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; jest.mock('./addDocumentTypeToEventCodeAggregation'); @@ -18,7 +22,7 @@ describe('getCountOfCaseDocumentsFiledByJudgesInteractor', () => { const mockStartDate = '02/12/2020'; const mockEndDate = '03/21/2020'; const mockJudges = [judgeUser.name]; - const mockValidRequest: JudgeActivityReportFilters = { + const mockValidRequest: GetCountOfCaseDocumentsFiledByJudgesRequest = { documentEventCodes: OPINION_EVENT_CODES_WITH_BENCH_OPINION, endDate: mockEndDate, judges: mockJudges, @@ -26,7 +30,7 @@ describe('getCountOfCaseDocumentsFiledByJudgesInteractor', () => { }; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(judgeUser); + // applicationContext.getCurrentUser.mockReturnValue(judgeUser); applicationContext .getPersistenceGateway() @@ -37,23 +41,29 @@ describe('getCountOfCaseDocumentsFiledByJudgesInteractor', () => { }); it('should return an error when the user is not authorized to generate the report', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); + // applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); await expect( getCountOfCaseDocumentsFiledByJudgesInteractor( applicationContext, mockValidRequest, + mockPetitionsClerkUser, ), ).rejects.toThrow('Unauthorized'); }); it('should return an error when the search parameters are not valid', async () => { await expect( - getCountOfCaseDocumentsFiledByJudgesInteractor(applicationContext, { - endDate: 'baddabingbaddaboom', - judges: [judgeUser.name], - startDate: 'yabbadabbadoo', - }), + getCountOfCaseDocumentsFiledByJudgesInteractor( + applicationContext, + { + documentEventCodes: [], + endDate: 'baddabingbaddaboom', + judges: [judgeUser.name], + startDate: 'yabbadabbadoo', + }, + mockJudgeUser, + ), ).rejects.toThrow(); }); @@ -62,6 +72,7 @@ describe('getCountOfCaseDocumentsFiledByJudgesInteractor', () => { await getCountOfCaseDocumentsFiledByJudgesInteractor( applicationContext, mockValidRequest, + mockJudgeUser, ); expect( diff --git a/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.ts b/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.ts index dffb6b18503..5dd6ab89809 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.ts @@ -6,6 +6,7 @@ import { isAuthorized, } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { addDocumentTypeToEventCodeAggregation } from './addDocumentTypeToEventCodeAggregation'; export type JudgeActivityReportFilters = { @@ -30,8 +31,9 @@ export type GetCountOfCaseDocumentsFiledByJudgesRequest = { export const getCountOfCaseDocumentsFiledByJudgesInteractor = async ( applicationContext: ServerApplicationContext, params: GetCountOfCaseDocumentsFiledByJudgesRequest, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); + // const authorizedUser = applicationContext.getCurrentUser(); if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.JUDGE_ACTIVITY_REPORT)) { throw new UnauthorizedError('Unauthorized to view Judge Activity Report'); diff --git a/web-api/src/lambdas/reports/getCountOfCaseDocumentsFiledByJudgesLambda.ts b/web-api/src/lambdas/reports/getCountOfCaseDocumentsFiledByJudgesLambda.ts index dc7a12f2203..3ea5a3a817e 100644 --- a/web-api/src/lambdas/reports/getCountOfCaseDocumentsFiledByJudgesLambda.ts +++ b/web-api/src/lambdas/reports/getCountOfCaseDocumentsFiledByJudgesLambda.ts @@ -1,13 +1,9 @@ -import { APIGatewayProxyEvent } from 'aws-lambda'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * gets the count of cases documents filed by judge for their activity report - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ export const getCountOfCaseDocumentsFiledByJudgesLambda = ( - event: APIGatewayProxyEvent, + event, + authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext @@ -15,5 +11,6 @@ export const getCountOfCaseDocumentsFiledByJudgesLambda = ( .getCountOfCaseDocumentsFiledByJudgesInteractor( applicationContext, event.queryStringParameters, + authorizedUser, ); }); From 03de2507d4d401a53d7e76f39d8d48dd2d23a798 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 12:31:41 -0700 Subject: [PATCH 319/523] 10417: remove appcontext.getCurrentUser from getCaseWorksheetsByJudgeInteractor --- ...getCaseWorksheetsByJudgeInteractor.test.ts | 33 ++++++++++++------- .../getCaseWorksheetsByJudgeInteractor.ts | 4 +-- .../reports/getCaseWorksheetsByJudgeLambda.ts | 9 +++-- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/web-api/src/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor.test.ts b/web-api/src/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor.test.ts index 1e063eb575c..3e8884b3db5 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor.test.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor.test.ts @@ -11,7 +11,11 @@ import { import { MOCK_CASE_WORKSHEET } from '@shared/test/mockCaseWorksheet'; import { RawCaseWorksheet } from '@shared/business/entities/caseWorksheet/CaseWorksheet'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { judgeUser, petitionsClerkUser } from '@shared/test/mockUsers'; +import { judgeUser } from '@shared/test/mockUsers'; +import { + mockJudgeUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getCaseWorksheetsByJudgeInteractor', () => { let mockGetDocketNumbersByStatusAndByJudgeResult: RawCase[] = []; @@ -61,24 +65,26 @@ describe('getCaseWorksheetsByJudgeInteractor', () => { () => mockGetDocketNumbersByStatusAndByJudgeResult, ); - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(judgeUser); - }); - it('should return an error when the user is not authorized to generate the report', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - await expect( - getCaseWorksheetsByJudgeInteractor(applicationContext, mockValidRequest), + getCaseWorksheetsByJudgeInteractor( + applicationContext, + mockValidRequest, + mockPetitionsClerkUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should return an error when the search parameters are not valid', async () => { await expect( - getCaseWorksheetsByJudgeInteractor(applicationContext, { - judges: [judgeUser.name], - statuses: [undefined as any], - }), + getCaseWorksheetsByJudgeInteractor( + applicationContext, + { + judges: [judgeUser.name], + statuses: [undefined as any], + }, + mockJudgeUser, + ), ).rejects.toThrow(); }); @@ -86,6 +92,7 @@ describe('getCaseWorksheetsByJudgeInteractor', () => { await getCaseWorksheetsByJudgeInteractor( applicationContext, mockValidRequest, + mockJudgeUser, ); expect( @@ -126,6 +133,7 @@ describe('getCaseWorksheetsByJudgeInteractor', () => { const result = await getCaseWorksheetsByJudgeInteractor( applicationContext, mockValidRequest, + mockJudgeUser, ); expect(result.cases).toEqual( @@ -161,6 +169,7 @@ describe('getCaseWorksheetsByJudgeInteractor', () => { const result = await getCaseWorksheetsByJudgeInteractor( applicationContext, mockValidRequest, + mockJudgeUser, ); const actualCases = result.cases.map(aCase => ({ diff --git a/web-api/src/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor.ts b/web-api/src/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor.ts index e4eda1f885b..38fe6015f59 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor.ts @@ -7,6 +7,7 @@ import { import { RawCaseWorksheet } from '@shared/business/entities/caseWorksheet/CaseWorksheet'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { SubmittedCAVTableFields } from '@web-api/persistence/elasticsearch/getDocketNumbersByStatusAndByJudge'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export type GetCasesByStatusAndByJudgeRequest = { statuses: string[]; @@ -21,11 +22,10 @@ export type GetCasesByStatusAndByJudgeResponse = SubmittedCAVTableFields & { export const getCaseWorksheetsByJudgeInteractor = async ( applicationContext: ServerApplicationContext, params: GetCasesByStatusAndByJudgeRequest, + authorizedUser: UnknownAuthUser, ): Promise<{ cases: GetCasesByStatusAndByJudgeResponse[]; }> => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.JUDGE_ACTIVITY_REPORT)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/reports/getCaseWorksheetsByJudgeLambda.ts b/web-api/src/lambdas/reports/getCaseWorksheetsByJudgeLambda.ts index 2a148721f3a..c4801ad2c22 100644 --- a/web-api/src/lambdas/reports/getCaseWorksheetsByJudgeLambda.ts +++ b/web-api/src/lambdas/reports/getCaseWorksheetsByJudgeLambda.ts @@ -1,15 +1,20 @@ -import { APIGatewayProxyEvent } from 'aws-lambda'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -export const getCaseWorksheetsByJudgeLambda = (event: APIGatewayProxyEvent) => +export const getCaseWorksheetsByJudgeLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, + async ({ applicationContext }) => { return await applicationContext .getUseCases() .getCaseWorksheetsByJudgeInteractor( applicationContext, event.queryStringParameters, + authorizedUser, ); }, { logResults: false }, From 3332dd29fabdfe2799e582ed963092a57dc5af15 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 12:37:39 -0700 Subject: [PATCH 320/523] 10417: remove appcontext.getCurrentUser from getTrialSessionsForJudgeActivityReportInteractor --- ...sionsForJudgeActivityReportInteractor.test.ts | 12 +++++++----- ...alSessionsForJudgeActivityReportInteractor.ts | 6 +++--- ...tTrialSessionsForJudgeActivityReportLambda.ts | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/web-api/src/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor.test.ts b/web-api/src/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor.test.ts index 0d66cafc723..ef1dccd0722 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor.test.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor.test.ts @@ -2,8 +2,9 @@ import { JudgeActivityStatisticsRequest } from '@web-api/business/useCases/judge import { MOCK_TRIAL_REGULAR } from '@shared/test/mockTrial'; import { SESSION_TYPES } from '@shared/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { docketClerkUser, judgeUser } from '@shared/test/mockUsers'; import { getTrialSessionsForJudgeActivityReportInteractor } from './getTrialSessionsForJudgeActivityReportInteractor'; +import { judgeUser } from '@shared/test/mockUsers'; +import { mockDocketClerkUser, mockJudgeUser } from '@shared/test/mockAuthUsers'; describe('getTrialSessionsForJudgeActivityReportInteractor', () => { const mockJudges = [ @@ -117,20 +118,17 @@ describe('getTrialSessionsForJudgeActivityReportInteractor', () => { }; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(judgeUser); - applicationContext .getPersistenceGateway() .getTrialSessions.mockReturnValue(mockTrialSessionsForAllJudges); }); it('should throw an error when user is unauthorized to retrieve the judge activity report', async () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - await expect( getTrialSessionsForJudgeActivityReportInteractor( applicationContext, mockValidRequest, + mockDocketClerkUser, ), ).rejects.toThrow(); }); @@ -140,6 +138,7 @@ describe('getTrialSessionsForJudgeActivityReportInteractor', () => { getTrialSessionsForJudgeActivityReportInteractor( applicationContext, mockInvalidRequest, + mockJudgeUser, ), ).rejects.toThrow(); }); @@ -148,6 +147,7 @@ describe('getTrialSessionsForJudgeActivityReportInteractor', () => { await getTrialSessionsForJudgeActivityReportInteractor( applicationContext, mockValidRequest, + mockJudgeUser, ); expect( @@ -159,6 +159,7 @@ describe('getTrialSessionsForJudgeActivityReportInteractor', () => { const opinions = await getTrialSessionsForJudgeActivityReportInteractor( applicationContext, mockValidRequest, + mockJudgeUser, ); expect(opinions).toEqual({ @@ -178,6 +179,7 @@ describe('getTrialSessionsForJudgeActivityReportInteractor', () => { const result = await getTrialSessionsForJudgeActivityReportInteractor( applicationContext, request, + mockJudgeUser, ); expect(result).toEqual({ diff --git a/web-api/src/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor.ts b/web-api/src/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor.ts index d73c7c05047..0cd1f3ada8b 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor.ts @@ -10,6 +10,7 @@ import { SESSION_TYPES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { sum } from 'lodash'; export type TrialSessionTypes = { @@ -28,10 +29,9 @@ export type TrialSessionReturnType = { export const getTrialSessionsForJudgeActivityReportInteractor = async ( applicationContext: ServerApplicationContext, { endDate, judges, startDate }: JudgeActivityStatisticsRequest, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.JUDGE_ACTIVITY_REPORT)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.JUDGE_ACTIVITY_REPORT)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/reports/getTrialSessionsForJudgeActivityReportLambda.ts b/web-api/src/lambdas/reports/getTrialSessionsForJudgeActivityReportLambda.ts index 65deb2f8f28..0c073275544 100644 --- a/web-api/src/lambdas/reports/getTrialSessionsForJudgeActivityReportLambda.ts +++ b/web-api/src/lambdas/reports/getTrialSessionsForJudgeActivityReportLambda.ts @@ -1,14 +1,22 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -export const getTrialSessionsForJudgeActivityReportLambda = event => +export const getTrialSessionsForJudgeActivityReportLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getTrialSessionsForJudgeActivityReportInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .getTrialSessionsForJudgeActivityReportInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); From 7b05d46ee04b44c25543fd95eaf4f18635697bf9 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 14:50:18 -0500 Subject: [PATCH 321/523] 10417 remove getCurrentUser from serveCaseToIrsInteractor --- .../serveCaseToIrsInteractor.test.ts | 271 ++++++++++++++---- .../serveCaseToIrsInteractor.ts | 9 +- .../src/lambdas/cases/serveCaseToIrsLambda.ts | 13 +- 3 files changed, 235 insertions(+), 58 deletions(-) diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.test.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.test.ts index 5abfde3bcfa..31cc10056a2 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.test.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.test.ts @@ -29,14 +29,14 @@ import { UnauthorizedError, } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { - docketClerkUser, - petitionsClerkUser, -} from '../../../../../shared/src/test/mockUsers'; import { getFakeFile, testPdfDoc, } from '../../../../../shared/src/business/test/getFakeFile'; +import { + mockDocketClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { serveCaseToIrsInteractor } from './serveCaseToIrsInteractor'; describe('serveCaseToIrsInteractor', () => { @@ -107,8 +107,6 @@ describe('serveCaseToIrsInteractor', () => { mockCase.docketEntries[0].workItem = { ...MOCK_WORK_ITEM }; applicationContext.getPersistenceGateway().updateWorkItem = jest.fn(); - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - applicationContext.getStorageClient.mockReturnValue({ getObject: getObjectMock, upload: (params, cb) => { @@ -136,9 +134,11 @@ describe('serveCaseToIrsInteractor', () => { }); it('should throw unauthorized error when user is unauthorized', async () => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser, ).toHaveBeenCalledWith({ @@ -166,7 +166,11 @@ describe('serveCaseToIrsInteractor', () => { mailingDate: 'some day', }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -191,7 +195,11 @@ describe('serveCaseToIrsInteractor', () => { mailingDate: 'some day', }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -201,7 +209,11 @@ describe('serveCaseToIrsInteractor', () => { it('should replace coversheet on the served petition if the case is not paper', async () => { mockCase = { ...MOCK_CASE }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -216,7 +228,11 @@ describe('serveCaseToIrsInteractor', () => { it('should preserve original case caption and docket number on the coversheet if the case is not paper', async () => { mockCase = { ...MOCK_CASE }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCases().addCoversheetInteractor, @@ -254,7 +270,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUtilities().getAddressPhoneDiff, @@ -284,7 +304,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUtilities().getAddressPhoneDiff, ).toHaveBeenCalled(); @@ -317,7 +341,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUtilities().getAddressPhoneDiff, @@ -374,7 +402,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition, @@ -408,7 +440,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition.mock @@ -452,7 +488,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition.mock @@ -495,7 +535,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition.mock @@ -524,7 +568,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().isFileExists, @@ -552,7 +600,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect(addDocketEntrySpy.mock.calls[0][0].documentTitle).toEqual( 'Filing Fee Waived', @@ -573,7 +625,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect(addDocketEntrySpy.mock.calls[0][0].documentTitle).toEqual( 'Filing Fee Paid', @@ -595,7 +651,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().isFileExists, @@ -631,7 +691,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().isFileExists, @@ -671,7 +735,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().isFileExists, @@ -718,7 +786,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition, @@ -771,7 +843,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition, @@ -801,7 +877,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition, @@ -843,7 +923,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition, @@ -861,7 +945,11 @@ describe('serveCaseToIrsInteractor', () => { isPaper: false, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -875,7 +963,11 @@ describe('serveCaseToIrsInteractor', () => { isPaper: false, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition, @@ -889,7 +981,11 @@ describe('serveCaseToIrsInteractor', () => { orderForFilingFee: false, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -909,7 +1005,11 @@ describe('serveCaseToIrsInteractor', () => { orderForAmendedPetition: false, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers() @@ -926,6 +1026,7 @@ describe('serveCaseToIrsInteractor', () => { const result = await serveCaseToIrsInteractor( applicationContext, mockParams, + mockPetitionsClerkUser, ); expect(result).toBeUndefined(); @@ -938,7 +1039,11 @@ describe('serveCaseToIrsInteractor', () => { mailingDate: 'some day', }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser, @@ -960,7 +1065,11 @@ describe('serveCaseToIrsInteractor', () => { mailingDate: 'some day', }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); const updatedCase = applicationContext.getUseCaseHelpers().updateCaseAndAssociations.mock @@ -1025,7 +1134,11 @@ describe('serveCaseToIrsInteractor', () => { .mockReturnValueOnce(mockCaseWithServedDocketEntries) .mockReturnValueOnce(mockCaseWithServedDocketEntries); - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -1066,7 +1179,11 @@ describe('serveCaseToIrsInteractor', () => { }; const MOCK_NOTR_ID = 'ea10afeb-f189-4657-a862-c607a091beaa'; applicationContext.getUniqueId.mockReturnValue(MOCK_NOTR_ID); - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUseCaseHelpers().sendServedPartiesEmails.mock .calls[0][0].docketEntryId, @@ -1107,7 +1224,11 @@ describe('serveCaseToIrsInteractor', () => { mailingDate: 'some day', }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getUtilities().serveCaseDocument, @@ -1120,7 +1241,11 @@ describe('serveCaseToIrsInteractor', () => { noticeOfAttachments: true, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect(applicationContext.getDocumentGenerators().order).toHaveBeenCalled(); expect( @@ -1134,7 +1259,11 @@ describe('serveCaseToIrsInteractor', () => { orderDesignatingPlaceOfTrial: true, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( await applicationContext.getUseCaseHelpers() @@ -1189,7 +1318,11 @@ describe('serveCaseToIrsInteractor', () => { orderToShowCause: true, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect(applicationContext.getDocumentGenerators().order).toHaveBeenCalled(); expect( @@ -1203,7 +1336,11 @@ describe('serveCaseToIrsInteractor', () => { orderToShowCause: true, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( await applicationContext.getUseCaseHelpers() @@ -1249,7 +1386,11 @@ describe('serveCaseToIrsInteractor', () => { orderForAmendedPetition: true, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( await applicationContext.getUseCaseHelpers() @@ -1287,7 +1428,11 @@ describe('serveCaseToIrsInteractor', () => { orderForAmendedPetitionAndFilingFee: true, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( await applicationContext.getUseCaseHelpers() @@ -1340,7 +1485,11 @@ describe('serveCaseToIrsInteractor', () => { orderToShowCause: true, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( await applicationContext.getUseCaseHelpers() @@ -1357,7 +1506,11 @@ describe('serveCaseToIrsInteractor', () => { orderForFilingFee: true, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect(applicationContext.getDocumentGenerators().order).toHaveBeenCalled(); expect( @@ -1389,7 +1542,11 @@ describe('serveCaseToIrsInteractor', () => { mockLock = MOCK_LOCK; await expect( - serveCaseToIrsInteractor(applicationContext, mockParams), + serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -1398,7 +1555,11 @@ describe('serveCaseToIrsInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -1417,7 +1578,11 @@ describe('serveCaseToIrsInteractor', () => { }); it('should generate a notice of receipt of petition with the name and title of the clerk of the court', async () => { - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition.mock .calls[0][0].data, @@ -1452,7 +1617,11 @@ describe('serveCaseToIrsInteractor', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, }; - await serveCaseToIrsInteractor(applicationContext, mockParams); + await serveCaseToIrsInteractor( + applicationContext, + mockParams, + mockPetitionsClerkUser, + ); expect( applicationContext.getDocumentGenerators().noticeOfReceiptOfPetition.mock diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts index bdb908b20bf..84dc48f9f4f 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts @@ -1,5 +1,8 @@ /* eslint-disable complexity */ -import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { + AuthUser, + UnknownAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; import { @@ -482,12 +485,13 @@ export const serveCaseToIrs = async ( clientConnectionId, docketNumber, }: { clientConnectionId: string; docketNumber: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); try { if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.SERVE_PETITION)) { throw new UnauthorizedError('Unauthorized'); } + const caseToBatch = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ @@ -517,6 +521,7 @@ export const serveCaseToIrs = async ( user: authorizedUser, }); + // TODO 10417 type weirdness -- why is this angry? caseEntity .updateCaseCaptionDocketRecord({ authorizedUser }) .updateDocketNumberRecord({ authorizedUser }) diff --git a/web-api/src/lambdas/cases/serveCaseToIrsLambda.ts b/web-api/src/lambdas/cases/serveCaseToIrsLambda.ts index 9370931c50c..d0b918de54b 100644 --- a/web-api/src/lambdas/cases/serveCaseToIrsLambda.ts +++ b/web-api/src/lambdas/cases/serveCaseToIrsLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,16 +7,18 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const serveCaseToIrsLambda = event => +export const serveCaseToIrsLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .serveCaseToIrsInteractor(applicationContext, { + return await applicationContext.getUseCases().serveCaseToIrsInteractor( + applicationContext, + { ...event.pathParameters, ...JSON.parse(event.body), - }); + }, + authorizedUser, + ); }, { logResults: false }, ); From a4068b7b3695f804aab225591a566b389577ee8a Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 12:53:58 -0700 Subject: [PATCH 322/523] 10417: remove appcontext.getCurrentUser from associatePrivatePractitionerWithCaseInteractor --- ...vatePractitionerWithCaseInteractor.test.ts | 32 ++++++++++++------- ...tePrivatePractitionerWithCaseInteractor.ts | 10 +++--- ...ociatePrivatePractitionerWithCaseLambda.ts | 22 +++++++------ 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.test.ts b/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.test.ts index 247075bb2e4..7b8808b07c2 100644 --- a/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.test.ts +++ b/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.test.ts @@ -5,6 +5,7 @@ import { PARTY_TYPES, ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { associatePrivatePractitionerWithCaseInteractor } from './associatePrivatePractitionerWithCaseInteractor'; @@ -50,19 +51,24 @@ describe('associatePrivatePractitionerWithCaseInteractor', () => { it('should throw an error when not authorized', async () => { await expect( - associatePrivatePractitionerWithCaseInteractor(applicationContext, { - docketNumber: caseRecord.docketNumber, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - } as any), + associatePrivatePractitionerWithCaseInteractor( + applicationContext, + { + docketNumber: caseRecord.docketNumber, + userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + } as any, + {} as UnknownAuthUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should add mapping for a practitioner', async () => { - applicationContext.getCurrentUser.mockReturnValue({ + let mockUser = { + email: 'emmet.brown@example.com', name: 'Emmett Lathrop "Doc" Brown, Ph.D.', role: ROLES.adc, userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); + }; applicationContext .getPersistenceGateway() .getUserById.mockImplementation(() => { @@ -81,11 +87,15 @@ describe('associatePrivatePractitionerWithCaseInteractor', () => { .getPersistenceGateway() .verifyCaseForUser.mockReturnValue(false); - await associatePrivatePractitionerWithCaseInteractor(applicationContext, { - docketNumber: caseRecord.docketNumber, - representing: [caseRecord.petitioners[0].contactId], - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - } as any); + await associatePrivatePractitionerWithCaseInteractor( + applicationContext, + { + docketNumber: caseRecord.docketNumber, + representing: [caseRecord.petitioners[0].contactId], + userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', + } as any, + mockUser, + ); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations, diff --git a/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts b/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts index 9a088e52f2e..0ee9e45767f 100644 --- a/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts +++ b/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { associatePrivatePractitionerToCase } from '../../useCaseHelper/caseAssociation/associatePrivatePractitionerToCase'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -30,25 +31,26 @@ export const associatePrivatePractitionerWithCase = async ( serviceIndicator: string; userId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const authenticatedUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(authenticatedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ASSOCIATE_USER_WITH_CASE) ) { throw new UnauthorizedError('Unauthorized'); } + // TODO 10417: type for practitioner lookup is wrong here const user = await applicationContext .getPersistenceGateway() .getUserById({ applicationContext, userId }); return await associatePrivatePractitionerToCase({ applicationContext, - authorizedUser: authenticatedUser, + authorizedUser, docketNumber, representing, serviceIndicator, + //@ts-ignore 10417: fix typing in future update user, }); }; diff --git a/web-api/src/lambdas/manualAssociation/associatePrivatePractitionerWithCaseLambda.ts b/web-api/src/lambdas/manualAssociation/associatePrivatePractitionerWithCaseLambda.ts index 2fb4fdead18..f38edd3b897 100644 --- a/web-api/src/lambdas/manualAssociation/associatePrivatePractitionerWithCaseLambda.ts +++ b/web-api/src/lambdas/manualAssociation/associatePrivatePractitionerWithCaseLambda.ts @@ -1,16 +1,18 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * associate practitioner with case - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const associatePrivatePractitionerWithCaseLambda = event => +export const associatePrivatePractitionerWithCaseLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .associatePrivatePractitionerWithCaseInteractor(applicationContext, { - ...JSON.parse(event.body), - }); + .associatePrivatePractitionerWithCaseInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); From 8adaf2058b4e081572838639c914d004f470eb44 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 14:56:52 -0500 Subject: [PATCH 323/523] 10417 remove getCurrentUser from getPracitionersByNameInteractor --- .../getPractitionersByNameInteractor.test.ts | 9 +++++++++ .../getPractitionersByNameInteractor.ts | 7 ++++--- .../getPractitionersByNameLambda.ts | 18 +++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.test.ts b/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.test.ts index ce19ea02ee5..3db48d6dd7a 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.test.ts @@ -1,6 +1,10 @@ import { ROLES } from '@shared/business/entities/EntityConstants'; import { applicationContext } from '@shared/business/test/createTestApplicationContext'; import { getPractitionersByNameInteractor } from './getPractitionersByNameInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getPractitionersByNameInteractor', () => { describe('Logged in User', () => { @@ -21,6 +25,7 @@ describe('getPractitionersByNameInteractor', () => { getPractitionersByNameInteractor( applicationContext, {} as { name: string; searchAfter: string }, + mockPetitionerUser, ), ).rejects.toThrow('Unauthorized for searching practitioners'); }); @@ -30,6 +35,7 @@ describe('getPractitionersByNameInteractor', () => { getPractitionersByNameInteractor( applicationContext, {} as { name: string; searchAfter: string }, + mockPetitionsClerkUser, ), ).rejects.toThrow('Name must be provided to search'); }); @@ -64,6 +70,7 @@ describe('getPractitionersByNameInteractor', () => { name: 'Test Practitioner', searchAfter: undefined as unknown as string, }, + mockPetitionsClerkUser, ); expect(results).toMatchObject({ @@ -124,6 +131,7 @@ describe('getPractitionersByNameInteractor', () => { name: 'Test Practitioner', searchAfter: undefined as unknown as string, }, + mockPetitionsClerkUser, ); expect(results).toBeDefined(); @@ -136,6 +144,7 @@ describe('getPractitionersByNameInteractor', () => { name: 'Test Practitioner', searchAfter: undefined as unknown as string, }, + undefined, ); expect(results).toMatchObject({ diff --git a/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.ts b/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.ts index 96306f21023..36fd3bf93d2 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.ts @@ -4,6 +4,7 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export type PractitionersByName = { searchResults: { @@ -26,13 +27,13 @@ export type PractitionersByName = { export const getPractitionersByNameInteractor = async ( applicationContext: ServerApplicationContext, { name, searchAfter }: { name: string; searchAfter: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authenticatedUser = applicationContext.getCurrentUser(); - const isLoggedInUser = !!authenticatedUser?.userId; + const isLoggedInUser = !!authorizedUser?.userId; if ( isLoggedInUser && - !isAuthorized(authenticatedUser, ROLE_PERMISSIONS.MANAGE_PRACTITIONER_USERS) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.MANAGE_PRACTITIONER_USERS) ) { throw new UnauthorizedError('Unauthorized for searching practitioners'); } diff --git a/web-api/src/lambdas/practitioners/getPractitionersByNameLambda.ts b/web-api/src/lambdas/practitioners/getPractitionersByNameLambda.ts index ed41b853ac9..d5a6dde93f6 100644 --- a/web-api/src/lambdas/practitioners/getPractitionersByNameLambda.ts +++ b/web-api/src/lambdas/practitioners/getPractitionersByNameLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,14 +7,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getPractitionersByNameLambda = event => +export const getPractitionersByNameLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { name, searchAfter } = event.queryStringParameters; return await applicationContext .getUseCases() - .getPractitionersByNameInteractor(applicationContext, { - name, - searchAfter, - }); + .getPractitionersByNameInteractor( + applicationContext, + { + name, + searchAfter, + }, + authorizedUser, + ); }); From c23952b6a627d9658bf4e2524f49146bb27c3728 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:03:21 -0500 Subject: [PATCH 324/523] 10417 remove getCurrentUser from getPractitionerDocumentInteractor --- .../getPractitionerDocumentInteractor.test.ts | 22 +++++++++++-------- .../getPractitionerDocumentInteractor.ts | 8 ++++--- .../getPractitionerDocumentLambda.ts | 12 +++++----- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.test.ts b/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.test.ts index 0c100a87866..eb310dc3e0e 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.test.ts @@ -5,12 +5,12 @@ import { import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getPractitionerDocumentInteractor } from './getPractitionerDocumentInteractor'; +import { + mockAdmissionsClerkUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getPractitionerDocumentInteractor', () => { - const testUser = { - role: ROLES.admissionsClerk, - userId: 'admissionsclerk', - }; const barNumber = 'PT4785'; const practitionerDocumentFileId = '14c373ff-3335-400d-8b39-3e4053072512'; const practitionerDocument = { @@ -20,7 +20,6 @@ describe('getPractitionerDocumentInteractor', () => { }; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(testUser); applicationContext .getPersistenceGateway() .getPractitionerDocumentByFileId.mockReturnValue(practitionerDocument); @@ -34,10 +33,14 @@ describe('getPractitionerDocumentInteractor', () => { applicationContext.getCurrentUser.mockReturnValueOnce(testPetitionerUser); await expect( - getPractitionerDocumentInteractor(applicationContext, { - barNumber, - practitionerDocumentFileId, - }), + getPractitionerDocumentInteractor( + applicationContext, + { + barNumber, + practitionerDocumentFileId, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -48,6 +51,7 @@ describe('getPractitionerDocumentInteractor', () => { barNumber, practitionerDocumentFileId, }, + mockAdmissionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.ts b/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.ts index 02ebaaef34f..2ad52fe141f 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * @@ -23,10 +24,11 @@ export const getPractitionerDocumentInteractor = async ( barNumber: string; practitionerDocumentFileId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) + ) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/practitioners/getPractitionerDocumentLambda.ts b/web-api/src/lambdas/practitioners/getPractitionerDocumentLambda.ts index 9d158b3bfa5..57e8d76d619 100644 --- a/web-api/src/lambdas/practitioners/getPractitionerDocumentLambda.ts +++ b/web-api/src/lambdas/practitioners/getPractitionerDocumentLambda.ts @@ -6,13 +6,15 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getPractitionerDocumentLambda = event => +export const getPractitionerDocumentLambda = (event, authorizedUser) => genericHandler(event, ({ applicationContext }) => { - return applicationContext - .getUseCases() - .getPractitionerDocumentInteractor(applicationContext, { + return applicationContext.getUseCases().getPractitionerDocumentInteractor( + applicationContext, + { barNumber: event.pathParameters.barNumber, practitionerDocumentFileId: event.pathParameters.practitionerDocumentFileId, - }); + }, + authorizedUser, + ); }); From c4452a0c3819b89fc00bd21c77043435a4042d7d Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:05:55 -0500 Subject: [PATCH 325/523] 10417 remove getCurrentUser from getPractitionerDocumentDownloadInteractor --- ...ionerDocumentDownloadUrlInteractor.test.ts | 35 ++++++++----------- ...actitionerDocumentDownloadUrlInteractor.ts | 8 +++-- ...etPractitionerDocumentDownloadUrlLambda.ts | 20 +++++++---- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/getPractitionerDocumentDownloadUrlInteractor.test.ts b/web-api/src/business/useCases/practitioner/getPractitionerDocumentDownloadUrlInteractor.test.ts index 22b4a42c4b4..1b420312181 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerDocumentDownloadUrlInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerDocumentDownloadUrlInteractor.test.ts @@ -1,10 +1,12 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getPractitionerDocumentDownloadUrlInteractor } from './getPractitionerDocumentDownloadUrlInteractor'; +import { + mockAdmissionsClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('getPractitionerDocumentDownloadUrlInteractor', () => { - let testUser; const mockDocumentMetadata = { categoryName: 'Application', categoryType: 'Application', @@ -25,30 +27,20 @@ describe('getPractitionerDocumentDownloadUrlInteractor', () => { }); it('should throw an unauthorized error when the user does not have permission to download the practitioner documentation file', async () => { - testUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - - applicationContext.getCurrentUser.mockImplementation(() => testUser); - await expect( - getPractitionerDocumentDownloadUrlInteractor(applicationContext, { - barNumber: mockPractitioner.barNumber, - practitionerDocumentFileId: - mockDocumentMetadata.practitionerDocumentFileId, - }), + getPractitionerDocumentDownloadUrlInteractor( + applicationContext, + { + barNumber: mockPractitioner.barNumber, + practitionerDocumentFileId: + mockDocumentMetadata.practitionerDocumentFileId, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should not throw an unauthorized error when the user has permission to download the practitioner documentation file', async () => { - testUser = { - role: ROLES.admissionsClerk, - userId: 'admissionsclerk', - }; - - applicationContext.getCurrentUser.mockImplementation(() => testUser); - const results = await getPractitionerDocumentDownloadUrlInteractor( applicationContext, { @@ -56,6 +48,7 @@ describe('getPractitionerDocumentDownloadUrlInteractor', () => { practitionerDocumentFileId: mockDocumentMetadata.practitionerDocumentFileId, }, + mockAdmissionsClerkUser, ); expect(results).toMatchObject({ url: expect.any(String), diff --git a/web-api/src/business/useCases/practitioner/getPractitionerDocumentDownloadUrlInteractor.ts b/web-api/src/business/useCases/practitioner/getPractitionerDocumentDownloadUrlInteractor.ts index e9bcf09ec7b..77f15ac7e51 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerDocumentDownloadUrlInteractor.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerDocumentDownloadUrlInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * @@ -21,10 +22,11 @@ export const getPractitionerDocumentDownloadUrlInteractor = async ( barNumber: string; practitionerDocumentFileId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) + ) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/practitioners/getPractitionerDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/practitioners/getPractitionerDocumentDownloadUrlLambda.ts index dffd120dfc6..ab0014ebe0e 100644 --- a/web-api/src/lambdas/practitioners/getPractitionerDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/practitioners/getPractitionerDocumentDownloadUrlLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getPractitionerDocumentDownloadUrlLambda = event => +export const getPractitionerDocumentDownloadUrlLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, ({ applicationContext }) => { return applicationContext .getUseCases() - .getPractitionerDocumentDownloadUrlInteractor(applicationContext, { - barNumber: event.pathParameters.barNumber, - practitionerDocumentFileId: - event.pathParameters.practitionerDocumentFileId, - }); + .getPractitionerDocumentDownloadUrlInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + practitionerDocumentFileId: + event.pathParameters.practitionerDocumentFileId, + }, + authorizedUser, + ); }); From 7f43d4792928997f05f3b165a0830d90ff9f4566 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:08:41 -0500 Subject: [PATCH 326/523] 10417 remove getCurrentUser from editPractitionerDocumentInteractor --- ...editPractitionerDocumentInteractor.test.ts | 56 ++++++++++--------- .../editPractitionerDocumentInteractor.ts | 6 +- .../editPractitionerDocumentLambda.ts | 18 ++++-- 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/editPractitionerDocumentInteractor.test.ts b/web-api/src/business/useCases/practitioner/editPractitionerDocumentInteractor.test.ts index ac036f4974a..c217a71ec0c 100644 --- a/web-api/src/business/useCases/practitioner/editPractitionerDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/editPractitionerDocumentInteractor.test.ts @@ -1,13 +1,12 @@ import { InvalidEntityError, UnauthorizedError } from '@web-api/errors/errors'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { editPractitionerDocumentInteractor } from './editPractitionerDocumentInteractor'; +import { + mockAdmissionsClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('editPractitionerDocumentInteractor', () => { - const testUser = { - role: ROLES.admissionsClerk, - userId: 'admissionsclerk', - }; const barNumber = 'PT4785'; const mockDocumentMetadata = { categoryName: 'Application', @@ -18,40 +17,42 @@ describe('editPractitionerDocumentInteractor', () => { practitionerDocumentFileId: 'ad69486a-2489-4eb1-bee6-bdb6cc0257b4', } as any; - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(testUser); - }); - it('should throw an unauthorized error when the user does not have permission to update the practitioner user', async () => { - const testPetitionerUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - applicationContext.getCurrentUser.mockReturnValueOnce(testPetitionerUser); - await expect( - editPractitionerDocumentInteractor(applicationContext, { - barNumber, - documentMetadata: mockDocumentMetadata, - }), + editPractitionerDocumentInteractor( + applicationContext, + { + barNumber, + documentMetadata: mockDocumentMetadata, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should throw a validation error if the practitioner document has the wrong type', async () => { await expect( - editPractitionerDocumentInteractor(applicationContext, { - barNumber, - documentMetadata: { ...mockDocumentMetadata, categoryType: 'GG' }, - }), + editPractitionerDocumentInteractor( + applicationContext, + { + barNumber, + documentMetadata: { ...mockDocumentMetadata, categoryType: 'GG' }, + }, + mockAdmissionsClerkUser, + ), ).rejects.toThrow(InvalidEntityError); }); it('should throw a validation error if the practitioner document is missing information', async () => { await expect( - editPractitionerDocumentInteractor(applicationContext, { - barNumber, - documentMetadata: { ...mockDocumentMetadata, fileName: undefined }, - }), + editPractitionerDocumentInteractor( + applicationContext, + { + barNumber, + documentMetadata: { ...mockDocumentMetadata, fileName: undefined }, + }, + mockAdmissionsClerkUser, + ), ).rejects.toThrow(InvalidEntityError); }); @@ -62,6 +63,7 @@ describe('editPractitionerDocumentInteractor', () => { barNumber, documentMetadata: mockDocumentMetadata, }, + mockAdmissionsClerkUser, ); expect(results).toMatchObject({ ...mockDocumentMetadata }); }); diff --git a/web-api/src/business/useCases/practitioner/editPractitionerDocumentInteractor.ts b/web-api/src/business/useCases/practitioner/editPractitionerDocumentInteractor.ts index 7cce99ab64e..9ec5ba628b9 100644 --- a/web-api/src/business/useCases/practitioner/editPractitionerDocumentInteractor.ts +++ b/web-api/src/business/useCases/practitioner/editPractitionerDocumentInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * editPractitionerDocumentInteractor @@ -31,11 +32,10 @@ export const editPractitionerDocumentInteractor = async ( uploadDate: string; }; }, + authorizedUser: UnknownAuthUser, ) => { - const requestUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(requestUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) ) { throw new UnauthorizedError('Unauthorized for creating practitioner user'); } diff --git a/web-api/src/lambdas/practitioners/editPractitionerDocumentLambda.ts b/web-api/src/lambdas/practitioners/editPractitionerDocumentLambda.ts index 85018ccf9bc..288d114e5e1 100644 --- a/web-api/src/lambdas/practitioners/editPractitionerDocumentLambda.ts +++ b/web-api/src/lambdas/practitioners/editPractitionerDocumentLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +7,19 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const editPractitionerDocumentLambda = event => +export const editPractitionerDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .editPractitionerDocumentInteractor(applicationContext, { - barNumber: event.pathParameters.barNumber, - documentMetadata: JSON.parse(event.body), - }); + .editPractitionerDocumentInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + documentMetadata: JSON.parse(event.body), + }, + authorizedUser, + ); }); From 34ee7f1b53c7ed2ca70da3d1910cb6a384d334a2 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:11:56 -0500 Subject: [PATCH 327/523] 10417 remove getCurrentUser from deletePractitionerDocumentInteractor --- ...letePractitionerDocumentInteractor.test.ts | 55 ++++++++++--------- .../deletePractitionerDocumentInteractor.ts | 6 +- .../deletePractitionerDocumentLambda.ts | 20 +++++-- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/deletePractitionerDocumentInteractor.test.ts b/web-api/src/business/useCases/practitioner/deletePractitionerDocumentInteractor.test.ts index 47642352804..41a3d0d9f87 100644 --- a/web-api/src/business/useCases/practitioner/deletePractitionerDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/deletePractitionerDocumentInteractor.test.ts @@ -1,40 +1,37 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { deletePractitionerDocumentInteractor } from './deletePractitionerDocumentInteractor'; +import { + mockAdmissionsClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('deletePractitionerDocumentInteractor', () => { - const testUser = { - role: ROLES.admissionsClerk, - userId: 'admissionsclerk', - }; const practitionerDocumentFileId = '3da3e303-5da9-4b8b-99a5-d4b65c449619'; const barNumber = 'PT76543'; - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(testUser); - }); - it('should throw an unauthorized error when the user does not have permission to update practitioner documents', async () => { - const testPetitionerUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - applicationContext.getCurrentUser.mockReturnValueOnce(testPetitionerUser); - await expect( - deletePractitionerDocumentInteractor(applicationContext, { - barNumber, - practitionerDocumentFileId, - }), + deletePractitionerDocumentInteractor( + applicationContext, + { + barNumber, + practitionerDocumentFileId, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should delete the practitioner document from persistence', async () => { - await deletePractitionerDocumentInteractor(applicationContext, { - barNumber, - practitionerDocumentFileId, - }); + await deletePractitionerDocumentInteractor( + applicationContext, + { + barNumber, + practitionerDocumentFileId, + }, + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().deleteDocumentFile.mock .calls[0][0], @@ -44,10 +41,14 @@ describe('deletePractitionerDocumentInteractor', () => { }); it('should delete the practitioner document from the DB', async () => { - await deletePractitionerDocumentInteractor(applicationContext, { - barNumber, - practitionerDocumentFileId, - }); + await deletePractitionerDocumentInteractor( + applicationContext, + { + barNumber, + practitionerDocumentFileId, + }, + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().deletePractitionerDocument.mock .calls[0][0], diff --git a/web-api/src/business/useCases/practitioner/deletePractitionerDocumentInteractor.ts b/web-api/src/business/useCases/practitioner/deletePractitionerDocumentInteractor.ts index 662d9508a4c..a77dd2e1ba1 100644 --- a/web-api/src/business/useCases/practitioner/deletePractitionerDocumentInteractor.ts +++ b/web-api/src/business/useCases/practitioner/deletePractitionerDocumentInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * deletePractitionerDocumentInteractor @@ -22,11 +23,10 @@ export const deletePractitionerDocumentInteractor = async ( barNumber: string; practitionerDocumentFileId: string; }, + authorizedUser: UnknownAuthUser, ) => { - const requestUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(requestUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) ) { throw new UnauthorizedError( 'Unauthorized for deleting practitioner documents', diff --git a/web-api/src/lambdas/practitioners/deletePractitionerDocumentLambda.ts b/web-api/src/lambdas/practitioners/deletePractitionerDocumentLambda.ts index afb3a0942c8..40a117bbb88 100644 --- a/web-api/src/lambdas/practitioners/deletePractitionerDocumentLambda.ts +++ b/web-api/src/lambdas/practitioners/deletePractitionerDocumentLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -6,13 +7,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const deletePractitionerDocumentLambda = event => +export const deletePractitionerDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .deletePractitionerDocumentInteractor(applicationContext, { - barNumber: event.pathParameters.barNumber, - practitionerDocumentFileId: - event.pathParameters.practitionerDocumentFileId, - }); + .deletePractitionerDocumentInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + practitionerDocumentFileId: + event.pathParameters.practitionerDocumentFileId, + }, + authorizedUser, + ); }); From 095e12562fe2f17c5395db47621320ecb814c787 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 13:15:06 -0700 Subject: [PATCH 328/523] 10417: remove appcontext.getCurrentUser from completeMessageInteractor --- .../completeMessageInteractor.test.ts | 85 +++++++++++-------- .../messages/completeMessageInteractor.ts | 6 +- .../lambdas/messages/completeMessageLambda.ts | 9 +- 3 files changed, 59 insertions(+), 41 deletions(-) diff --git a/web-api/src/business/useCases/messages/completeMessageInteractor.test.ts b/web-api/src/business/useCases/messages/completeMessageInteractor.test.ts index 4940b11bb28..a8aa9cb652a 100644 --- a/web-api/src/business/useCases/messages/completeMessageInteractor.test.ts +++ b/web-api/src/business/useCases/messages/completeMessageInteractor.test.ts @@ -6,6 +6,10 @@ import { import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { completeMessageInteractor } from './completeMessageInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('completeMessageInteractor', () => { const mockMessages = [ @@ -52,10 +56,6 @@ describe('completeMessageInteractor', () => { const PARENT_MESSAGE_ID_2 = '4782edfe-618b-4315-9619-675403246bce'; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ name: 'Test Petitionsclerk', role: ROLES.petitionsClerk, @@ -74,28 +74,31 @@ describe('completeMessageInteractor', () => { }); it('should throw unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - completeMessageInteractor(applicationContext, { - messages: [{ messageBody: 'hi', parentMessageId: '123' }], - }), + completeMessageInteractor( + applicationContext, + { + messages: [{ messageBody: 'hi', parentMessageId: '123' }], + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should call persistence methods to mark the thread as replied to and complete the most recent messages', async () => { - await completeMessageInteractor(applicationContext, { - messages: [ - { - messageBody: 'the completed message', - parentMessageId: PARENT_MESSAGE_ID_1, - }, - { messageBody: 'hi', parentMessageId: PARENT_MESSAGE_ID_2 }, - ], - }); + await completeMessageInteractor( + applicationContext, + { + messages: [ + { + messageBody: 'the completed message', + parentMessageId: PARENT_MESSAGE_ID_1, + }, + { messageBody: 'hi', parentMessageId: PARENT_MESSAGE_ID_2 }, + ], + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().markMessageThreadRepliedTo, @@ -132,14 +135,18 @@ describe('completeMessageInteractor', () => { }); it('should send a success message to the user', async () => { - await completeMessageInteractor(applicationContext, { - messages: [ - { - messageBody: 'the completed message', - parentMessageId: PARENT_MESSAGE_ID_1, - }, - ], - }); + await completeMessageInteractor( + applicationContext, + { + messages: [ + { + messageBody: 'the completed message', + parentMessageId: PARENT_MESSAGE_ID_1, + }, + ], + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -153,14 +160,18 @@ describe('completeMessageInteractor', () => { applicationContext .getPersistenceGateway() .updateMessage.mockRejectedValueOnce(new Error('Bad!')); - await completeMessageInteractor(applicationContext, { - messages: [ - { - messageBody: 'the completed message', - parentMessageId: PARENT_MESSAGE_ID_1, - }, - ], - }); + await completeMessageInteractor( + applicationContext, + { + messages: [ + { + messageBody: 'the completed message', + parentMessageId: PARENT_MESSAGE_ID_1, + }, + ], + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, diff --git a/web-api/src/business/useCases/messages/completeMessageInteractor.ts b/web-api/src/business/useCases/messages/completeMessageInteractor.ts index b7755e4f21e..9265133633b 100644 --- a/web-api/src/business/useCases/messages/completeMessageInteractor.ts +++ b/web-api/src/business/useCases/messages/completeMessageInteractor.ts @@ -5,6 +5,7 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { orderBy } from 'lodash'; export const completeMessageInteractor = async ( @@ -12,9 +13,8 @@ export const completeMessageInteractor = async ( { messages, }: { messages: { messageBody: string; parentMessageId: string }[] }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.SEND_RECEIVE_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } @@ -47,6 +47,8 @@ export const completeMessageInteractor = async ( applicationContext, }).validate(); + // TODO 10417: fix typing for call to markAsCompleted + // @ts-ignore fix typing for call to markAsCompleted updatedMessage.markAsCompleted({ message: message.messageBody, user }); const validatedRawMessage = updatedMessage.validate().toRawObject(); diff --git a/web-api/src/lambdas/messages/completeMessageLambda.ts b/web-api/src/lambdas/messages/completeMessageLambda.ts index f75653af303..ec6c98805ef 100644 --- a/web-api/src/lambdas/messages/completeMessageLambda.ts +++ b/web-api/src/lambdas/messages/completeMessageLambda.ts @@ -1,4 +1,5 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; /** @@ -7,7 +8,7 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const completeMessageLambda = event => +export const completeMessageLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler( event, async ({ @@ -17,6 +18,10 @@ export const completeMessageLambda = event => }) => { return await applicationContext .getUseCases() - .completeMessageInteractor(applicationContext, JSON.parse(event.body)); + .completeMessageInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); }, ); From a785d381cb842f99057ce099bd77e003028fb37c Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:16:39 -0500 Subject: [PATCH 329/523] 10417 remove getCurrentUser from createPractitionerUserInteractor --- .../createPractitionerUserInteractor.test.ts | 33 ++++++++++++------- .../createPractitionerUserInteractor.ts | 8 +++-- .../createPractitionerUserLambda.ts | 17 +++++++--- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/createPractitionerUserInteractor.test.ts b/web-api/src/business/useCases/practitioner/createPractitionerUserInteractor.test.ts index e67b01f28de..7d9cd3b5e59 100644 --- a/web-api/src/business/useCases/practitioner/createPractitionerUserInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/createPractitionerUserInteractor.test.ts @@ -4,9 +4,12 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { RawPractitioner } from '@shared/business/entities/Practitioner'; import { UnauthorizedError } from '@web-api/errors/errors'; -import { admissionsClerkUser, petitionerUser } from '@shared/test/mockUsers'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createPractitionerUserInteractor } from './createPractitionerUserInteractor'; +import { + mockAdmissionsClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('createPractitionerUserInteractor', () => { const mockUser: RawPractitioner = { @@ -28,19 +31,20 @@ describe('createPractitionerUserInteractor', () => { }; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(admissionsClerkUser); applicationContext .getPersistenceGateway() .createOrUpdatePractitionerUser.mockResolvedValue(mockUser); }); it('should throw an error when the user is unauthorized to create a practitioner user', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - await expect( - createPractitionerUserInteractor(applicationContext, { - user: mockUser, - }), + createPractitionerUserInteractor( + applicationContext, + { + user: mockUser, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -50,6 +54,7 @@ describe('createPractitionerUserInteractor', () => { { user: mockUser, }, + mockAdmissionsClerkUser, ); expect(barNumber).toEqual(mockUser.barNumber); @@ -58,12 +63,16 @@ describe('createPractitionerUserInteractor', () => { it('should set practitioner.pendingEmail to practitioner.email and set practitioner.email to undefined', async () => { const mockEmail = 'testing@example.com'; - await createPractitionerUserInteractor(applicationContext, { - user: { - ...mockUser, - email: mockEmail, + await createPractitionerUserInteractor( + applicationContext, + { + user: { + ...mockUser, + email: mockEmail, + }, }, - }); + mockAdmissionsClerkUser, + ); const mockUserCall = applicationContext.getPersistenceGateway().createOrUpdatePractitionerUser diff --git a/web-api/src/business/useCases/practitioner/createPractitionerUserInteractor.ts b/web-api/src/business/useCases/practitioner/createPractitionerUserInteractor.ts index 42bda73d028..12877296336 100644 --- a/web-api/src/business/useCases/practitioner/createPractitionerUserInteractor.ts +++ b/web-api/src/business/useCases/practitioner/createPractitionerUserInteractor.ts @@ -5,15 +5,17 @@ import { import { RawPractitioner } from '../../../../../shared/src/business/entities/Practitioner'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createPractitionerUser } from '../../../../../shared/src/business/utilities/createPractitionerUser'; export const createPractitionerUserInteractor = async ( applicationContext: ServerApplicationContext, { user }: { user: RawPractitioner }, + authorizedUser: UnknownAuthUser, ): Promise<{ barNumber: string }> => { - const requestUser = applicationContext.getCurrentUser(); - - if (!isAuthorized(requestUser, ROLE_PERMISSIONS.ADD_EDIT_PRACTITIONER_USER)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.ADD_EDIT_PRACTITIONER_USER) + ) { throw new UnauthorizedError('Unauthorized for creating practitioner user'); } diff --git a/web-api/src/lambdas/practitioners/createPractitionerUserLambda.ts b/web-api/src/lambdas/practitioners/createPractitionerUserLambda.ts index e73ed496894..3f76a324cfc 100644 --- a/web-api/src/lambdas/practitioners/createPractitionerUserLambda.ts +++ b/web-api/src/lambdas/practitioners/createPractitionerUserLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { createPractitionerUserInteractor } from '@web-api/business/useCases/practitioner/createPractitionerUserInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +8,16 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const createPractitionerUserLambda = event => +export const createPractitionerUserLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createPractitionerUserInteractor(applicationContext, { + return await createPractitionerUserInteractor( + applicationContext, + { user: JSON.parse(event.body).user, - }); + }, + authorizedUser, + ); }); From 03e4d4f0bca51d119c3985a6bc52df40f84527c1 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 13:20:19 -0700 Subject: [PATCH 330/523] 10417: remove appcontext.getCurrentUser from createMessageInteractor --- .../messages/createMessageInteractor.test.ts | 45 ++++++++++--------- .../messages/createMessageInteractor.ts | 4 +- .../lambdas/messages/createMessageLambda.ts | 19 ++++---- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/web-api/src/business/useCases/messages/createMessageInteractor.test.ts b/web-api/src/business/useCases/messages/createMessageInteractor.test.ts index 7ee899f0d9c..c5fcbe2e0b4 100644 --- a/web-api/src/business/useCases/messages/createMessageInteractor.test.ts +++ b/web-api/src/business/useCases/messages/createMessageInteractor.test.ts @@ -7,23 +7,26 @@ import { import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createMessageInteractor } from './createMessageInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('createMessageInteractor', () => { it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - createMessageInteractor(applicationContext, { - attachments: [], - docketNumber: '101-20', - message: 'hello world', - subject: 'what is up', - toSection: DOCKET_SECTION, - toUserId: 'abc', - }), + createMessageInteractor( + applicationContext, + { + attachments: [], + docketNumber: '101-20', + message: 'hello world', + subject: 'what is up', + toSection: DOCKET_SECTION, + toUserId: 'abc', + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -45,10 +48,6 @@ describe('createMessageInteractor', () => { toSection: PETITIONS_SECTION, toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getUserById.mockReturnValueOnce({ @@ -72,10 +71,14 @@ describe('createMessageInteractor', () => { status: CASE_STATUS_TYPES.generalDocket, }); - await createMessageInteractor(applicationContext, { - ...messageData, - attachments: mockAttachments, - }); + await createMessageInteractor( + applicationContext, + { + ...messageData, + attachments: mockAttachments, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createMessage, diff --git a/web-api/src/business/useCases/messages/createMessageInteractor.ts b/web-api/src/business/useCases/messages/createMessageInteractor.ts index ae1ea236b8d..c3f8da961f7 100644 --- a/web-api/src/business/useCases/messages/createMessageInteractor.ts +++ b/web-api/src/business/useCases/messages/createMessageInteractor.ts @@ -9,6 +9,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export type MessageType = { attachments: { @@ -39,9 +40,8 @@ export const createMessageInteractor = async ( toSection, toUserId, }: MessageWithMetaData, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.SEND_RECEIVE_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/createMessageLambda.ts b/web-api/src/lambdas/messages/createMessageLambda.ts index 1c6d0c9dc7e..b7c7a4aa777 100644 --- a/web-api/src/lambdas/messages/createMessageLambda.ts +++ b/web-api/src/lambdas/messages/createMessageLambda.ts @@ -1,16 +1,13 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * lambda which is used for creating a new message - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const createMessageLambda = event => +export const createMessageLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createMessageInteractor(applicationContext, { + return await applicationContext.getUseCases().createMessageInteractor( + applicationContext, + { ...JSON.parse(event.body), - }); + }, + authorizedUser, + ); }); From 43271b69ee05e3ddd10f3ca028af6737e7fb76be Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 13:24:30 -0700 Subject: [PATCH 331/523] 10417: remove appcontext.getCurrentUser from getCompletedMessagesForUserInteractor --- ...CompletedMessagesForUserInteractor.test.ts | 25 +++++++++---------- .../getCompletedMessagesForUserInteractor.ts | 12 ++------- .../getCompletedMessagesForUserLambda.ts | 22 ++++++++-------- 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/web-api/src/business/useCases/messages/getCompletedMessagesForUserInteractor.test.ts b/web-api/src/business/useCases/messages/getCompletedMessagesForUserInteractor.test.ts index 503b4c3e2e9..2901e264ac8 100644 --- a/web-api/src/business/useCases/messages/getCompletedMessagesForUserInteractor.test.ts +++ b/web-api/src/business/useCases/messages/getCompletedMessagesForUserInteractor.test.ts @@ -1,24 +1,26 @@ import { CASE_STATUS_TYPES, PETITIONS_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getCompletedMessagesForUserInteractor } from './getCompletedMessagesForUserInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('getCompletedMessagesForUserInteractor', () => { it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - getCompletedMessagesForUserInteractor(applicationContext, { - userId: 'abc', - }), + getCompletedMessagesForUserInteractor( + applicationContext, + { + userId: 'abc', + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -50,10 +52,6 @@ describe('getCompletedMessagesForUserInteractor', () => { toSection: PETITIONS_SECTION, toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getCompletedUserInboxMessages.mockReturnValue([messageData]); @@ -63,6 +61,7 @@ describe('getCompletedMessagesForUserInteractor', () => { { userId: messageData.completedByUserId, }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/messages/getCompletedMessagesForUserInteractor.ts b/web-api/src/business/useCases/messages/getCompletedMessagesForUserInteractor.ts index 540bb1ae2eb..63f134695cd 100644 --- a/web-api/src/business/useCases/messages/getCompletedMessagesForUserInteractor.ts +++ b/web-api/src/business/useCases/messages/getCompletedMessagesForUserInteractor.ts @@ -5,21 +5,13 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * getCompletedMessagesForUserInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.userId the user to get the inbox messages - * @returns {object} the messages in the user inbox - */ export const getCompletedMessagesForUserInteractor = async ( applicationContext: ServerApplicationContext, { userId }: { userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/getCompletedMessagesForUserLambda.ts b/web-api/src/lambdas/messages/getCompletedMessagesForUserLambda.ts index 4c36d8429eb..3474600460e 100644 --- a/web-api/src/lambdas/messages/getCompletedMessagesForUserLambda.ts +++ b/web-api/src/lambdas/messages/getCompletedMessagesForUserLambda.ts @@ -1,16 +1,18 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * gets the completed messages for the user - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const getCompletedMessagesForUserLambda = event => +export const getCompletedMessagesForUserLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getCompletedMessagesForUserInteractor(applicationContext, { - userId: event.pathParameters.userId, - }); + .getCompletedMessagesForUserInteractor( + applicationContext, + { + userId: event.pathParameters.userId, + }, + authorizedUser, + ); }); From 81d1786c88bd5e1620656c7c9fa8f39bbb1616a4 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:19:51 -0500 Subject: [PATCH 332/523] 10417 remove getCurrentUser from createPractitionerDocumentInteractor --- ...eatePractitionerDocumentInteractor.test.ts | 45 +++++++++---------- .../createPractitionerDocumentInteractor.ts | 6 +-- .../createPractitionerDocumentLambda.ts | 17 ++++--- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/createPractitionerDocumentInteractor.test.ts b/web-api/src/business/useCases/practitioner/createPractitionerDocumentInteractor.test.ts index 347051ed778..8327a7faf52 100644 --- a/web-api/src/business/useCases/practitioner/createPractitionerDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/createPractitionerDocumentInteractor.test.ts @@ -1,11 +1,13 @@ import { InvalidEntityError, UnauthorizedError } from '@web-api/errors/errors'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { createPractitionerDocumentInteractor } from './createPractitionerDocumentInteractor'; +import { + mockAdmissionsClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; jest.mock('@web-api/business/useCases/user/generateChangeOfAddress'); describe('updatePractitionerUserInteractor', () => { - let testUser; const mockDocumentMetadata = { categoryName: 'Application', categoryType: 'Application', @@ -15,35 +17,29 @@ describe('updatePractitionerUserInteractor', () => { practitionerDocumentFileId: '07044afe-641b-4d75-a84f-0698870b7650', } as any; - beforeEach(() => { - testUser = { - role: ROLES.admissionsClerk, - userId: 'admissionsclerk', - }; - - applicationContext.getCurrentUser.mockImplementation(() => testUser); - }); - it('should throw an unauthorized error when the user does not have permission to update the practitioner user', async () => { - testUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( - createPractitionerDocumentInteractor(applicationContext, { - barNumber: 'pt1234', - documentMetadata: mockDocumentMetadata, - }), + createPractitionerDocumentInteractor( + applicationContext, + { + barNumber: 'pt1234', + documentMetadata: mockDocumentMetadata, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should throw a validation error if the practitioner document has the wrong type', async () => { await expect( - createPractitionerDocumentInteractor(applicationContext, { - barNumber: 'pt1234', - documentMetadata: { ...mockDocumentMetadata, categoryType: 'GG' }, - }), + createPractitionerDocumentInteractor( + applicationContext, + { + barNumber: 'pt1234', + documentMetadata: { ...mockDocumentMetadata, categoryType: 'GG' }, + }, + mockAdmissionsClerkUser, + ), ).rejects.toThrow(InvalidEntityError); }); @@ -54,6 +50,7 @@ describe('updatePractitionerUserInteractor', () => { barNumber: 'pt1234', documentMetadata: mockDocumentMetadata, }, + mockAdmissionsClerkUser, ); expect(results).toMatchObject({ ...mockDocumentMetadata }); }); diff --git a/web-api/src/business/useCases/practitioner/createPractitionerDocumentInteractor.ts b/web-api/src/business/useCases/practitioner/createPractitionerDocumentInteractor.ts index 7a41567b1a7..f0799eceb66 100644 --- a/web-api/src/business/useCases/practitioner/createPractitionerDocumentInteractor.ts +++ b/web-api/src/business/useCases/practitioner/createPractitionerDocumentInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * createPractitionerDocumentInteractor @@ -30,11 +31,10 @@ export const createPractitionerDocumentInteractor = async ( fileName: string; }; }, + authorizedUser: UnknownAuthUser, ) => { - const requestUser = applicationContext.getCurrentUser(); - if ( - !isAuthorized(requestUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.UPLOAD_PRACTITIONER_DOCUMENT) ) { throw new UnauthorizedError('Unauthorized for creating practitioner user'); } diff --git a/web-api/src/lambdas/practitioners/createPractitionerDocumentLambda.ts b/web-api/src/lambdas/practitioners/createPractitionerDocumentLambda.ts index bef05cb41aa..7a9332e4f71 100644 --- a/web-api/src/lambdas/practitioners/createPractitionerDocumentLambda.ts +++ b/web-api/src/lambdas/practitioners/createPractitionerDocumentLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { createPractitionerDocumentInteractor } from '@web-api/business/useCases/practitioner/createPractitionerDocumentInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,12 +8,17 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const createPractitionerDocumentLambda = event => +export const createPractitionerDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createPractitionerDocumentInteractor(applicationContext, { + return await createPractitionerDocumentInteractor( + applicationContext, + { barNumber: event.pathParameters.barNumber, documentMetadata: JSON.parse(event.body), - }); + }, + authorizedUser, + ); }); From 45686e6df2b080dd8d74ef87098ccaa7f93c69d4 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:25:11 -0500 Subject: [PATCH 333/523] 10417 remove getCurrentUser from startPollingForResultsInteractor --- .../startPollingForResultsInteractor.test.ts | 37 ++++++++++++------- .../startPollingForResultsInteractor.ts | 6 +-- .../polling/startPollingForResultsLambda.ts | 17 ++++++--- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/web-api/src/business/useCases/polling/startPollingForResultsInteractor.test.ts b/web-api/src/business/useCases/polling/startPollingForResultsInteractor.test.ts index d56acd02b26..b8a6da2b515 100644 --- a/web-api/src/business/useCases/polling/startPollingForResultsInteractor.test.ts +++ b/web-api/src/business/useCases/polling/startPollingForResultsInteractor.test.ts @@ -1,4 +1,5 @@ import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { startPollingForResultsInteractor } from '@web-api/business/useCases/polling/startPollingForResultsInteractor'; describe('startPollingForResultsInteractor', () => { @@ -13,22 +14,22 @@ describe('startPollingForResultsInteractor', () => { totalNumberOfChunks: 1, }, ]; - const TEST_USER_ID = 'TEST_USER_ID'; - const TEST_USER = { - userId: TEST_USER_ID, - }; + const TEST_USER_ID = mockDocketClerkUser.userId; beforeEach(() => { - applicationContext.getCurrentUser = jest.fn().mockReturnValue(TEST_USER); applicationContext.getPersistenceGateway().getRequestResults = jest .fn() .mockResolvedValue(MOCKED_RESULTS); }); it('should load poll response', async () => { - const results = await startPollingForResultsInteractor(applicationContext, { - requestId: TEST_REQUEST_ID, - }); + const results = await startPollingForResultsInteractor( + applicationContext, + { + requestId: TEST_REQUEST_ID, + }, + mockDocketClerkUser, + ); const getRequestResultsCalls = applicationContext.getPersistenceGateway().getRequestResults.mock.calls; @@ -47,9 +48,13 @@ describe('startPollingForResultsInteractor', () => { .fn() .mockResolvedValue([]); - const results = await startPollingForResultsInteractor(applicationContext, { - requestId: TEST_REQUEST_ID, - }); + const results = await startPollingForResultsInteractor( + applicationContext, + { + requestId: TEST_REQUEST_ID, + }, + mockDocketClerkUser, + ); const getRequestResultsCalls = applicationContext.getPersistenceGateway().getRequestResults.mock.calls; @@ -74,9 +79,13 @@ describe('startPollingForResultsInteractor', () => { }, ]); - const results = await startPollingForResultsInteractor(applicationContext, { - requestId: TEST_REQUEST_ID, - }); + const results = await startPollingForResultsInteractor( + applicationContext, + { + requestId: TEST_REQUEST_ID, + }, + mockDocketClerkUser, + ); const getRequestResultsCalls = applicationContext.getPersistenceGateway().getRequestResults.mock.calls; diff --git a/web-api/src/business/useCases/polling/startPollingForResultsInteractor.ts b/web-api/src/business/useCases/polling/startPollingForResultsInteractor.ts index 8dc2d7e23b8..2753e3c8463 100644 --- a/web-api/src/business/useCases/polling/startPollingForResultsInteractor.ts +++ b/web-api/src/business/useCases/polling/startPollingForResultsInteractor.ts @@ -1,17 +1,17 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const startPollingForResultsInteractor = async ( applicationContext: ServerApplicationContext, { requestId }: { requestId: string }, + authorizedUser: UnknownAuthUser, ): Promise<{ response: any } | undefined> => { - const user = applicationContext.getCurrentUser(); - const records = await applicationContext .getPersistenceGateway() .getRequestResults({ applicationContext, requestId, - userId: user.userId, + userId: authorizedUser.userId, }); if (records.length === 0) return undefined; diff --git a/web-api/src/lambdas/polling/startPollingForResultsLambda.ts b/web-api/src/lambdas/polling/startPollingForResultsLambda.ts index d00f6f7b3cc..8466556e67c 100644 --- a/web-api/src/lambdas/polling/startPollingForResultsLambda.ts +++ b/web-api/src/lambdas/polling/startPollingForResultsLambda.ts @@ -1,10 +1,17 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { startPollingForResultsInteractor } from '@web-api/business/useCases/polling/startPollingForResultsInteractor'; -export const startPollingForResultsLambda = event => +export const startPollingForResultsLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .startPollingForResultsInteractor(applicationContext, { + return await startPollingForResultsInteractor( + applicationContext, + { ...event.pathParameters, - }); + }, + authorizedUser, + ); }); From 63a61ecdae5a3c71f9cff50a402178127ea0df22 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:34:33 -0500 Subject: [PATCH 334/523] 10417 remove getCurrentUser from udpateDocketEntryWorksheet Lambda --- .../authorizationClientService.ts | 2 +- .../useCaseHelper/getJudgeForUserHelper.ts | 3 +- ...dateDocketEntryWorksheetInteractor.test.ts | 30 ++++++++++++------- .../updateDocketEntryWorksheetInteractor.ts | 8 ++--- .../updateDocketEntryWorksheetLambda.ts | 18 ++++++----- 5 files changed, 37 insertions(+), 24 deletions(-) diff --git a/shared/src/authorization/authorizationClientService.ts b/shared/src/authorization/authorizationClientService.ts index 6fc7e1d8144..4ee68ae3fd4 100644 --- a/shared/src/authorization/authorizationClientService.ts +++ b/shared/src/authorization/authorizationClientService.ts @@ -2,7 +2,7 @@ import { AuthUser, UnknownAuthUser, isAuthUser, -} from '@shared/business/entities/authUser/AuthUser'; +} from '../business/entities/authUser/AuthUser'; export const ROLE_PERMISSIONS = { ADD_CASE_TO_TRIAL_SESSION: 'ADD_CASE_TO_TRIAL_SESSION', diff --git a/web-api/src/business/useCaseHelper/getJudgeForUserHelper.ts b/web-api/src/business/useCaseHelper/getJudgeForUserHelper.ts index fb3c89d35a7..d728e0f2b91 100644 --- a/web-api/src/business/useCaseHelper/getJudgeForUserHelper.ts +++ b/web-api/src/business/useCaseHelper/getJudgeForUserHelper.ts @@ -1,10 +1,11 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { InvalidRequest } from '@web-api/errors/errors'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { User } from '@shared/business/entities/User'; export const getJudgeForUserHelper = async ( applicationContext: ServerApplicationContext, - { user }: { user: { userId: string } }, + { user }: { user: AuthUser }, ): Promise> => { const rawUser = await applicationContext.getPersistenceGateway().getUserById({ applicationContext, diff --git a/web-api/src/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor.test.ts b/web-api/src/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor.test.ts index 1bf68de488a..b0406ec2ae8 100644 --- a/web-api/src/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor.test.ts +++ b/web-api/src/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor.test.ts @@ -1,7 +1,10 @@ import { InvalidEntityError, UnauthorizedError } from '@web-api/errors/errors'; import { RawDocketEntryWorksheet } from '@shared/business/entities/docketEntryWorksheet/DocketEntryWorksheet'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { judgeColvin, petitionsClerkUser } from '@shared/test/mockUsers'; +import { + mockJudgeUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { updateDocketEntryWorksheetInteractor } from '@web-api/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor'; describe('updateDocketEntryWorksheetInteractor', () => { @@ -16,8 +19,6 @@ describe('updateDocketEntryWorksheetInteractor', () => { }; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(judgeColvin); - applicationContext .getUseCaseHelpers() .getJudgeForUserHelper.mockReturnValue({ userId: TEST_JUDGE_USER_ID }); @@ -28,20 +29,26 @@ describe('updateDocketEntryWorksheetInteractor', () => { }); it('should throw an error when the user does not have access to the case worksheet feature', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - await expect( - updateDocketEntryWorksheetInteractor(applicationContext, { - worksheet: VALID_WORKSHEET, - }), + updateDocketEntryWorksheetInteractor( + applicationContext, + { + worksheet: VALID_WORKSHEET, + }, + mockPetitionsClerkUser, + ), ).rejects.toThrow(UnauthorizedError); }); it('should throw an error when the provided worksheet fails validation', async () => { await expect( - updateDocketEntryWorksheetInteractor(applicationContext, { - worksheet: { ...VALID_WORKSHEET, docketEntryId: 'NOT A UUID' }, - }), + updateDocketEntryWorksheetInteractor( + applicationContext, + { + worksheet: { ...VALID_WORKSHEET, docketEntryId: 'NOT A UUID' }, + }, + mockJudgeUser, + ), ).rejects.toThrow(InvalidEntityError); }); @@ -51,6 +58,7 @@ describe('updateDocketEntryWorksheetInteractor', () => { { worksheet: VALID_WORKSHEET, }, + mockJudgeUser, ); const updateDocketEntryWorksheetCallCount = diff --git a/web-api/src/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor.ts b/web-api/src/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor.ts index e1cc06183f3..211e58d1616 100644 --- a/web-api/src/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor.ts +++ b/web-api/src/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor.ts @@ -8,6 +8,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const updateDocketEntryWorksheetInteractor = async ( applicationContext: ServerApplicationContext, @@ -16,16 +17,15 @@ export const updateDocketEntryWorksheetInteractor = async ( }: { worksheet: RawDocketEntryWorksheet; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.DOCKET_ENTRY_WORKSHEET)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.DOCKET_ENTRY_WORKSHEET)) { throw new UnauthorizedError('Unauthorized'); } const judgeUser = await applicationContext .getUseCaseHelpers() - .getJudgeForUserHelper(applicationContext, { user }); + .getJudgeForUserHelper(applicationContext, { user: authorizedUser }); const docketEntryWorksheetEntity = new DocketEntryWorksheet( worksheet, diff --git a/web-api/src/lambdas/pendingMotion/updateDocketEntryWorksheetLambda.ts b/web-api/src/lambdas/pendingMotion/updateDocketEntryWorksheetLambda.ts index 31c37f28e6f..10a7a6d7239 100644 --- a/web-api/src/lambdas/pendingMotion/updateDocketEntryWorksheetLambda.ts +++ b/web-api/src/lambdas/pendingMotion/updateDocketEntryWorksheetLambda.ts @@ -1,11 +1,15 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateDocketEntryWorksheetInteractor } from '@web-api/business/useCases/pendingMotion/updateDocketEntryWorksheetInteractor'; -export const updateDocketEntryWorksheetLambda = event => +export const updateDocketEntryWorksheetLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateDocketEntryWorksheetInteractor( - applicationContext, - JSON.parse(event.body), - ); + return await updateDocketEntryWorksheetInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); }); From fda2e10c7d7162ffb517cc6e54296212765dcc94 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 13:36:18 -0700 Subject: [PATCH 335/523] 10417: remove appcontext.getCurrentUser from getInboxMessagesForSectionInteractor --- ...tInboxMessagesForSectionInteractor.test.ts | 25 +++++++++---------- .../getInboxMessagesForSectionInteractor.ts | 12 ++------- .../getInboxMessagesForSectionLambda.ts | 22 ++++++++-------- 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/web-api/src/business/useCases/messages/getInboxMessagesForSectionInteractor.test.ts b/web-api/src/business/useCases/messages/getInboxMessagesForSectionInteractor.test.ts index f0dfa5ba13f..ce0e93cf81c 100644 --- a/web-api/src/business/useCases/messages/getInboxMessagesForSectionInteractor.test.ts +++ b/web-api/src/business/useCases/messages/getInboxMessagesForSectionInteractor.test.ts @@ -2,24 +2,26 @@ import { CASE_STATUS_TYPES, DOCKET_SECTION, PETITIONS_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getInboxMessagesForSectionInteractor } from './getInboxMessagesForSectionInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('getInboxMessagesForSectionInteractor', () => { it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - getInboxMessagesForSectionInteractor(applicationContext, { - section: DOCKET_SECTION, - }), + getInboxMessagesForSectionInteractor( + applicationContext, + { + section: DOCKET_SECTION, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -48,10 +50,6 @@ describe('getInboxMessagesForSectionInteractor', () => { trialDate: '2028-03-01T21:40:46.415Z', trialLocation: 'El Paso, Texas', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getSectionInboxMessages.mockReturnValue([messageData]); @@ -61,6 +59,7 @@ describe('getInboxMessagesForSectionInteractor', () => { { section: DOCKET_SECTION, }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/messages/getInboxMessagesForSectionInteractor.ts b/web-api/src/business/useCases/messages/getInboxMessagesForSectionInteractor.ts index 0fe790db64d..236ce9d8471 100644 --- a/web-api/src/business/useCases/messages/getInboxMessagesForSectionInteractor.ts +++ b/web-api/src/business/useCases/messages/getInboxMessagesForSectionInteractor.ts @@ -5,21 +5,13 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * getInboxMessagesForSectionInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.section the section to get the inbox messages - * @returns {object} the messages in the section inbox - */ export const getInboxMessagesForSectionInteractor = async ( applicationContext: ServerApplicationContext, { section }: { section: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/getInboxMessagesForSectionLambda.ts b/web-api/src/lambdas/messages/getInboxMessagesForSectionLambda.ts index 5ca45c6321d..e13c01efeee 100644 --- a/web-api/src/lambdas/messages/getInboxMessagesForSectionLambda.ts +++ b/web-api/src/lambdas/messages/getInboxMessagesForSectionLambda.ts @@ -1,16 +1,18 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * gets the inbox messages for the section - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const getInboxMessagesForSectionLambda = event => +export const getInboxMessagesForSectionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getInboxMessagesForSectionInteractor(applicationContext, { - section: event.pathParameters.section, - }); + .getInboxMessagesForSectionInteractor( + applicationContext, + { + section: event.pathParameters.section, + }, + authorizedUser, + ); }); From d3da203ebef1f9c3a703f96a83fa90270214711d Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:37:34 -0500 Subject: [PATCH 336/523] 10417 remove getCurrentUser from getPendingMotionDocketEntriesForCurrentJudgeInteractor --- ...ketEntriesForCurrentJudgeInteractor.test.ts | 12 +++++++----- ...onDocketEntriesForCurrentJudgeInteractor.ts | 3 ++- ...MotionDocketEntriesForCurrentJudgeLambda.ts | 18 +++++++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/web-api/src/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor.test.ts b/web-api/src/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor.test.ts index e75c040595a..aa52bc33a61 100644 --- a/web-api/src/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor.test.ts +++ b/web-api/src/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor.test.ts @@ -5,7 +5,10 @@ import { import { RawDocketEntryWorksheet } from '@shared/business/entities/docketEntryWorksheet/DocketEntryWorksheet'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { judgeColvin, petitionsClerkUser } from '@shared/test/mockUsers'; +import { + mockJudgeUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; jest.mock('@shared/business/utilities/DateHandler', () => { const originalModule = jest.requireActual( @@ -33,8 +36,6 @@ describe('getPendingMotionDocketEntriesForCurrentJudgeInteractor', () => { const CASE_BY_DOCKET_NUMBER: { [key: string]: any } = {}; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(judgeColvin); - applicationContext .getPersistenceGateway() .getAllPendingMotionDocketEntriesForJudge.mockReturnValue( @@ -73,14 +74,13 @@ describe('getPendingMotionDocketEntriesForCurrentJudgeInteractor', () => { }); it('should throw an error when the user does not have access to the case worksheet feature', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - await expect( getPendingMotionDocketEntriesForCurrentJudgeInteractor( applicationContext, { judgeIds: ['judgeId'], }, + mockPetitionsClerkUser, ), ).rejects.toThrow(UnauthorizedError); }); @@ -121,6 +121,7 @@ describe('getPendingMotionDocketEntriesForCurrentJudgeInteractor', () => { { judgeIds: ['judgeId'], }, + mockJudgeUser, ); expect( @@ -212,6 +213,7 @@ describe('getPendingMotionDocketEntriesForCurrentJudgeInteractor', () => { { judgeIds: ['judgeId'], }, + mockJudgeUser, ); expect(results.docketEntries.length).toEqual(1); diff --git a/web-api/src/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor.ts b/web-api/src/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor.ts index 183cd116d2e..9a10036c9fb 100644 --- a/web-api/src/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor.ts +++ b/web-api/src/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor.ts @@ -6,6 +6,7 @@ import { import { RawDocketEntryWorksheet } from '@shared/business/entities/docketEntryWorksheet/DocketEntryWorksheet'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { calculateDifferenceInDays, prepareDateFromString, @@ -34,11 +35,11 @@ export type FormattedPendingMotionWithWorksheet = FormattedPendingMotion & { export const getPendingMotionDocketEntriesForCurrentJudgeInteractor = async ( applicationContext: ServerApplicationContext, params: { judgeIds: string[] }, + authorizedUser: UnknownAuthUser, ): Promise<{ docketEntries: FormattedPendingMotionWithWorksheet[]; }> => { const { judgeIds } = params; - const authorizedUser = applicationContext.getCurrentUser(); if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.PENDING_MOTIONS_TABLE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeLambda.ts b/web-api/src/lambdas/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeLambda.ts index 02fb711ca0a..cac698f787d 100644 --- a/web-api/src/lambdas/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeLambda.ts +++ b/web-api/src/lambdas/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeLambda.ts @@ -1,11 +1,15 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getPendingMotionDocketEntriesForCurrentJudgeInteractor } from '@web-api/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor'; -export const getPendingMotionDocketEntriesForCurrentJudgeLambda = event => +export const getPendingMotionDocketEntriesForCurrentJudgeLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, ({ applicationContext }) => - applicationContext - .getUseCases() - .getPendingMotionDocketEntriesForCurrentJudgeInteractor( - applicationContext, - event.queryStringParameters, - ), + getPendingMotionDocketEntriesForCurrentJudgeInteractor( + applicationContext, + event.queryStringParameters, + authorizedUser, + ), ); From 822b588733386bb526d34f75c2a420bff3c672fb Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:40:15 -0500 Subject: [PATCH 337/523] 10417 remove getCurrentUser from deleteDocketEntryWorksheetInteractor --- ...eleteDocketEntryWorksheetInteractor.test.ts | 9 ++++++--- .../deleteDocketEntryWorksheetInteractor.ts | 3 ++- .../deleteDocketEntryWorksheetLambda.ts | 18 +++++++++++------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.test.ts b/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.test.ts index 599a8f45daa..4aebaa12fd1 100644 --- a/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.test.ts +++ b/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.test.ts @@ -1,7 +1,10 @@ import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { deleteDocketEntryWorksheetInteractor } from '@web-api/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor'; -import { docketClerkUser } from '@shared/test/mockUsers'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; describe('deleteDocketEntryWorksheetInteractor', () => { const TEST_DOCKET_ENTRY_ID = 'TEST_DOCKET_ENTRY_ID'; @@ -10,8 +13,6 @@ describe('deleteDocketEntryWorksheetInteractor', () => { applicationContext .getPersistenceGateway() .deleteDocketEntryWorksheetRecord.mockReturnValue(null); - - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); }); it('should throw an Unauthorized Error when user does not have permission', async () => { @@ -20,6 +21,7 @@ describe('deleteDocketEntryWorksheetInteractor', () => { deleteDocketEntryWorksheetInteractor( applicationContext, TEST_DOCKET_ENTRY_ID, + mockPetitionerUser, ), ).rejects.toThrow(UnauthorizedError); }); @@ -28,6 +30,7 @@ describe('deleteDocketEntryWorksheetInteractor', () => { await deleteDocketEntryWorksheetInteractor( applicationContext, TEST_DOCKET_ENTRY_ID, + mockDocketClerkUser, ); const { calls } = diff --git a/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.ts b/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.ts index baaab5dc060..86565baeadb 100644 --- a/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.ts +++ b/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.ts @@ -4,12 +4,13 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const deleteDocketEntryWorksheetInteractor = async ( applicationContext: ServerApplicationContext, docketEntryId: string, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); if ( !isAuthorized( authorizedUser, diff --git a/web-api/src/lambdas/pendingMotion/deleteDocketEntryWorksheetLambda.ts b/web-api/src/lambdas/pendingMotion/deleteDocketEntryWorksheetLambda.ts index 758a05bc8ef..7b8668d62cc 100644 --- a/web-api/src/lambdas/pendingMotion/deleteDocketEntryWorksheetLambda.ts +++ b/web-api/src/lambdas/pendingMotion/deleteDocketEntryWorksheetLambda.ts @@ -1,11 +1,15 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { deleteDocketEntryWorksheetInteractor } from '@web-api/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor'; import { genericHandler } from '../../genericHandler'; -export const deleteDocketEntryWorksheetLambda = event => +export const deleteDocketEntryWorksheetLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, ({ applicationContext }) => { - return applicationContext - .getUseCases() - .deleteDocketEntryWorksheetInteractor( - applicationContext, - event.pathParameters.docketEntryId, - ); + return deleteDocketEntryWorksheetInteractor( + applicationContext, + event.pathParameters.docketEntryId, + authorizedUser, + ); }); From 2bf8fbbcbae58133efbf86e62846aa7d4c1b06cb Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:43:43 -0500 Subject: [PATCH 338/523] 10417 remove getCurrentUser from generatePrintablePendingReportInteractor --- ...tePrintablePendingReportInteractor.test.ts | 69 +++++++++++-------- ...eneratePrintablePendingReportInteractor.ts | 4 +- .../generatePrintablePendingReportLambda.ts | 17 +++-- 3 files changed, 53 insertions(+), 37 deletions(-) diff --git a/web-api/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.test.ts b/web-api/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.test.ts index c2285814984..64fe99c25a5 100644 --- a/web-api/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.test.ts +++ b/web-api/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.test.ts @@ -1,14 +1,13 @@ -import { - DOCKET_NUMBER_SUFFIXES, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { DOCKET_NUMBER_SUFFIXES } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generatePrintablePendingReportInteractor } from './generatePrintablePendingReportInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('generatePrintablePendingReportInteractor', () => { - let mockUser; - const mockFoundDocuments = [ { associatedJudge: 'Judge Judgey', @@ -87,13 +86,6 @@ describe('generatePrintablePendingReportInteractor', () => { }); beforeEach(() => { - mockUser = { - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }; - - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); @@ -104,15 +96,14 @@ describe('generatePrintablePendingReportInteractor', () => { }); it('should throw an unauthorized error when the user does not have access', async () => { - mockUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( - generatePrintablePendingReportInteractor(applicationContext, { - judge: 'Colvin', - } as any), + generatePrintablePendingReportInteractor( + applicationContext, + { + judge: 'Colvin', + } as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -120,6 +111,7 @@ describe('generatePrintablePendingReportInteractor', () => { const results = await generatePrintablePendingReportInteractor( applicationContext, {} as any, + mockPetitionsClerkUser, ); expect( @@ -135,6 +127,7 @@ describe('generatePrintablePendingReportInteractor', () => { await generatePrintablePendingReportInteractor( applicationContext, {} as any, + mockPetitionsClerkUser, ); const { pendingItems } = @@ -223,6 +216,7 @@ describe('generatePrintablePendingReportInteractor', () => { await generatePrintablePendingReportInteractor( applicationContext, {} as any, + mockPetitionsClerkUser, ); const { subtitle } = @@ -232,9 +226,13 @@ describe('generatePrintablePendingReportInteractor', () => { }); it('should generate a subtitle with the judge name if a judge filter is applied', async () => { - await generatePrintablePendingReportInteractor(applicationContext, { - judge: 'Colvin', - } as any); + await generatePrintablePendingReportInteractor( + applicationContext, + { + judge: 'Colvin', + } as any, + mockPetitionsClerkUser, + ); const { subtitle } = applicationContext.getDocumentGenerators().pendingReport.mock.calls[0][0] @@ -243,9 +241,13 @@ describe('generatePrintablePendingReportInteractor', () => { }); it('should get case information from persistence and generate a subtitle with the docket number if a docketNumber is present', async () => { - await generatePrintablePendingReportInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - } as any); + await generatePrintablePendingReportInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockPetitionsClerkUser, + ); const { subtitle } = applicationContext.getDocumentGenerators().pendingReport.mock.calls[0][0] @@ -257,9 +259,13 @@ describe('generatePrintablePendingReportInteractor', () => { it('should generate a subtitle with the docket number suffix if present', async () => { MOCK_CASE.docketNumberWithSuffix = `${MOCK_CASE.docketNumber}${DOCKET_NUMBER_SUFFIXES.WHISTLEBLOWER}`; - await generatePrintablePendingReportInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - } as any); + await generatePrintablePendingReportInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + } as any, + mockPetitionsClerkUser, + ); const { subtitle } = applicationContext.getDocumentGenerators().pendingReport.mock.calls[0][0] @@ -271,6 +277,7 @@ describe('generatePrintablePendingReportInteractor', () => { await generatePrintablePendingReportInteractor( applicationContext, {} as any, + mockPetitionsClerkUser, ); expect( @@ -282,6 +289,7 @@ describe('generatePrintablePendingReportInteractor', () => { await generatePrintablePendingReportInteractor( applicationContext, {} as any, + mockPetitionsClerkUser, ); expect( @@ -293,6 +301,7 @@ describe('generatePrintablePendingReportInteractor', () => { const results = await generatePrintablePendingReportInteractor( applicationContext, {} as any, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.ts b/web-api/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.ts index 884efdf3d1b..4b082ad1fad 100644 --- a/web-api/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.ts +++ b/web-api/src/business/useCases/pendingItems/generatePrintablePendingReportInteractor.ts @@ -4,13 +4,13 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const generatePrintablePendingReportInteractor = async ( applicationContext: ServerApplicationContext, { docketNumber, judge }: { docketNumber?: string; judge?: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.PENDING_ITEMS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/pendingItems/generatePrintablePendingReportLambda.ts b/web-api/src/lambdas/pendingItems/generatePrintablePendingReportLambda.ts index 9fb5d350ad7..2828b72a6df 100644 --- a/web-api/src/lambdas/pendingItems/generatePrintablePendingReportLambda.ts +++ b/web-api/src/lambdas/pendingItems/generatePrintablePendingReportLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generatePrintablePendingReportInteractor } from '@web-api/business/useCases/pendingItems/generatePrintablePendingReportInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,15 +8,20 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const generatePrintablePendingReportLambda = event => +export const generatePrintablePendingReportLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .generatePrintablePendingReportInteractor(applicationContext, { + return await generatePrintablePendingReportInteractor( + applicationContext, + { ...event.queryStringParameters, - }); + }, + authorizedUser, + ); }, { logResults: false }, ); From 81df7554a5365881e7ac81f2b8773135cee525f4 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 13:45:55 -0700 Subject: [PATCH 339/523] 10417: remove appcontext.getCurrentUser from getInboxMessagesForUserInteractor --- .../getInboxMessagesForUserInteractor.test.ts | 25 +++++++++---------- .../getInboxMessagesForUserInteractor.ts | 12 ++------- .../messages/getInboxMessagesForUserLambda.ts | 22 ++++++++-------- 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/web-api/src/business/useCases/messages/getInboxMessagesForUserInteractor.test.ts b/web-api/src/business/useCases/messages/getInboxMessagesForUserInteractor.test.ts index 9d75b782386..0a72363800d 100644 --- a/web-api/src/business/useCases/messages/getInboxMessagesForUserInteractor.test.ts +++ b/web-api/src/business/useCases/messages/getInboxMessagesForUserInteractor.test.ts @@ -1,24 +1,26 @@ import { CASE_STATUS_TYPES, PETITIONS_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getInboxMessagesForUserInteractor } from './getInboxMessagesForUserInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('getInboxMessagesForUserInteractor', () => { it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - getInboxMessagesForUserInteractor(applicationContext, { - userId: 'bob', - }), + getInboxMessagesForUserInteractor( + applicationContext, + { + userId: 'bob', + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -47,10 +49,6 @@ describe('getInboxMessagesForUserInteractor', () => { trialDate: '2028-03-01T21:40:46.415Z', trialLocation: 'El Paso, Texas', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getUserInboxMessages.mockReturnValue([messageData]); @@ -60,6 +58,7 @@ describe('getInboxMessagesForUserInteractor', () => { { userId: 'bob', }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/messages/getInboxMessagesForUserInteractor.ts b/web-api/src/business/useCases/messages/getInboxMessagesForUserInteractor.ts index 4d68bcd0f3c..1818d69618b 100644 --- a/web-api/src/business/useCases/messages/getInboxMessagesForUserInteractor.ts +++ b/web-api/src/business/useCases/messages/getInboxMessagesForUserInteractor.ts @@ -5,21 +5,13 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * getInboxMessagesForUserInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.userId the user to get the inbox messages - * @returns {object} the messages in the user inbox - */ export const getInboxMessagesForUserInteractor = async ( applicationContext: ServerApplicationContext, { userId }: { userId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/getInboxMessagesForUserLambda.ts b/web-api/src/lambdas/messages/getInboxMessagesForUserLambda.ts index 9e88019af7a..8d61dd48ee6 100644 --- a/web-api/src/lambdas/messages/getInboxMessagesForUserLambda.ts +++ b/web-api/src/lambdas/messages/getInboxMessagesForUserLambda.ts @@ -1,16 +1,18 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * gets the inbox messages for the user - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const getInboxMessagesForUserLambda = event => +export const getInboxMessagesForUserLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getInboxMessagesForUserInteractor(applicationContext, { - userId: event.pathParameters.userId, - }); + .getInboxMessagesForUserInteractor( + applicationContext, + { + userId: event.pathParameters.userId, + }, + authorizedUser, + ); }); From 149a6bb5c17f14bbddafe5c2c71564b76e04f491 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:46:38 -0500 Subject: [PATCH 340/523] 10417 remove getCurrentUser from fetchpendingitemsinteractor --- .../fetchPendingItemsInteractor.test.ts | 51 +++++++++---------- .../fetchPendingItemsInteractor.ts | 4 +- .../pendingItems/fetchPendingItemsLambda.ts | 17 +++++-- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/web-api/src/business/useCases/pendingItems/fetchPendingItemsInteractor.test.ts b/web-api/src/business/useCases/pendingItems/fetchPendingItemsInteractor.test.ts index 4c0a0b3b7e0..95233f9379c 100644 --- a/web-api/src/business/useCases/pendingItems/fetchPendingItemsInteractor.test.ts +++ b/web-api/src/business/useCases/pendingItems/fetchPendingItemsInteractor.test.ts @@ -1,37 +1,32 @@ -import { ROLES } from '@shared/business/entities/EntityConstants'; import { applicationContext } from '@shared/business/test/createTestApplicationContext'; import { fetchPendingItemsInteractor } from '@web-api/business/useCases/pendingItems/fetchPendingItemsInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('fetchPendingItemsInteractor', () => { - let mockUser; - - beforeEach(() => { - mockUser = { - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }; - - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - }); - it('should throw an unauthorized error when the user does not have access to blocked cases', async () => { - mockUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( - fetchPendingItemsInteractor(applicationContext, { - judge: 'Judge Colvin', - } as any), + fetchPendingItemsInteractor( + applicationContext, + { + judge: 'Judge Colvin', + } as any, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should throw an error when the judge is not defined', async () => { await expect( - fetchPendingItemsInteractor(applicationContext, { - judge: undefined, - } as any), + fetchPendingItemsInteractor( + applicationContext, + { + judge: undefined, + } as any, + mockPetitionsClerkUser, + ), ).rejects.toThrow('judge is required'); }); @@ -43,9 +38,13 @@ describe('fetchPendingItemsInteractor', () => { { docketEntryId: 'abc', docketNumber: '201-20', pending: true }, ]); - const results = await fetchPendingItemsInteractor(applicationContext, { - judge: 'Judge Colvin', - } as any); + const results = await fetchPendingItemsInteractor( + applicationContext, + { + judge: 'Judge Colvin', + } as any, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().fetchPendingItems, diff --git a/web-api/src/business/useCases/pendingItems/fetchPendingItemsInteractor.ts b/web-api/src/business/useCases/pendingItems/fetchPendingItemsInteractor.ts index 3e01fbe537f..17727473c33 100644 --- a/web-api/src/business/useCases/pendingItems/fetchPendingItemsInteractor.ts +++ b/web-api/src/business/useCases/pendingItems/fetchPendingItemsInteractor.ts @@ -4,6 +4,7 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const pendingItemCaseSource = [ 'associatedJudge', @@ -34,12 +35,11 @@ export type PendingItem = Pick< export const fetchPendingItemsInteractor = async ( applicationContext: ServerApplicationContext, { judge, page }: { judge: string; page: number }, + authorizedUser: UnknownAuthUser, ): Promise<{ foundDocuments: PendingItem[]; total: number; }> => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.PENDING_ITEMS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/pendingItems/fetchPendingItemsLambda.ts b/web-api/src/lambdas/pendingItems/fetchPendingItemsLambda.ts index 9331136a61b..9d7c6d2e8f7 100644 --- a/web-api/src/lambdas/pendingItems/fetchPendingItemsLambda.ts +++ b/web-api/src/lambdas/pendingItems/fetchPendingItemsLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { fetchPendingItemsInteractor } from '@web-api/business/useCases/pendingItems/fetchPendingItemsInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,11 +8,16 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const fetchPendingItemsLambda = event => +export const fetchPendingItemsLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .fetchPendingItemsInteractor(applicationContext, { + return await fetchPendingItemsInteractor( + applicationContext, + { ...event.queryStringParameters, - }); + }, + authorizedUser, + ); }); From 9c7cfc748960677d27f30f9db95eef7ced09b7b6 Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 13:49:46 -0700 Subject: [PATCH 341/523] 10417: remove appcontext.getCurrentUser from getMessageThreadInteractor --- .../getMessageThreadInteractor.test.ts | 25 +++++++++---------- .../messages/getMessageThreadInteractor.ts | 12 ++------- .../messages/getMessageThreadLambda.ts | 22 ++++++++-------- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/web-api/src/business/useCases/messages/getMessageThreadInteractor.test.ts b/web-api/src/business/useCases/messages/getMessageThreadInteractor.test.ts index 81f41aa9e8a..7644eee3c86 100644 --- a/web-api/src/business/useCases/messages/getMessageThreadInteractor.test.ts +++ b/web-api/src/business/useCases/messages/getMessageThreadInteractor.test.ts @@ -1,23 +1,25 @@ import { CASE_STATUS_TYPES, PETITIONS_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getMessageThreadInteractor } from './getMessageThreadInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getMessageThreadInteractor', () => { it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - getMessageThreadInteractor(applicationContext, { - parentMessageId: 'abc', - }), + getMessageThreadInteractor( + applicationContext, + { + parentMessageId: 'abc', + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -42,10 +44,6 @@ describe('getMessageThreadInteractor', () => { toSection: PETITIONS_SECTION, toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getMessageThreadByParentId.mockReturnValue([mockMessage]); @@ -55,6 +53,7 @@ describe('getMessageThreadInteractor', () => { { parentMessageId: 'abc', }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/messages/getMessageThreadInteractor.ts b/web-api/src/business/useCases/messages/getMessageThreadInteractor.ts index 1bd6f7741bf..b6ef6aa0cbc 100644 --- a/web-api/src/business/useCases/messages/getMessageThreadInteractor.ts +++ b/web-api/src/business/useCases/messages/getMessageThreadInteractor.ts @@ -5,21 +5,13 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * gets a message thread by parent id - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.parentMessageId the id of the parent message for the thread - * @returns {object} the message - */ export const getMessageThreadInteractor = async ( applicationContext: ServerApplicationContext, { parentMessageId }: { parentMessageId: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/getMessageThreadLambda.ts b/web-api/src/lambdas/messages/getMessageThreadLambda.ts index 5720653f017..c86d608756e 100644 --- a/web-api/src/lambdas/messages/getMessageThreadLambda.ts +++ b/web-api/src/lambdas/messages/getMessageThreadLambda.ts @@ -1,16 +1,16 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * lambda which is used for retrieving messages by the parent message id - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const getMessageThreadLambda = event => +export const getMessageThreadLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getMessageThreadInteractor(applicationContext, { + return await applicationContext.getUseCases().getMessageThreadInteractor( + applicationContext, + { parentMessageId: event.pathParameters.parentMessageId, - }); + }, + authorizedUser, + ); }); From e33631a0c7c971de58fd2df53b6518b9f0fc4f61 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:49:53 -0500 Subject: [PATCH 342/523] 10417 remove getCurrentUser from exportPendingReportInteractor --- .../exportPendingReportInteractor.test.ts | 41 ++++++++----------- .../exportPendingReportInteractor.ts | 4 +- .../pendingItems/exportPendingReportLambda.ts | 17 +++++--- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/web-api/src/business/useCases/pendingItems/exportPendingReportInteractor.test.ts b/web-api/src/business/useCases/pendingItems/exportPendingReportInteractor.test.ts index bce8b791efc..d7b76fb4737 100644 --- a/web-api/src/business/useCases/pendingItems/exportPendingReportInteractor.test.ts +++ b/web-api/src/business/useCases/pendingItems/exportPendingReportInteractor.test.ts @@ -1,14 +1,15 @@ import { CASE_STATUS_TYPES, DOCKET_NUMBER_SUFFIXES, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { exportPendingReportInteractor } from '@web-api/business/useCases/pendingItems/exportPendingReportInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('exportPendingReportInteractor', () => { - let mockUser; - const judge = 'Colvin'; const mockFoundDocuments = [ @@ -97,32 +98,26 @@ describe('exportPendingReportInteractor', () => { }); }); - beforeEach(() => { - mockUser = { - role: ROLES.petitionsClerk, - userId: 'petitionsclerk', - }; - - applicationContext.getCurrentUser.mockImplementation(() => mockUser); - }); - it('should throw an unauthorized error when the user does not have access', async () => { - mockUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - await expect( - exportPendingReportInteractor(applicationContext, { - judge: 'Colvin', - }), + exportPendingReportInteractor( + applicationContext, + { + judge: 'Colvin', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); it('should call fetchPendingItems from persistence and return a csv string of the results', async () => { - const results = await exportPendingReportInteractor(applicationContext, { - judge, - }); + const results = await exportPendingReportInteractor( + applicationContext, + { + judge, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().fetchPendingItems, diff --git a/web-api/src/business/useCases/pendingItems/exportPendingReportInteractor.ts b/web-api/src/business/useCases/pendingItems/exportPendingReportInteractor.ts index e8dde7bccaa..776ebf9f55f 100644 --- a/web-api/src/business/useCases/pendingItems/exportPendingReportInteractor.ts +++ b/web-api/src/business/useCases/pendingItems/exportPendingReportInteractor.ts @@ -4,14 +4,14 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { stringify } from 'csv-stringify/sync'; export const exportPendingReportInteractor = async ( applicationContext: ServerApplicationContext, { judge }: { judge?: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.PENDING_ITEMS)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/pendingItems/exportPendingReportLambda.ts b/web-api/src/lambdas/pendingItems/exportPendingReportLambda.ts index 795ecf0788f..6cfdde8cad5 100644 --- a/web-api/src/lambdas/pendingItems/exportPendingReportLambda.ts +++ b/web-api/src/lambdas/pendingItems/exportPendingReportLambda.ts @@ -1,14 +1,21 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { exportPendingReportInteractor } from '@web-api/business/useCases/pendingItems/exportPendingReportInteractor'; import { genericHandler } from '../../genericHandler'; -export const exportPendingReportLambda = event => +export const exportPendingReportLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .exportPendingReportInteractor(applicationContext, { + return await exportPendingReportInteractor( + applicationContext, + { ...event.queryStringParameters, - }); + }, + authorizedUser, + ); }, { logResults: false }, ); From 7488d561d6c2896fb9483daf1b4260849752f7c6 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:53:12 -0500 Subject: [PATCH 343/523] 10417 remove getCurrentUser from setMessageAsReadInteractor --- .../setMessageAsReadInteractor.test.ts | 39 ++++++++++--------- .../messages/setMessageAsReadInteractor.ts | 6 +-- .../messages/setMessageAsReadLambda.ts | 17 +++++--- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/web-api/src/business/useCases/messages/setMessageAsReadInteractor.test.ts b/web-api/src/business/useCases/messages/setMessageAsReadInteractor.test.ts index 3f0d6b8277b..d6be9631096 100644 --- a/web-api/src/business/useCases/messages/setMessageAsReadInteractor.test.ts +++ b/web-api/src/business/useCases/messages/setMessageAsReadInteractor.test.ts @@ -1,19 +1,21 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { setMessageAsReadInteractor } from './setMessageAsReadInteractor'; describe('setMessageAsReadInteractor', () => { it('returns an authorization error if the user does not have the necessary permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'petitioner', - }); - await expect( - setMessageAsReadInteractor(applicationContext, { - docketNumber: '123-45', - messageId: '123', - }), + setMessageAsReadInteractor( + applicationContext, + { + docketNumber: '123-45', + messageId: '123', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); expect( applicationContext.getPersistenceGateway().setMessageAsRead, @@ -21,15 +23,14 @@ describe('setMessageAsReadInteractor', () => { }); it('calls the persistence method for marking a message as read for the given messageId', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsClerk', - }); - - await setMessageAsReadInteractor(applicationContext, { - docketNumber: '123-45', - messageId: '123', - }); + await setMessageAsReadInteractor( + applicationContext, + { + docketNumber: '123-45', + messageId: '123', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().setMessageAsRead, diff --git a/web-api/src/business/useCases/messages/setMessageAsReadInteractor.ts b/web-api/src/business/useCases/messages/setMessageAsReadInteractor.ts index 78311316a6c..9d639f52300 100644 --- a/web-api/src/business/useCases/messages/setMessageAsReadInteractor.ts +++ b/web-api/src/business/useCases/messages/setMessageAsReadInteractor.ts @@ -4,6 +4,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * setMessageAsReadInteractor @@ -17,10 +18,9 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const setMessageAsReadInteractor = async ( applicationContext: ServerApplicationContext, { docketNumber, messageId }: { docketNumber: string; messageId: string }, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.GET_READ_MESSAGES)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.GET_READ_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/setMessageAsReadLambda.ts b/web-api/src/lambdas/messages/setMessageAsReadLambda.ts index 652014e5c49..39efe824705 100644 --- a/web-api/src/lambdas/messages/setMessageAsReadLambda.ts +++ b/web-api/src/lambdas/messages/setMessageAsReadLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { setMessageAsReadInteractor } from '@web-api/business/useCases/messages/setMessageAsReadInteractor'; /** * sets the given message's read status @@ -6,14 +8,19 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const setMessageAsReadLambda = event => +export const setMessageAsReadLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { messageId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .setMessageAsReadInteractor(applicationContext, { + return await setMessageAsReadInteractor( + applicationContext, + { messageId, ...JSON.parse(event.body), - }); + }, + authorizedUser, + ); }); From 3f7cb600ead4e263faaba186d901fb4e6e9b8a4d Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Mon, 22 Jul 2024 13:55:36 -0700 Subject: [PATCH 344/523] 10417: remove appcontext.getCurrentUser from getOutboxMessagesForSectionInteractor --- ...OutboxMessagesForSectionInteractor.test.ts | 25 +++++++++---------- .../getOutboxMessagesForSectionInteractor.ts | 12 ++------- .../getOutboxMessagesForSectionLambda.ts | 22 ++++++++-------- 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/web-api/src/business/useCases/messages/getOutboxMessagesForSectionInteractor.test.ts b/web-api/src/business/useCases/messages/getOutboxMessagesForSectionInteractor.test.ts index ab323fe9cd4..2694090b3ba 100644 --- a/web-api/src/business/useCases/messages/getOutboxMessagesForSectionInteractor.test.ts +++ b/web-api/src/business/useCases/messages/getOutboxMessagesForSectionInteractor.test.ts @@ -2,24 +2,26 @@ import { CASE_STATUS_TYPES, DOCKET_SECTION, PETITIONS_SECTION, - ROLES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getOutboxMessagesForSectionInteractor } from './getOutboxMessagesForSectionInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { omit } from 'lodash'; describe('getOutboxMessagesForSectionInteractor', () => { it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - getOutboxMessagesForSectionInteractor(applicationContext, { - section: DOCKET_SECTION, - }), + getOutboxMessagesForSectionInteractor( + applicationContext, + { + section: DOCKET_SECTION, + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -48,10 +50,6 @@ describe('getOutboxMessagesForSectionInteractor', () => { trialDate: '2028-03-01T21:40:46.415Z', trialLocation: 'El Paso, Texas', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getSectionOutboxMessages.mockReturnValue([messageData]); @@ -61,6 +59,7 @@ describe('getOutboxMessagesForSectionInteractor', () => { { section: DOCKET_SECTION, }, + mockPetitionsClerkUser, ); expect( diff --git a/web-api/src/business/useCases/messages/getOutboxMessagesForSectionInteractor.ts b/web-api/src/business/useCases/messages/getOutboxMessagesForSectionInteractor.ts index 7da7ac45e7a..084143dad28 100644 --- a/web-api/src/business/useCases/messages/getOutboxMessagesForSectionInteractor.ts +++ b/web-api/src/business/useCases/messages/getOutboxMessagesForSectionInteractor.ts @@ -5,21 +5,13 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -/** - * getOutboxMessagesForSectionInteractor - * - * @param {object} applicationContext the application context - * @param {object} providers the providers object - * @param {string} providers.section the section to get the outbox messages - * @returns {object} the messages in the section outbox - */ export const getOutboxMessagesForSectionInteractor = async ( applicationContext: ServerApplicationContext, { section }: { section: string }, + authorizedUser: UnknownAuthUser, ) => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.VIEW_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/messages/getOutboxMessagesForSectionLambda.ts b/web-api/src/lambdas/messages/getOutboxMessagesForSectionLambda.ts index 30f3e8098f8..a1de57152c6 100644 --- a/web-api/src/lambdas/messages/getOutboxMessagesForSectionLambda.ts +++ b/web-api/src/lambdas/messages/getOutboxMessagesForSectionLambda.ts @@ -1,16 +1,18 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; -/** - * gets the outbox messages for the section - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const getOutboxMessagesForSectionLambda = event => +export const getOutboxMessagesForSectionLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { return await applicationContext .getUseCases() - .getOutboxMessagesForSectionInteractor(applicationContext, { - section: event.pathParameters.section, - }); + .getOutboxMessagesForSectionInteractor( + applicationContext, + { + section: event.pathParameters.section, + }, + authorizedUser, + ); }); From f0b4708644f74ce7881146abac01e12df5d43652 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 15:56:04 -0500 Subject: [PATCH 345/523] 10417 remove getCurrentUser from replyToMessageInteractor --- .../messages/replyToMessageInteractor.test.ts | 47 ++++++++++--------- .../messages/replyToMessageInteractor.ts | 27 ++++++----- .../lambdas/messages/replyToMessageLambda.ts | 14 ++++-- 3 files changed, 50 insertions(+), 38 deletions(-) diff --git a/web-api/src/business/useCases/messages/replyToMessageInteractor.test.ts b/web-api/src/business/useCases/messages/replyToMessageInteractor.test.ts index 158d621bb75..5b0993bd1fb 100644 --- a/web-api/src/business/useCases/messages/replyToMessageInteractor.test.ts +++ b/web-api/src/business/useCases/messages/replyToMessageInteractor.test.ts @@ -5,6 +5,10 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { replyToMessageInteractor } from './replyToMessageInteractor'; describe('replyToMessageInteractor', () => { @@ -18,21 +22,20 @@ describe('replyToMessageInteractor', () => { ]; it('throws unauthorized for a user without MESSAGES permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: '9bd0308c-2b06-4589-b36e-242398bea31b', - }); - await expect( - replyToMessageInteractor(applicationContext, { - attachments: mockAttachments, - docketNumber: '101-20', - message: "How's it going?", - parentMessageId: '62ea7e6e-8101-4e4b-9bbd-932b149c86c3', - subject: 'Hey!', - toSection: PETITIONS_SECTION, - toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', - }), + replyToMessageInteractor( + applicationContext, + { + attachments: mockAttachments, + docketNumber: '101-20', + message: "How's it going?", + parentMessageId: '62ea7e6e-8101-4e4b-9bbd-932b149c86c3', + subject: 'Hey!', + toSection: PETITIONS_SECTION, + toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', + }, + mockPetitionerUser, + ), ).rejects.toThrow(UnauthorizedError); }); @@ -45,10 +48,6 @@ describe('replyToMessageInteractor', () => { toSection: PETITIONS_SECTION, toUserId: 'b427ca37-0df1-48ac-94bb-47aed073d6f7', }; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'b9fcabc8-3c83-4cbf-9f4a-d2ecbdc591e1', - }); applicationContext .getPersistenceGateway() .getUserById.mockReturnValueOnce({ @@ -73,10 +72,14 @@ describe('replyToMessageInteractor', () => { status: CASE_STATUS_TYPES.generalDocket, }); - await replyToMessageInteractor(applicationContext, { - ...messageData, - attachments: mockAttachments, - }); + await replyToMessageInteractor( + applicationContext, + { + ...messageData, + attachments: mockAttachments, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createMessage, diff --git a/web-api/src/business/useCases/messages/replyToMessageInteractor.ts b/web-api/src/business/useCases/messages/replyToMessageInteractor.ts index 2fe37120f4b..9ec1b3be1de 100644 --- a/web-api/src/business/useCases/messages/replyToMessageInteractor.ts +++ b/web-api/src/business/useCases/messages/replyToMessageInteractor.ts @@ -10,6 +10,7 @@ import { import { ReplyMessageType } from '@web-api/business/useCases/messages/createMessageInteractor'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const replyToMessage = async ( applicationContext: ServerApplicationContext, @@ -22,9 +23,8 @@ export const replyToMessage = async ( toSection, toUserId, }: ReplyMessageType, + authorizedUser: UnknownAuthUser, ): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.SEND_RECEIVE_MESSAGES)) { throw new UnauthorizedError('Unauthorized'); } @@ -88,14 +88,19 @@ export const replyToMessageInteractor = ( toSection, toUserId, }: ReplyMessageType, + authorizedUser: UnknownAuthUser, ): Promise => { - return replyToMessage(applicationContext, { - attachments, - docketNumber, - message, - parentMessageId, - subject, - toSection, - toUserId, - }); + return replyToMessage( + applicationContext, + { + attachments, + docketNumber, + message, + parentMessageId, + subject, + toSection, + toUserId, + }, + authorizedUser, + ); }; diff --git a/web-api/src/lambdas/messages/replyToMessageLambda.ts b/web-api/src/lambdas/messages/replyToMessageLambda.ts index 9f2233a785a..af4a591e6ec 100644 --- a/web-api/src/lambdas/messages/replyToMessageLambda.ts +++ b/web-api/src/lambdas/messages/replyToMessageLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { replyToMessageInteractor } from '@web-api/business/useCases/messages/replyToMessageInteractor'; /** * lambda which is used to reply to a message @@ -6,12 +8,14 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const replyToMessageLambda = event => +export const replyToMessageLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .replyToMessageInteractor(applicationContext, { + return await replyToMessageInteractor( + applicationContext, + { parentMessageId: event.pathParameters.parentMessageId, ...JSON.parse(event.body), - }); + }, + authorizedUser, + ); }); From 0ac353a1bdfb2ebfb12998796aa94032d1ced800 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 16:02:14 -0500 Subject: [PATCH 346/523] 10417 remove getCurrentUser from getPractitionerByBarNumberInteractor --- ...tPractitionerByBarNumberInteractor.test.ts | 55 ++++++------------- .../getPractitionerByBarNumberInteractor.ts | 7 ++- .../getPractitionerByBarNumberLambda.ts | 17 ++++-- 3 files changed, 32 insertions(+), 47 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/getPractitionerByBarNumberInteractor.test.ts b/web-api/src/business/useCases/practitioner/getPractitionerByBarNumberInteractor.test.ts index c08a8eb6097..68eced0490b 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerByBarNumberInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerByBarNumberInteractor.test.ts @@ -2,36 +2,28 @@ import { ROLES, SERVICE_INDICATOR_TYPES, } from '../../../../../shared/src/business/entities/EntityConstants'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getPractitionerByBarNumberInteractor } from './getPractitionerByBarNumberInteractor'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('getPractitionerByBarNumberInteractor', () => { describe('Logged in User', () => { it('throws an unauthorized error if the request user does not have the MANAGE_PRACTITIONER_USERS permissions', async () => { - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'Test Petitioner', - role: ROLES.petitioner, - userId: '1005d1ab-18d0-43ec-bafb-654e83405416', - }), - ); - await expect( - getPractitionerByBarNumberInteractor(applicationContext, { - barNumber: 'BN0000', - }), + getPractitionerByBarNumberInteractor( + applicationContext, + { + barNumber: 'BN0000', + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized for getting attorney user'); }); it('calls the persistence method to get a private practitioner with the given bar number', async () => { - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), - ); applicationContext .getPersistenceGateway() .getPractitionerByBarNumber.mockReturnValue({ @@ -58,6 +50,7 @@ describe('getPractitionerByBarNumberInteractor', () => { { barNumber: 'PP1234', }, + mockPetitionsClerkUser, ); expect(practitioner).toEqual({ @@ -89,13 +82,6 @@ describe('getPractitionerByBarNumberInteractor', () => { }); it('calls the persistence method to get an IRS practitioner with the given bar number', async () => { - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), - ); applicationContext .getPersistenceGateway() .getPractitionerByBarNumber.mockReturnValue({ @@ -120,6 +106,7 @@ describe('getPractitionerByBarNumberInteractor', () => { { barNumber: 'PI5678', }, + mockPetitionsClerkUser, ); expect(practitioner).toEqual({ @@ -149,13 +136,6 @@ describe('getPractitionerByBarNumberInteractor', () => { }); it('throws a not found error if no practitioner is found with the given bar number', async () => { - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }), - ); applicationContext .getPersistenceGateway() .getPractitionerByBarNumber.mockReturnValue(undefined); @@ -165,6 +145,7 @@ describe('getPractitionerByBarNumberInteractor', () => { { barNumber: 'BN0000', }, + mockPetitionsClerkUser, ); expect(practitioner).toBeUndefined(); @@ -173,8 +154,6 @@ describe('getPractitionerByBarNumberInteractor', () => { describe('Public User', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(undefined); - applicationContext .getPersistenceGateway() .getPractitionerByBarNumber.mockReturnValue({ @@ -197,26 +176,24 @@ describe('getPractitionerByBarNumberInteractor', () => { }); it('should not throw an error when a public user access interactor', async () => { - applicationContext.getCurrentUser.mockReturnValue(undefined); - const results = await getPractitionerByBarNumberInteractor( applicationContext, { barNumber: 'BN0000', }, + undefined, ); expect(results).toBeDefined(); }); it('should return an array with Practitioner result', async () => { - applicationContext.getCurrentUser.mockReturnValue(undefined); - const results = await getPractitionerByBarNumberInteractor( applicationContext, { barNumber: 'BN0000', }, + undefined, ); expect(results).toEqual([ diff --git a/web-api/src/business/useCases/practitioner/getPractitionerByBarNumberInteractor.ts b/web-api/src/business/useCases/practitioner/getPractitionerByBarNumberInteractor.ts index c0b39a1d720..1c4a920d2a4 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerByBarNumberInteractor.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerByBarNumberInteractor.ts @@ -5,6 +5,7 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * getPractitionerByBarNumberInteractor @@ -17,13 +18,13 @@ import { UnauthorizedError } from '@web-api/errors/errors'; export const getPractitionerByBarNumberInteractor = async ( applicationContext: ServerApplicationContext, { barNumber }: { barNumber: string }, + authorizedUser: UnknownAuthUser, ) => { - const requestUser = applicationContext.getCurrentUser(); - const isLoggedInUser = !!requestUser?.userId; + const isLoggedInUser = !!authorizedUser?.userId; if ( isLoggedInUser && - !isAuthorized(requestUser, ROLE_PERMISSIONS.MANAGE_PRACTITIONER_USERS) + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.MANAGE_PRACTITIONER_USERS) ) { throw new UnauthorizedError('Unauthorized for getting attorney user'); } diff --git a/web-api/src/lambdas/practitioners/getPractitionerByBarNumberLambda.ts b/web-api/src/lambdas/practitioners/getPractitionerByBarNumberLambda.ts index a4c821d743d..44e5eed53f5 100644 --- a/web-api/src/lambdas/practitioners/getPractitionerByBarNumberLambda.ts +++ b/web-api/src/lambdas/practitioners/getPractitionerByBarNumberLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getPractitionerByBarNumberInteractor } from '@web-api/business/useCases/practitioner/getPractitionerByBarNumberInteractor'; /** * gets practitioner user by bar number @@ -6,11 +8,16 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getPractitionerByBarNumberLambda = event => +export const getPractitionerByBarNumberLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getPractitionerByBarNumberInteractor(applicationContext, { + return await getPractitionerByBarNumberInteractor( + applicationContext, + { barNumber: event.pathParameters.barNumber, - }); + }, + authorizedUser, + ); }); From fca82ef9538ab065eeb00aa2b9f7cd24e07250c3 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 16:14:47 -0500 Subject: [PATCH 347/523] 10417 cleanup in serveCaseToIrsInteractor --- .../serveCaseToIrs/serveCaseToIrsInteractor.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts index 84dc48f9f4f..57aca854265 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts @@ -33,11 +33,7 @@ import { getClinicLetterKey } from '../../../../../shared/src/business/utilities import { random, remove } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; -export const addDocketEntryForPaymentStatus = ({ - applicationContext, - caseEntity, - user, -}) => { +export const addDocketEntryForPaymentStatus = ({ caseEntity, user }) => { if (caseEntity.petitionPaymentStatus === PAYMENT_STATUS.PAID) { const paymentStatusDocketEntry = new DocketEntry( { @@ -49,7 +45,7 @@ export const addDocketEntryForPaymentStatus = ({ isOnDocketRecord: true, processingStatus: 'complete', }, - { authorizedUser: applicationContext.getCurrentUser() }, + { authorizedUser: user }, ); paymentStatusDocketEntry.setFiledBy(user); @@ -66,7 +62,7 @@ export const addDocketEntryForPaymentStatus = ({ isOnDocketRecord: true, processingStatus: 'complete', }, - { authorizedUser: applicationContext.getCurrentUser() }, + { authorizedUser: user }, ); petitionPaymentStatusDocketEntry.setFiledBy(user); @@ -341,7 +337,7 @@ const generateNoticeOfReceipt = async ({ isOnDocketRecord: true, }, { - authorizedUser: applicationContext.getCurrentUser, + authorizedUser: userServingPetition, petitioners: caseEntity.petitioners, }, ); @@ -516,12 +512,10 @@ export const serveCaseToIrs = async ( } addDocketEntryForPaymentStatus({ - applicationContext, caseEntity, user: authorizedUser, }); - // TODO 10417 type weirdness -- why is this angry? caseEntity .updateCaseCaptionDocketRecord({ authorizedUser }) .updateDocketNumberRecord({ authorizedUser }) @@ -537,7 +531,7 @@ export const serveCaseToIrs = async ( .getUseCaseHelpers() .addDocketEntryForSystemGeneratedOrder({ applicationContext, - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, caseEntity, systemGeneratedDocument: noticeOfAttachmentsInNatureOfEvidence, }), @@ -678,7 +672,7 @@ export const serveCaseToIrs = async ( message: { action: 'serve_to_irs_error', }, - userId: authorizedUser.userId, + userId: authorizedUser?.userId || '', }); } }; From 29e93d32c4d7254df283f53fd62065623c2462a8 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 16:41:25 -0500 Subject: [PATCH 348/523] 10417 cleanup in setTrialSessionCalendarInteractor --- ...archiveCorrespondenceDocumentInteractor.ts | 2 - ...tOfCaseDocumentsFiledByJudgesInteractor.ts | 2 - .../setTrialSessionCalendarInteractor.test.ts | 100 +++++++++----- .../setTrialSessionCalendarInteractor.ts | 130 ++++++++++-------- 4 files changed, 144 insertions(+), 90 deletions(-) diff --git a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts index d669d51adfd..08355fe9c56 100644 --- a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts +++ b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts @@ -16,8 +16,6 @@ export const archiveCorrespondenceDocument = async ( }: { correspondenceId: string; docketNumber: string }, authorizedUser: UnknownAuthUser, ) => { - // const user = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.CASE_CORRESPONDENCE)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.ts b/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.ts index 5dd6ab89809..0a054ede523 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.ts @@ -33,8 +33,6 @@ export const getCountOfCaseDocumentsFiledByJudgesInteractor = async ( params: GetCountOfCaseDocumentsFiledByJudgesRequest, authorizedUser: UnknownAuthUser, ): Promise => { - // const authorizedUser = applicationContext.getCurrentUser(); - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.JUDGE_ACTIVITY_REPORT)) { throw new UnauthorizedError('Unauthorized to view Judge Activity Report'); } diff --git a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.ts b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.ts index cbc661fe1b7..747495624f3 100644 --- a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.test.ts @@ -2,6 +2,10 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { setTrialSessionCalendarInteractor } from './setTrialSessionCalendarInteractor'; describe('setTrialSessionCalendarInteractor', () => { @@ -50,10 +54,14 @@ describe('setTrialSessionCalendarInteractor', () => { .getPersistenceGateway() .getEligibleCasesForTrialSession.mockReturnValue([MOCK_CASE]); - await setTrialSessionCalendarInteractor(applicationContext, { - clientConnectionId: 'hellomom', - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + clientConnectionId: 'hellomom', + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionerUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -88,10 +96,14 @@ describe('setTrialSessionCalendarInteractor', () => { .getPersistenceGateway() .setPriorityOnAllWorkItems.mockReturnValue({}); - await setTrialSessionCalendarInteractor(applicationContext, { - clientConnectionId: 'hellomom', - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + clientConnectionId: 'hellomom', + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -129,10 +141,14 @@ describe('setTrialSessionCalendarInteractor', () => { }, ]); - await setTrialSessionCalendarInteractor(applicationContext, { - clientConnectionId: 'hi', - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + clientConnectionId: 'hi', + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] @@ -168,10 +184,14 @@ describe('setTrialSessionCalendarInteractor', () => { }, ]); - await setTrialSessionCalendarInteractor(applicationContext, { - clientConnectionId: 'hi', - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + clientConnectionId: 'hi', + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().setPriorityOnAllWorkItems, @@ -201,10 +221,14 @@ describe('setTrialSessionCalendarInteractor', () => { .getPersistenceGateway() .getCalendaredCasesForTrialSession.mockReturnValue([]); - await setTrialSessionCalendarInteractor(applicationContext, { - clientConnectionId: 'hi', - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + clientConnectionId: 'hi', + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getEligibleCasesForTrialSession @@ -227,10 +251,14 @@ describe('setTrialSessionCalendarInteractor', () => { }, ]); - await setTrialSessionCalendarInteractor(applicationContext, { - clientConnectionId: 'hi', - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + clientConnectionId: 'hi', + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getEligibleCasesForTrialSession @@ -243,10 +271,14 @@ describe('setTrialSessionCalendarInteractor', () => { it('should throw a ServiceUnavailableError if the Case is currently locked', async () => { mockLock = MOCK_LOCK; - await setTrialSessionCalendarInteractor(applicationContext, { - clientConnectionId: 'hi', - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + clientConnectionId: 'hi', + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock @@ -258,10 +290,14 @@ describe('setTrialSessionCalendarInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await setTrialSessionCalendarInteractor(applicationContext, { - clientConnectionId: 'hi', - trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); + await setTrialSessionCalendarInteractor( + applicationContext, + { + clientConnectionId: 'hi', + trialSessionId: '6805d1ab-18d0-43ec-bafb-654e83405416', + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, diff --git a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts index 93b25791235..9c1e8a0aff8 100644 --- a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts @@ -1,3 +1,7 @@ +import { + AuthUser, + UnknownAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { NotFoundError, UnauthorizedError } from '../../../errors/errors'; import { @@ -12,18 +16,18 @@ import { chunk, flatten, partition, uniq } from 'lodash'; const CHUNK_SIZE = 50; -// TODO 10417 update to remove getCurrentUser export const setTrialSessionCalendarInteractor = async ( applicationContext: ServerApplicationContext, { clientConnectionId, trialSessionId, }: { trialSessionId: string; clientConnectionId: string }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - try { - if (!isAuthorized(user, ROLE_PERMISSIONS.SET_TRIAL_SESSION_CALENDAR)) { + if ( + !isAuthorized(authorizedUser, ROLE_PERMISSIONS.SET_TRIAL_SESSION_CALENDAR) + ) { throw new UnauthorizedError('Unauthorized'); } @@ -38,9 +42,7 @@ export const setTrialSessionCalendarInteractor = async ( throw new NotFoundError(`Trial session ${trialSessionId} was not found.`); } - const trialSessionEntity = new TrialSession(trialSession, { - applicationContext, - }); + const trialSessionEntity = new TrialSession(trialSession); trialSessionEntity.validate(); @@ -98,6 +100,7 @@ export const setTrialSessionCalendarInteractor = async ( await acquireLock({ applicationContext, + authorizedUser, identifiers: allDocketNumbers.map(item => `case|${item}`), ttl: 900, }); @@ -105,27 +108,36 @@ export const setTrialSessionCalendarInteractor = async ( const funcs = [ ...manuallyAddedQcIncompleteCases.map( caseRecord => () => - removeManuallyAddedCaseFromTrialSession({ - applicationContext, - caseRecord, - trialSessionEntity, - }), + removeManuallyAddedCaseFromTrialSession( + { + applicationContext, + caseRecord, + trialSessionEntity, + }, + authorizedUser, + ), ), ...manuallyAddedQcCompleteCases.map( aCase => () => - setManuallyAddedCaseAsCalendared({ - applicationContext, - caseRecord: aCase, - trialSessionEntity, - }), + setManuallyAddedCaseAsCalendared( + { + applicationContext, + caseRecord: aCase, + trialSessionEntity, + }, + authorizedUser, + ), ), ...eligibleCases.map( aCase => () => - setTrialSessionCalendarForEligibleCase({ - applicationContext, - caseRecord: aCase, - trialSessionEntity, - }), + setTrialSessionCalendarForEligibleCase( + { + applicationContext, + caseRecord: aCase, + trialSessionEntity, + }, + authorizedUser, + ), ), ]; @@ -158,13 +170,14 @@ export const setTrialSessionCalendarInteractor = async ( action: 'set_trial_session_calendar_complete', trialSessionId, }, - userId: user.userId, + userId: authorizedUser.userId, }); } catch (error: any) { applicationContext.logger.error( `Error setting trial session calendar for trialSessionId: ${trialSessionId}`, ); applicationContext.logger.error(error); + console.log(error); await applicationContext.getNotificationGateway().sendNotificationToUser({ applicationContext, clientConnectionId, @@ -172,26 +185,29 @@ export const setTrialSessionCalendarInteractor = async ( action: 'set_trial_session_calendar_error', message: `Error setting trial session calendar: ${error?.message}`, }, - userId: user.userId, + userId: authorizedUser?.userId || '', }); } }; -const removeManuallyAddedCaseFromTrialSession = ({ - applicationContext, - caseRecord, - trialSessionEntity, -}: { - applicationContext: ServerApplicationContext; - caseRecord: RawCase; - trialSessionEntity: TrialSession; -}): Promise => { +const removeManuallyAddedCaseFromTrialSession = ( + { + applicationContext, + caseRecord, + trialSessionEntity, + }: { + applicationContext: ServerApplicationContext; + caseRecord: RawCase; + trialSessionEntity: TrialSession; + }, + authorizedUser: AuthUser, +): Promise => { trialSessionEntity.deleteCaseFromCalendar({ docketNumber: caseRecord.docketNumber, }); const caseEntity = new Case(caseRecord, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); caseEntity.removeFromTrialWithAssociatedJudge(); @@ -202,16 +218,19 @@ const removeManuallyAddedCaseFromTrialSession = ({ }); }; -const setManuallyAddedCaseAsCalendared = async ({ - applicationContext, - caseRecord, - trialSessionEntity, -}: { - applicationContext: ServerApplicationContext; - caseRecord: RawCase; - trialSessionEntity: TrialSession; -}): Promise => { - const caseEntity = new Case(caseRecord, { applicationContext }); +const setManuallyAddedCaseAsCalendared = async ( + { + applicationContext, + caseRecord, + trialSessionEntity, + }: { + applicationContext: ServerApplicationContext; + caseRecord: RawCase; + trialSessionEntity: TrialSession; + }, + authorizedUser: AuthUser, +): Promise => { + const caseEntity = new Case(caseRecord, { authorizedUser }); caseEntity.setAsCalendared(trialSessionEntity); @@ -229,16 +248,19 @@ const setManuallyAddedCaseAsCalendared = async ({ ]); }; -const setTrialSessionCalendarForEligibleCase = async ({ - applicationContext, - caseRecord, - trialSessionEntity, -}: { - applicationContext: ServerApplicationContext; - caseRecord: RawCase; - trialSessionEntity: TrialSession; -}): Promise => { - const caseEntity = new Case(caseRecord, { applicationContext }); +const setTrialSessionCalendarForEligibleCase = async ( + { + applicationContext, + caseRecord, + trialSessionEntity, + }: { + applicationContext: ServerApplicationContext; + caseRecord: RawCase; + trialSessionEntity: TrialSession; + }, + authorizedUser: AuthUser, +): Promise => { + const caseEntity = new Case(caseRecord, { authorizedUser }); caseEntity.setAsCalendared(trialSessionEntity); trialSessionEntity.addCaseToCalendar(caseEntity); From 988d0a47ba15b33d03dc96051d0d3b43f774feeb Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 14:48:23 -0700 Subject: [PATCH 349/523] 10417: remove getCurrentUser --- .../setNoticeOfChangeOfTrialJudge.test.ts | 33 ++++++++++++------- .../setNoticeOfChangeOfTrialJudge.ts | 4 ++- .../updateTrialSessionInteractor.ts | 24 +++++++++----- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts index 3288e0b5999..62f8be020f3 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.test.ts @@ -5,6 +5,7 @@ import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/busin import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getFakeFile } from '../../../../../shared/src/business/test/getFakeFile'; import { getJudgeWithTitle } from '@shared/business/utilities/getJudgeWithTitle'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { setNoticeOfChangeOfTrialJudge } from './setNoticeOfChangeOfTrialJudge'; jest.mock('@shared/business/utilities/getJudgeWithTitle', () => ({ @@ -53,12 +54,16 @@ describe('setNoticeOfChangeOfTrialJudge', () => { }); it('should retrieve the judge title and fullname for the current and new judges', async () => { - await setNoticeOfChangeOfTrialJudge(applicationContext, { - caseEntity: mockOpenCase, - currentTrialSession, - newPdfDoc: getFakeFile, - newTrialSessionEntity: updatedTrialSession, - }); + await setNoticeOfChangeOfTrialJudge( + applicationContext, + { + caseEntity: mockOpenCase, + currentTrialSession, + newPdfDoc: getFakeFile, + newTrialSessionEntity: updatedTrialSession, + }, + mockDocketClerkUser, + ); expect(getJudgeWithTitle.mock.calls[0][0]).toMatchObject({ judgeUserName: currentTrialSession.judge.name, @@ -71,12 +76,16 @@ describe('setNoticeOfChangeOfTrialJudge', () => { }); it('should create a docket entry and serve the generated notice', async () => { - await setNoticeOfChangeOfTrialJudge(applicationContext, { - caseEntity: mockOpenCase, - currentTrialSession, - newPdfDoc: getFakeFile, - newTrialSessionEntity: updatedTrialSession, - }); + await setNoticeOfChangeOfTrialJudge( + applicationContext, + { + caseEntity: mockOpenCase, + currentTrialSession, + newPdfDoc: getFakeFile, + newTrialSessionEntity: updatedTrialSession, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().createAndServeNoticeDocketEntry diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.ts index 046af028757..bc448ac0b18 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { getJudgeWithTitle } from '../../../../../shared/src/business/utilities/getJudgeWithTitle'; @@ -5,6 +6,7 @@ import { getJudgeWithTitle } from '../../../../../shared/src/business/utilities/ export const setNoticeOfChangeOfTrialJudge = async ( applicationContext: ServerApplicationContext, { caseEntity, currentTrialSession, newPdfDoc, newTrialSessionEntity }, + authorizedUser: AuthUser, ) => { const priorJudgeTitleWithFullName = await getJudgeWithTitle({ applicationContext, @@ -44,6 +46,6 @@ export const setNoticeOfChangeOfTrialJudge = async ( newPdfDoc, noticePdf, }, - applicationContext.getCurrentUser(), + authorizedUser, ); }; diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index 39aa962ed95..5952e8a0719 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -1,4 +1,8 @@ /* eslint-disable complexity */ +import { + AuthUser, + UnknownAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { NotFoundError } from '../../../errors/errors'; import { @@ -13,7 +17,6 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; import { TRIAL_SESSION_PROCEEDING_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { TrialSessionWorkingCopy } from '../../../../../shared/src/business/entities/trialSessions/TrialSessionWorkingCopy'; import { UnauthorizedError } from '@web-api/errors/errors'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { get } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -222,7 +225,7 @@ const updateCasesAndSetNoticeOfChange = async ({ currentTrialSession: RawTrialSession; paperServicePdfsCombined: any; updatedTrialSessionEntity: TrialSession; - authorizedUser: any; + authorizedUser: AuthUser; shouldSetNoticeOfChangeToRemoteProceeding: boolean; shouldSetNoticeOfChangeToInPersonProceeding: boolean; shouldIssueNoticeOfChangeOfTrialJudge: boolean; @@ -254,7 +257,6 @@ const updateCasesAndSetNoticeOfChange = async ({ caseEntity, newPdfDoc: paperServicePdfsCombined, newTrialSessionEntity: updatedTrialSessionEntity, - user: authorizedUser, }); } @@ -275,12 +277,16 @@ const updateCasesAndSetNoticeOfChange = async ({ if (shouldIssueNoticeOfChangeOfTrialJudge) { await applicationContext .getUseCaseHelpers() - .setNoticeOfChangeOfTrialJudge(applicationContext, { - caseEntity, - currentTrialSession, - newPdfDoc: paperServicePdfsCombined, - newTrialSessionEntity: updatedTrialSessionEntity, - }); + .setNoticeOfChangeOfTrialJudge( + applicationContext, + { + caseEntity, + currentTrialSession, + newPdfDoc: paperServicePdfsCombined, + newTrialSessionEntity: updatedTrialSessionEntity, + }, + authorizedUser, + ); } caseEntity.updateTrialSessionInformation(updatedTrialSessionEntity); From c69cb4a535c76c4b4f5300eafc2bc396d4603d17 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 14:52:42 -0700 Subject: [PATCH 350/523] 10417: remove getCurrentUser --- .../generateNoticesForCaseTrialSessionCalendarInteractor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index 7aff933867f..e485a3b3303 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -267,7 +267,7 @@ const setNoticeForCase = async ({ judge: trialSessionEntity.judge.name, processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, }, - { authorizedUser: applicationContext.getCurrentUser() }, + { authorizedUser: undefined }, ); standingPretrialDocketEntry.setFiledBy(user); From 97e8f4acca881c96cf9106691e18d16611df7f9f Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 16:58:10 -0500 Subject: [PATCH 351/523] 10417 some cleanup in generateTrialSessionPaperServicePdfInteractor --- ...alSessionPaperServicePdfInteractor.test.ts | 45 ++++++++++++------- ...teTrialSessionPaperServicePdfInteractor.ts | 12 ++--- ...aredTrialSessionInteractor.locking.test.ts | 14 +++--- ...icesForCalendaredTrialSessionInteractor.ts | 11 +++-- 4 files changed, 48 insertions(+), 34 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.test.ts b/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.test.ts index 9ad28673ca8..89ce5e6802a 100644 --- a/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.test.ts @@ -1,7 +1,10 @@ import { MOCK_TRIAL_INPERSON } from '@shared/test/mockTrial'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { generateTrialSessionPaperServicePdfInteractor } from './generateTrialSessionPaperServicePdfInteractor'; -import { petitionerUser, petitionsClerkUser } from '@shared/test/mockUsers'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; import { testPdfDoc } from '../../../../../shared/src/business/test/getFakeFile'; describe('generateTrialSessionPaperServicePdfInteractor', () => { @@ -9,8 +12,6 @@ describe('generateTrialSessionPaperServicePdfInteractor', () => { const mockFileId = '46f3244d-aaca-48c8-a7c1-de561d000c90'; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - applicationContext .getPersistenceGateway() .getDocument.mockResolvedValue(testPdfDoc); @@ -24,13 +25,15 @@ describe('generateTrialSessionPaperServicePdfInteractor', () => { }); it('should return an unauthorized error when the user does not have the TRIAL_SESSIONS permission', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); // Petitioners do not have permission to manage trial sessions - await expect( - generateTrialSessionPaperServicePdfInteractor(applicationContext, { - trialNoticePdfsKeys: ['1234-56'], - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }), + generateTrialSessionPaperServicePdfInteractor( + applicationContext, + { + trialNoticePdfsKeys: ['1234-56'], + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); @@ -40,10 +43,14 @@ describe('generateTrialSessionPaperServicePdfInteractor', () => { .getPersistenceGateway() .getTrialSessionById.mockResolvedValue(MOCK_TRIAL_INPERSON); - await generateTrialSessionPaperServicePdfInteractor(applicationContext, { - trialNoticePdfsKeys: mockTrialNoticePdfsKeys, - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }); + await generateTrialSessionPaperServicePdfInteractor( + applicationContext, + { + trialNoticePdfsKeys: mockTrialNoticePdfsKeys, + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().getDocument, @@ -70,10 +77,14 @@ describe('generateTrialSessionPaperServicePdfInteractor', () => { }); it('should send a notification to the user when combining the paper service documents is complete', async () => { - await generateTrialSessionPaperServicePdfInteractor(applicationContext, { - trialNoticePdfsKeys: ['123-56'], - trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, - }); + await generateTrialSessionPaperServicePdfInteractor( + applicationContext, + { + trialNoticePdfsKeys: ['123-56'], + trialSessionId: MOCK_TRIAL_INPERSON.trialSessionId!, + }, + mockPetitionsClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[2][0], diff --git a/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.ts b/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.ts index 23e250dc12d..a05d1bfcd20 100644 --- a/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor.ts @@ -6,6 +6,7 @@ import { import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const generateTrialSessionPaperServicePdfInteractor = async ( applicationContext: ServerApplicationContext, @@ -18,10 +19,9 @@ export const generateTrialSessionPaperServicePdfInteractor = async ( trialSessionId: string; clientConnectionId: string; }, + authorizedUser: UnknownAuthUser, ): Promise => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.TRIAL_SESSIONS)) { throw new UnauthorizedError('Unauthorized'); } @@ -35,7 +35,7 @@ export const generateTrialSessionPaperServicePdfInteractor = async ( action: 'paper_service_started', totalPdfs: trialNoticePdfsKeys.length, }, - userId: user.userId, + userId: authorizedUser.userId, }); let pdfsAppended = 0; @@ -65,7 +65,7 @@ export const generateTrialSessionPaperServicePdfInteractor = async ( action: 'paper_service_updated', pdfsAppended, }, - userId: user.userId, + userId: authorizedUser.userId, }); } @@ -115,6 +115,6 @@ export const generateTrialSessionPaperServicePdfInteractor = async ( hasPaper: true, pdfUrl, }, - userId: user.userId, + userId: authorizedUser.userId, }); }; diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts index b25d44a54ec..2058b805aa7 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts @@ -9,7 +9,7 @@ import { handleLockError, setNoticesForCalendaredTrialSessionInteractor, } from './setNoticesForCalendaredTrialSessionInteractor'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; +import { mockTrialClerkUser } from '@shared/test/mockAuthUsers'; describe('determineEntitiesToLock', () => { const trialSessionId = '6805d1ab-18d0-43ec-bafb-654e83405416'; @@ -61,7 +61,7 @@ describe('handleLockError', () => { await handleLockError( applicationContext, mockOriginalRequest, - mockDocketClerkUser, + mockTrialClerkUser, ); expect( @@ -123,7 +123,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { setNoticesForCalendaredTrialSessionInteractor( applicationContext, mockRequest, - mockDocketClerkUser, + mockTrialClerkUser, ), ).rejects.toThrow(ServiceUnavailableError); @@ -137,7 +137,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { setNoticesForCalendaredTrialSessionInteractor( applicationContext, mockRequest, - mockDocketClerkUser, + mockTrialClerkUser, ), ).rejects.toThrow(ServiceUnavailableError); @@ -150,7 +150,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { originalRequest: mockRequest, requestToRetry: 'set_notices_for_calendared_trial_session', }, - userId: mockDocketClerkUser.userId, + userId: mockTrialClerkUser.userId, }); expect( @@ -168,7 +168,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, mockRequest, - mockDocketClerkUser, + mockTrialClerkUser, ); expect( @@ -184,7 +184,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, mockRequest, - mockDocketClerkUser, + mockTrialClerkUser, ); const expectedIdentifiers = mockCases.map( diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts index 13b7413f6ef..3e9fcb8a1f9 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts @@ -7,6 +7,7 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generateTrialSessionPaperServicePdfInteractor } from '@web-api/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; const setNoticesForCalendaredTrialSession = async ( @@ -164,13 +165,15 @@ const setNoticesForCalendaredTrialSession = async ( }); if (trialNoticePdfsKeys.length) { - await applicationContext - .getUseCases() - .generateTrialSessionPaperServicePdfInteractor(applicationContext, { + await generateTrialSessionPaperServicePdfInteractor( + applicationContext, + { clientConnectionId, trialNoticePdfsKeys, trialSessionId, - }); + }, + authorizedUser, + ); } }; From ce83af31dcf48c8a07c805fefb5defea6302a89b Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 22 Jul 2024 17:01:50 -0500 Subject: [PATCH 352/523] 10417 remove getCurrentUser from serveCaseToIrsInteractor.addDocketEntryForPaymentstatus.test --- ...teractor.addDocketEntryForPaymentStatus.test.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.addDocketEntryForPaymentStatus.test.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.addDocketEntryForPaymentStatus.test.ts index 23f9342a931..770c2cc569a 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.addDocketEntryForPaymentStatus.test.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.addDocketEntryForPaymentStatus.test.ts @@ -2,15 +2,13 @@ import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { PAYMENT_STATUS } from '../../../../../shared/src/business/entities/EntityConstants'; import { addDocketEntryForPaymentStatus } from './serveCaseToIrsInteractor'; -import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { mockPetitionsClerkUser } from '@shared/test/mockAuthUsers'; +import { + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('addDocketEntryForPaymentStatus', () => { - let user; - - beforeEach(() => { - user = applicationContext.getCurrentUser(); - }); + let user = mockPetitionerUser; it('adds a docketRecord for a paid petition payment', async () => { const caseEntity = new Case( @@ -22,7 +20,6 @@ describe('addDocketEntryForPaymentStatus', () => { { authorizedUser: mockPetitionsClerkUser }, ); await addDocketEntryForPaymentStatus({ - applicationContext, caseEntity, user, }); @@ -47,7 +44,6 @@ describe('addDocketEntryForPaymentStatus', () => { { authorizedUser: mockPetitionsClerkUser }, ); await addDocketEntryForPaymentStatus({ - applicationContext, caseEntity, user, }); From 3a46616ec6d4cee700d1cbd88e7b3840c9ee57b3 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 15:16:04 -0700 Subject: [PATCH 353/523] 10417: remove getCurrentUser --- .../updatePractitionerUserInteractor.ts | 1 + .../useCases/user/generateChangeOfAddress.ts | 6 +++++- ...ssForPractitioner.irsPractitioners.test.ts | 10 ++++++--- ...rPractitioner.privatePractitioners.test.ts | 14 ++++++++++--- .../updateUserContactInformationInteractor.ts | 21 +++++++++++++------ 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts index 1e0c58385d5..c1f70787990 100644 --- a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts +++ b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts @@ -128,6 +128,7 @@ export const updatePractitionerUser = async ( if (combinedDiffKeys.length > propertiesNotRequiringChangeOfAddress.length) { await generateChangeOfAddress({ applicationContext, + authorizedUser, bypassDocketEntry, contactInfo: validatedUserData.contact, firmName: validatedUserData.firmName, diff --git a/web-api/src/business/useCases/user/generateChangeOfAddress.ts b/web-api/src/business/useCases/user/generateChangeOfAddress.ts index 3c87a59a2d3..695132da6c9 100644 --- a/web-api/src/business/useCases/user/generateChangeOfAddress.ts +++ b/web-api/src/business/useCases/user/generateChangeOfAddress.ts @@ -1,4 +1,5 @@ import { ALLOWLIST_FEATURE_FLAGS } from '@shared/business/entities/EntityConstants'; +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { SQSClient, SendMessageCommand } from '@aws-sdk/client-sqs'; import { ServerApplicationContext } from '@web-api/applicationContext'; @@ -31,6 +32,7 @@ export type TUserContact = { */ const generateChangeOfAddressForPractitioner = async ({ applicationContext, + authorizedUser, bypassDocketEntry = false, contactInfo, firmName, @@ -49,6 +51,7 @@ const generateChangeOfAddressForPractitioner = async ({ updatedName?: string; user: any; websocketMessagePrefix?: string; + authorizedUser: AuthUser; }): Promise => { const associatedUserCases = await applicationContext .getPersistenceGateway() @@ -100,7 +103,7 @@ const generateChangeOfAddressForPractitioner = async ({ firmName, jobId, requestUser: { - ...applicationContext.getCurrentUser(), + ...authorizedUser, token: undefined, }, requestUserId, @@ -120,6 +123,7 @@ const generateChangeOfAddressForPractitioner = async ({ .getUseCaseHelpers() .generateChangeOfAddressHelper({ applicationContext, + authorizedUser, bypassDocketEntry, contactInfo, docketNumber: caseInfo.docketNumber, diff --git a/web-api/src/business/useCases/user/generateChangeOfAddressForPractitioner.irsPractitioners.test.ts b/web-api/src/business/useCases/user/generateChangeOfAddressForPractitioner.irsPractitioners.test.ts index 8dbf66d62ee..567e3a2522e 100644 --- a/web-api/src/business/useCases/user/generateChangeOfAddressForPractitioner.irsPractitioners.test.ts +++ b/web-api/src/business/useCases/user/generateChangeOfAddressForPractitioner.irsPractitioners.test.ts @@ -6,8 +6,8 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; import { generateChangeOfAddress } from './generateChangeOfAddress'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; jest.mock('../addCoversheetInteractor', () => ({ addCoverToPdf: jest.fn().mockReturnValue({ @@ -56,8 +56,6 @@ describe('generateChangeOfAddress', () => { }; beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getUseCaseHelpers() .updateCaseAndAssociations.mockImplementation( @@ -87,6 +85,7 @@ describe('generateChangeOfAddress', () => { it('should run a change of address when address1 changes for an irs practitioner', async () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, bypassDocketEntry: false, contactInfo: { ...mockIrsPractitioner.contact, @@ -117,6 +116,7 @@ describe('generateChangeOfAddress', () => { it('should not set partyIrsPractitioner if role is not irsPractitioner', async () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, bypassDocketEntry: false, contactInfo: { ...mockIrsPractitioner.contact, @@ -141,6 +141,7 @@ describe('generateChangeOfAddress', () => { it('should send a notification to the user initially and after each case is updated', async () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, bypassDocketEntry: false, contactInfo: { ...mockIrsPractitioner.contact, @@ -180,6 +181,7 @@ describe('generateChangeOfAddress', () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, bypassDocketEntry: false, contactInfo: { ...mockIrsPractitioner.contact, @@ -206,6 +208,7 @@ describe('generateChangeOfAddress', () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, bypassDocketEntry: false, contactInfo: { ...mockIrsPractitioner.contact, @@ -236,6 +239,7 @@ describe('generateChangeOfAddress', () => { it('should set isAutoGenerated to true on the generated "Notice of Change of Address" document', async () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, bypassDocketEntry: false, contactInfo: { ...mockIrsPractitioner.contact, diff --git a/web-api/src/business/useCases/user/generateChangeOfAddressForPractitioner.privatePractitioners.test.ts b/web-api/src/business/useCases/user/generateChangeOfAddressForPractitioner.privatePractitioners.test.ts index e7258c8ae59..f591aeb8036 100644 --- a/web-api/src/business/useCases/user/generateChangeOfAddressForPractitioner.privatePractitioners.test.ts +++ b/web-api/src/business/useCases/user/generateChangeOfAddressForPractitioner.privatePractitioners.test.ts @@ -7,8 +7,8 @@ import { import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { calculateISODate } from '../../../../../shared/src/business/utilities/DateHandler'; -import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; import { generateChangeOfAddress } from './generateChangeOfAddress'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; jest.mock('../addCoversheetInteractor', () => ({ addCoverToPdf: jest.fn().mockReturnValue({ @@ -66,8 +66,6 @@ describe('generateChangeOfAddress', () => { ); }); beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getCasesForUser.mockReturnValue([{ docketNumber }]); @@ -123,6 +121,7 @@ describe('generateChangeOfAddress', () => { }); await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, contactInfo: { ...mockPrivatePractitioner.contact, address1: '234 Main St', @@ -152,6 +151,7 @@ describe('generateChangeOfAddress', () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, contactInfo: { ...mockPrivatePractitioner.contact, address1: '234 Main St', @@ -180,6 +180,7 @@ describe('generateChangeOfAddress', () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, contactInfo: { ...mockPrivatePractitioner.contact, address1: '234 Main St', @@ -201,6 +202,7 @@ describe('generateChangeOfAddress', () => { it("should NOT create a work item for an associated practitioner's notice of change of address when there is no paper service for the case", async () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, contactInfo: { ...mockPrivatePractitioner.contact, address1: '234 Main St', @@ -222,6 +224,7 @@ describe('generateChangeOfAddress', () => { it('should not create a docket entry, work item, or serve anything if the bypassDocketEntry flag is true', async () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, bypassDocketEntry: true, contactInfo: { ...mockPrivatePractitioner.contact, @@ -255,6 +258,7 @@ describe('generateChangeOfAddress', () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, contactInfo: { ...mockPrivatePractitioner.contact, address1: '234 Main St', @@ -287,6 +291,7 @@ describe('generateChangeOfAddress', () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, contactInfo: { ...mockPrivatePractitioner.contact, address1: '234 Main St', @@ -321,6 +326,7 @@ describe('generateChangeOfAddress', () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, contactInfo: { ...mockPrivatePractitioner.contact, address1: '234 Main St', @@ -364,6 +370,7 @@ describe('generateChangeOfAddress', () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, contactInfo: { ...mockPrivatePractitioner.contact, }, @@ -389,6 +396,7 @@ describe('generateChangeOfAddress', () => { it('should use original case caption to create case title when creating work item', async () => { await generateChangeOfAddress({ applicationContext, + authorizedUser: mockDocketClerkUser, contactInfo: { ...mockPrivatePractitioner.contact, address1: '234 Main St', diff --git a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts index 0583fe9c487..7fa81843309 100644 --- a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts @@ -1,3 +1,7 @@ +import { + AuthUser, + UnknownAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { IrsPractitioner } from '@shared/business/entities/IrsPractitioner'; import { Practitioner } from '../../../../../shared/src/business/entities/Practitioner'; import { PrivatePractitioner } from '../../../../../shared/src/business/entities/PrivatePractitioner'; @@ -7,7 +11,6 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { generateChangeOfAddress } from './generateChangeOfAddress'; import { isArray, isEqual } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -28,6 +31,7 @@ const updateUserContactInformationHelper = async ( firmName, userId, }: { contactInfo: any; firmName: string; userId: string }, + authorizedUser: AuthUser, ) => { const user = await applicationContext .getPersistenceGateway() @@ -100,6 +104,7 @@ const updateUserContactInformationHelper = async ( const results = await generateChangeOfAddress({ applicationContext, + authorizedUser, contactInfo, firmName, user: userEntity.validate().toRawObject(), @@ -148,11 +153,15 @@ export const updateUserContactInformation = async ( } try { - await updateUserContactInformationHelper(applicationContext, { - contactInfo, - firmName, - userId, - }); + await updateUserContactInformationHelper( + applicationContext, + { + contactInfo, + firmName, + userId, + }, + authorizedUser, + ); } catch (error) { applicationContext.logger.error(error); await applicationContext.getNotificationGateway().sendNotificationToUser({ From 99bfaf0c64a8180c4be0e930a3ca883a60e6de53 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 15:20:12 -0700 Subject: [PATCH 354/523] 10417: remove getCurrentUser --- ...etNoticeOfChangeToRemoteProceeding.test.ts | 19 +++++++++++++------ .../setNoticeOfChangeToRemoteProceeding.ts | 4 +++- .../updateTrialSessionInteractor.ts | 14 +++++++++----- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts index b868fd7a5e5..87e5dcdce22 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.test.ts @@ -6,7 +6,10 @@ import { } from '../../../../../shared/src/test/mockTrial'; import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; +import { + mockDocketClerkUser, + mockTrialClerkUser, +} from '@shared/test/mockAuthUsers'; import { setNoticeOfChangeToRemoteProceeding } from './setNoticeOfChangeToRemoteProceeding'; describe('setNoticeOfChangeToRemoteProceeding', () => { @@ -31,11 +34,15 @@ describe('setNoticeOfChangeToRemoteProceeding', () => { }); it('should generate and serve a NORP when the proceeding type changes from in person to remote and the case status is not closed', async () => { - await setNoticeOfChangeToRemoteProceeding(applicationContext, { - caseEntity: mockOpenCase, - newPdfDoc: mockNewPdf, - newTrialSessionEntity: MOCK_TRIAL_REMOTE, - }); + await setNoticeOfChangeToRemoteProceeding( + applicationContext, + { + caseEntity: mockOpenCase, + newPdfDoc: mockNewPdf, + newTrialSessionEntity: MOCK_TRIAL_REMOTE, + }, + mockTrialClerkUser, + ); expect( applicationContext.getUseCases() diff --git a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.ts b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.ts index 7959664dcd1..cd9b931b3a2 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeToRemoteProceeding.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '@shared/business/entities/cases/Case'; import { SYSTEM_GENERATED_DOCUMENT_TYPES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServerApplicationContext } from '@web-api/applicationContext'; @@ -30,6 +31,7 @@ export const setNoticeOfChangeToRemoteProceeding = async ( newPdfDoc, newTrialSessionEntity, }: { caseEntity: Case; newPdfDoc: any; newTrialSessionEntity: any }, + authorizedUser: AuthUser, ): Promise => { const trialSessionInformation: TrialSessionInformationType = { chambersPhoneNumber: newTrialSessionEntity.chambersPhoneNumber, @@ -58,6 +60,6 @@ export const setNoticeOfChangeToRemoteProceeding = async ( newPdfDoc, noticePdf, }, - applicationContext.getCurrentUser(), + authorizedUser, ); }; diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index 5952e8a0719..47346c12697 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -253,11 +253,15 @@ const updateCasesAndSetNoticeOfChange = async ({ if (shouldSetNoticeOfChangeToRemoteProceeding) { await applicationContext .getUseCaseHelpers() - .setNoticeOfChangeToRemoteProceeding(applicationContext, { - caseEntity, - newPdfDoc: paperServicePdfsCombined, - newTrialSessionEntity: updatedTrialSessionEntity, - }); + .setNoticeOfChangeToRemoteProceeding( + applicationContext, + { + caseEntity, + newPdfDoc: paperServicePdfsCombined, + newTrialSessionEntity: updatedTrialSessionEntity, + }, + authorizedUser, + ); } if (shouldSetNoticeOfChangeToInPersonProceeding) { From 522ce1994a7e52c10e992650144ac3c4efd0df02 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 15:42:48 -0700 Subject: [PATCH 355/523] 10417: remove getCurrentUser in the worker. Replace the user argument with authorizedUser. --- .../useCases/auth/changePasswordInteractor.ts | 2 +- .../user/queueUpdateAssociatedCasesWorker.ts | 2 +- .../user/updateAssociatedCaseWorker.test.ts | 171 ++++++++++++------ .../user/updateAssociatedCaseWorker.ts | 18 +- .../user/verifyUserPendingEmailInteractor.ts | 2 +- web-api/src/gateways/worker/worker.test.ts | 10 +- web-api/src/gateways/worker/workerLocal.ts | 2 +- .../src/gateways/worker/workerRouter.test.ts | 5 + web-api/src/gateways/worker/workerRouter.ts | 13 +- .../cognitoAuthorizer/worker-handler.ts | 2 +- 10 files changed, 150 insertions(+), 77 deletions(-) diff --git a/web-api/src/business/useCases/auth/changePasswordInteractor.ts b/web-api/src/business/useCases/auth/changePasswordInteractor.ts index 7634c8623e8..bc577db1cb1 100644 --- a/web-api/src/business/useCases/auth/changePasswordInteractor.ts +++ b/web-api/src/business/useCases/auth/changePasswordInteractor.ts @@ -73,9 +73,9 @@ export const changePasswordInteractor = async ( .getWorkerGateway() .queueWork(applicationContext, { message: { + authorizedUser: updatedUser, payload: { user: updatedUser }, type: MESSAGE_TYPES.QUEUE_UPDATE_ASSOCIATED_CASES, - user: updatedUser, }, }); } diff --git a/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.ts b/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.ts index ad71f821e1d..7f965bb3d0b 100644 --- a/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.ts +++ b/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.ts @@ -18,9 +18,9 @@ export const queueUpdateAssociatedCasesWorker = async ( docketNumbersAssociatedWithUser.map(docketNumber => applicationContext.getWorkerGateway().queueWork(applicationContext, { message: { + authorizedUser: applicationContext.getCurrentUser(), payload: { docketNumber, user }, type: MESSAGE_TYPES.UPDATE_ASSOCIATED_CASE, - user: applicationContext.getCurrentUser(), }, }), ), diff --git a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.test.ts b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.test.ts index 7329ce24951..ff127d1080e 100644 --- a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.test.ts +++ b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.test.ts @@ -16,6 +16,10 @@ import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '@shared/business/test/createTestApplicationContext'; import { calculateISODate } from '@shared/business/utilities/DateHandler'; import { getContactPrimary } from '@shared/business/entities/cases/Case'; +import { + mockPetitionerUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; import { updateAssociatedCaseWorker, updatePetitionerCase, @@ -71,10 +75,14 @@ describe('updateAssociatedCaseWorker', () => { privatePractitioners: [], }); - await updateAssociatedCaseWorker(applicationContext, { - docketNumber: '101-18', - user: mockPractitioner, - }); + await updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: '101-18', + user: mockPractitioner, + }, + mockPrivatePractitionerUser, + ); expect(applicationContext.logger.error.mock.calls[0][0]).toEqual( 'Could not find user|3ab77c88-1dd0-4adb-a03c-c466ad72d417 barNumber: RA3333 on 101-18', @@ -90,13 +98,17 @@ describe('updateAssociatedCaseWorker', () => { userId: 'cde00f40-56e8-46c2-94c3-b1155b89a203', }); - await updateAssociatedCaseWorker(applicationContext, { - docketNumber: '101-18', - user: { - ...mockPetitioner, - userId: 'cde00f40-56e8-46c2-94c3-b1155b89a203', + await updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: '101-18', + user: { + ...mockPetitioner, + userId: 'cde00f40-56e8-46c2-94c3-b1155b89a203', + }, }, - }); + mockPetitionerUser, + ); expect(applicationContext.logger.error.mock.calls[0][0]).toEqual( 'Could not find user|cde00f40-56e8-46c2-94c3-b1155b89a203 on 101-18', @@ -112,10 +124,14 @@ describe('updateAssociatedCaseWorker', () => { .getPersistenceGateway() .getLock.mockImplementation(() => MOCK_LOCK); await expect( - updateAssociatedCaseWorker(applicationContext, { - docketNumber: '123-45', - user: MOCK_PRACTITIONER, - }), + updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: '123-45', + user: MOCK_PRACTITIONER, + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -127,10 +143,14 @@ describe('updateAssociatedCaseWorker', () => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => undefined); - await updateAssociatedCaseWorker(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - user: MOCK_PRACTITIONER, - }); + await updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + user: MOCK_PRACTITIONER, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -142,10 +162,14 @@ describe('updateAssociatedCaseWorker', () => { }); it('should remove the lock', async () => { - await updateAssociatedCaseWorker(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - user: MOCK_PRACTITIONER, - }); + await updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + user: MOCK_PRACTITIONER, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getPersistenceGateway().removeLock, @@ -184,10 +208,14 @@ describe('updateAssociatedCaseWorker', () => { ...mockCase, privatePractitioners: [], }); - await updateAssociatedCaseWorker(applicationContext, { - docketNumber: mockCase.docketNumber, - user: mockPetitioner, - }); + await updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: mockCase.docketNumber, + user: mockPetitioner, + }, + mockPetitionerUser, + ); const { servedParties } = applicationContext.getUseCaseHelpers().generateAndServeDocketEntry.mock .calls[0][0]; @@ -197,10 +225,14 @@ describe('updateAssociatedCaseWorker', () => { }); it("should update the user's case with the new email", async () => { - await updateAssociatedCaseWorker(applicationContext, { - docketNumber: mockCase.docketNumber, - user: mockPractitioner, - }); + await updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: mockCase.docketNumber, + user: mockPractitioner, + }, + mockPrivatePractitionerUser, + ); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations, @@ -222,10 +254,14 @@ describe('updateAssociatedCaseWorker', () => { ); await expect( - updateAssociatedCaseWorker(applicationContext, { - docketNumber: mockCase.docketNumber, - user: mockPractitioner, - }), + updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: mockCase.docketNumber, + user: mockPractitioner, + }, + mockPrivatePractitionerUser, + ), ).rejects.toThrow('updateCaseAndAssociations failure'); expect( @@ -256,10 +292,14 @@ describe('updateAssociatedCaseWorker', () => { .getCaseByDocketNumber.mockReturnValue(mockCase); await expect( - updateAssociatedCaseWorker(applicationContext, { - docketNumber: mockCase.docketNumber, - user: mockPetitioner, - }), + updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: mockCase.docketNumber, + user: mockPetitioner, + }, + mockPetitionerUser, + ), ).resolves.toBeUndefined(); // has no return value expect( @@ -281,10 +321,14 @@ describe('updateAssociatedCaseWorker', () => { }); await expect( - updateAssociatedCaseWorker(applicationContext, { - docketNumber: mockCase.docketNumber, - user: mockPetitioner, - }), + updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: mockCase.docketNumber, + user: mockPetitioner, + }, + mockPetitionerUser, + ), ).resolves.toBeUndefined(); // has no return value expect( @@ -307,10 +351,14 @@ describe('updateAssociatedCaseWorker', () => { }); await expect( - updateAssociatedCaseWorker(applicationContext, { - docketNumber: mockCase.docketNumber, - user: mockPetitioner, - }), + updateAssociatedCaseWorker( + applicationContext, + { + docketNumber: mockCase.docketNumber, + user: mockPetitioner, + }, + mockPetitionerUser, + ), ).resolves.toBeUndefined(); // has no return value expect( @@ -321,7 +369,7 @@ describe('updateAssociatedCaseWorker', () => { }); describe('updatePetitionerCases', () => { const UPDATED_EMAIL = 'hello@example.com'; - const mockPetitionerUser = { + const mockPetitionerUser2 = { ...validUser, email: UPDATED_EMAIL, role: ROLES.petitioner, @@ -341,8 +389,9 @@ describe('updatePetitionerCases', () => { await updatePetitionerCase({ applicationContext, + authorizedUser: mockPetitionerUser2, docketNumber: MOCK_CASE.docketNumber, - user: mockPetitionerUser, + user: mockPetitionerUser2, }); expect( @@ -375,14 +424,15 @@ describe('updatePetitionerCases', () => { await expect( updatePetitionerCase({ applicationContext, + authorizedUser: mockPetitionerUser2, docketNumber: '101-21', - user: mockPetitionerUser, + user: mockPetitionerUser2, }), ).resolves.not.toThrow(); expect(applicationContext.logger.error).toHaveBeenCalledTimes(1); expect(applicationContext.logger.error).toHaveBeenCalledWith( - `Could not find user|${mockPetitionerUser.userId} on ${caseMock.docketNumber}`, + `Could not find user|${mockPetitionerUser2.userId} on ${caseMock.docketNumber}`, ); expect( applicationContext.getUseCaseHelpers().updateCaseAndAssociations, @@ -401,8 +451,9 @@ describe('updatePetitionerCases', () => { await expect( updatePetitionerCase({ applicationContext, + authorizedUser: mockPetitionerUser2, docketNumber: MOCK_CASE.docketNumber, - user: mockPetitionerUser, + user: mockPetitionerUser2, }), ).rejects.toThrow('entity was invalid'); @@ -424,7 +475,7 @@ describe('updatePetitionerCases', () => { }, { ...MOCK_CASE.petitioners[0], - contactId: mockPetitionerUser.userId, + contactId: mockPetitionerUser2.userId, contactType: CONTACT_TYPES.secondary, inCareOf: 'Barney', }, @@ -433,8 +484,9 @@ describe('updatePetitionerCases', () => { await updatePetitionerCase({ applicationContext, + authorizedUser: mockPetitionerUser2, docketNumber: MOCK_CASE.docketNumber, - user: mockPetitionerUser, + user: mockPetitionerUser2, }); const { caseToUpdate } = @@ -457,7 +509,7 @@ describe('updatePetitionerCases', () => { }, { ...MOCK_CASE.petitioners[0], - contactId: mockPetitionerUser.userId, + contactId: mockPetitionerUser2.userId, contactType: CONTACT_TYPES.secondary, inCareOf: 'Barney', serviceIndicator: SERVICE_INDICATOR_TYPES.SI_NONE, @@ -473,8 +525,9 @@ describe('updatePetitionerCases', () => { await updatePetitionerCase({ applicationContext, + authorizedUser: mockPetitionerUser2, docketNumber: MOCK_CASE.docketNumber, - user: mockPetitionerUser, + user: mockPetitionerUser2, }); const { caseToUpdate } = @@ -497,7 +550,7 @@ describe('updatePetitionerCases', () => { ...MOCK_CASE.petitioners, { ...MOCK_CASE.petitioners[0], - contactId: mockPetitionerUser.userId, + contactId: mockPetitionerUser2.userId, contactType: CONTACT_TYPES.secondary, inCareOf: 'Barney', serviceIndicator: SERVICE_INDICATOR_TYPES.SI_NONE, @@ -506,15 +559,16 @@ describe('updatePetitionerCases', () => { privatePractitioners: [ { ...MOCK_ELIGIBLE_CASE_WITH_PRACTITIONERS.privatePractitioners[0], - representing: [mockPetitionerUser.userId], + representing: [mockPetitionerUser2.userId], }, ], }); await updatePetitionerCase({ applicationContext, + authorizedUser: mockPetitionerUser2, docketNumber: MOCK_CASE.docketNumber, - user: mockPetitionerUser, + user: mockPetitionerUser2, }); const { caseToUpdate } = @@ -552,6 +606,7 @@ describe('updatePractitionerCases', () => { it('should set the service serviceIndicator to ELECTRONIC when confirming the email', async () => { await updatePractitionerCase({ applicationContext, + authorizedUser: mockPractitionerUser, docketNumber: MOCK_CASE.docketNumber, user: mockPractitionerUser, }); diff --git a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts index 4f25b2630f0..9dea2a09809 100644 --- a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts +++ b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '@shared/business/entities/cases/Case'; import { ROLES, @@ -10,9 +11,11 @@ import { aggregatePartiesForService } from '@shared/business/utilities/aggregate export const updateAssociatedCaseWorker = async ( applicationContext: ServerApplicationContext, { docketNumber, user }: { docketNumber: string; user: RawUser }, + authorizedUser: AuthUser, ): Promise => { await applicationContext.getUseCaseHelpers().acquireLock({ applicationContext, + authorizedUser, identifiers: [`case|${docketNumber}`], retries: 10, ttl: 900, @@ -22,6 +25,7 @@ export const updateAssociatedCaseWorker = async ( if (user.role === ROLES.petitioner) { await updatePetitionerCase({ applicationContext, + authorizedUser, docketNumber, user, }); @@ -33,6 +37,7 @@ export const updateAssociatedCaseWorker = async ( ) { await updatePractitionerCase({ applicationContext, + authorizedUser, docketNumber, user, }); @@ -46,12 +51,14 @@ export const updateAssociatedCaseWorker = async ( export const updatePetitionerCase = async ({ applicationContext, + authorizedUser, docketNumber, user, }: { applicationContext: ServerApplicationContext; docketNumber: string; user: RawUser; + authorizedUser: AuthUser; }): Promise => { const rawCaseToUpdate = await applicationContext .getPersistenceGateway() @@ -62,6 +69,7 @@ export const updatePetitionerCase = async ({ const caseToUpdate = await updateCaseEntityAndGenerateChange({ applicationContext, + authorizedUser, rawCaseData: rawCaseToUpdate, user, }); @@ -76,12 +84,14 @@ export const updatePetitionerCase = async ({ export const updatePractitionerCase = async ({ applicationContext, + authorizedUser, docketNumber, user, }: { applicationContext: ServerApplicationContext; docketNumber: string; user: any; + authorizedUser: AuthUser; }): Promise => { const caseToUpdate = await applicationContext .getPersistenceGateway() @@ -91,7 +101,7 @@ export const updatePractitionerCase = async ({ }); const caseEntity = new Case(caseToUpdate, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const practitionerObject = [ ...caseEntity.privatePractitioners, @@ -111,7 +121,7 @@ export const updatePractitionerCase = async ({ // we do this again so that it will convert '' to null const validatedCaseToUpdate = new Case(caseEntity, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }).validate(); await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ @@ -122,15 +132,17 @@ export const updatePractitionerCase = async ({ const updateCaseEntityAndGenerateChange = async ({ applicationContext, + authorizedUser, rawCaseData, user, }: { applicationContext: ServerApplicationContext; rawCaseData: RawCase; user: RawUser; + authorizedUser: AuthUser; }): Promise => { const caseEntity = new Case(rawCaseData, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const petitionerObject = caseEntity.getPetitionerById(user.userId); diff --git a/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts b/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts index 5ba90907e8e..c7af447e398 100644 --- a/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts +++ b/web-api/src/business/useCases/user/verifyUserPendingEmailInteractor.ts @@ -59,9 +59,9 @@ export const verifyUserPendingEmailInteractor = async ( await applicationContext.getWorkerGateway().queueWork(applicationContext, { message: { + authorizedUser, payload: { user: updatedUser }, type: MESSAGE_TYPES.QUEUE_UPDATE_ASSOCIATED_CASES, - user: authorizedUser, }, }); }; diff --git a/web-api/src/gateways/worker/worker.test.ts b/web-api/src/gateways/worker/worker.test.ts index bd541216976..ab4c28a6bfc 100644 --- a/web-api/src/gateways/worker/worker.test.ts +++ b/web-api/src/gateways/worker/worker.test.ts @@ -8,15 +8,15 @@ import { worker } from '@web-api/gateways/worker/worker'; describe('worker', () => { it('should use the messaging service to send the provided message to the environment`s message queue', async () => { const mockMessage: WorkerMessage = { - payload: { - abc: 'def', - }, - type: MESSAGE_TYPES.QUEUE_UPDATE_ASSOCIATED_CASES, - user: { + authorizedUser: { name: 'ignored', role: 'ignored', userId: 'ignored', }, + payload: { + abc: 'def', + }, + type: MESSAGE_TYPES.QUEUE_UPDATE_ASSOCIATED_CASES, }; const mockQueueUrl = 'www.send_a_message.com'; applicationContext.environment.workerQueueUrl = mockQueueUrl; diff --git a/web-api/src/gateways/worker/workerLocal.ts b/web-api/src/gateways/worker/workerLocal.ts index e9a18f162f5..458e8116ca2 100644 --- a/web-api/src/gateways/worker/workerLocal.ts +++ b/web-api/src/gateways/worker/workerLocal.ts @@ -13,7 +13,7 @@ export const workerLocal: WorkerHandler = async ( { message }: { message: WorkerMessage }, ): Promise => { // Simulate what happens on a deployed environment when a message is sent to SQS. - const appContext = createApplicationContext(message.user); + const appContext = createApplicationContext(message.authorizedUser); setTimeout( async () => { try { diff --git a/web-api/src/gateways/worker/workerRouter.test.ts b/web-api/src/gateways/worker/workerRouter.test.ts index 3d743173b02..c15ac250646 100644 --- a/web-api/src/gateways/worker/workerRouter.test.ts +++ b/web-api/src/gateways/worker/workerRouter.test.ts @@ -4,10 +4,12 @@ import { workerRouter, } from '@web-api/gateways/worker/workerRouter'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('workerRouter', () => { it('should make a call to update a user`s associated case when the message type is UPDATE_ASSOCIATED_CASE', async () => { const mockMessage: WorkerMessage = { + authorizedUser: mockDocketClerkUser, payload: { abc: '123', }, @@ -25,6 +27,7 @@ describe('workerRouter', () => { it('should make a call to queue a user`s associated cases for update when the message type is QUEUE_UPDATE_ASSOCIATED_CASES', async () => { const mockMessage: WorkerMessage = { + authorizedUser: mockDocketClerkUser, payload: { abc: '123', }, @@ -42,9 +45,11 @@ describe('workerRouter', () => { it('should throw an error when the message type provided was not recognized by the router', async () => { const mockMessage: WorkerMessage = { + authorizedUser: mockDocketClerkUser, payload: { abc: '123', }, + type: 'DOES_NOT_EXIST' as any, }; diff --git a/web-api/src/gateways/worker/workerRouter.ts b/web-api/src/gateways/worker/workerRouter.ts index bbf329ca265..25169b33242 100644 --- a/web-api/src/gateways/worker/workerRouter.ts +++ b/web-api/src/gateways/worker/workerRouter.ts @@ -1,13 +1,10 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { ServerApplicationContext } from '@web-api/applicationContext'; export type WorkerMessage = { payload: any; type: WorkerMessageType; - user: { - role: string; - userId: string; - name: string; - }; + authorizedUser: AuthUser; }; export const MESSAGE_TYPES = { @@ -30,7 +27,11 @@ export const workerRouter = async ( case MESSAGE_TYPES.UPDATE_ASSOCIATED_CASE: await applicationContext .getUseCases() - .updateAssociatedCaseWorker(applicationContext, message.payload); + .updateAssociatedCaseWorker( + applicationContext, + message.payload, + message.authorizedUser, + ); break; case MESSAGE_TYPES.QUEUE_UPDATE_ASSOCIATED_CASES: await applicationContext diff --git a/web-api/src/lambdas/cognitoAuthorizer/worker-handler.ts b/web-api/src/lambdas/cognitoAuthorizer/worker-handler.ts index 9191b1d4da9..f9deadf3861 100644 --- a/web-api/src/lambdas/cognitoAuthorizer/worker-handler.ts +++ b/web-api/src/lambdas/cognitoAuthorizer/worker-handler.ts @@ -9,6 +9,6 @@ export const workerHandler = async (event: SQSEvent): Promise => { const { Records } = event; const { body } = Records[0]; const message: WorkerMessage = JSON.parse(body); - const applicationContext = createApplicationContext(message.user); + const applicationContext = createApplicationContext(message.authorizedUser); await workerRouter(applicationContext, { message }); }; From 05790d7c0b95018e2ecab57f3a5706af1ecfb18e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 15:46:37 -0700 Subject: [PATCH 356/523] 10417: remove getCurrentUser in the worker. Replace the user argument with authorizedUser. --- .../useCases/serveCaseToIrs/generateDraftDocument.ts | 5 ++++- .../useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web-api/src/business/useCases/serveCaseToIrs/generateDraftDocument.ts b/web-api/src/business/useCases/serveCaseToIrs/generateDraftDocument.ts index 7fcd1861f7a..12603dfbb5b 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/generateDraftDocument.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/generateDraftDocument.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '@shared/business/entities/cases/Case'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { replaceBracketed } from '../../../../../shared/src/business/utilities/replaceBracketed'; @@ -12,6 +13,7 @@ import { replaceBracketed } from '../../../../../shared/src/business/utilities/r */ export const generateDraftDocument = async ({ applicationContext, + authorizedUser, caseEntity, document, replacements, @@ -20,6 +22,7 @@ export const generateDraftDocument = async ({ caseEntity: Case; document: any; replacements: string[]; + authorizedUser: AuthUser; }) => { const content = replaceBracketed(document.content, ...replacements); @@ -27,7 +30,7 @@ export const generateDraftDocument = async ({ .getUseCaseHelpers() .addDocketEntryForSystemGeneratedOrder({ applicationContext, - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, caseEntity, systemGeneratedDocument: { ...document, diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts index 57aca854265..bf3cd2374d5 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts @@ -553,6 +553,7 @@ export const serveCaseToIrs = async ( generatedDocuments.push( generateDraftDocument({ applicationContext, + authorizedUser, caseEntity, document: orderDesignatingPlaceOfTrial, replacements: [ @@ -574,6 +575,7 @@ export const serveCaseToIrs = async ( generatedDocuments.push( generateDraftDocument({ applicationContext, + authorizedUser, caseEntity, document: orderForFilingFee, replacements: [todayPlus30, todayPlus30], @@ -588,6 +590,7 @@ export const serveCaseToIrs = async ( generatedDocuments.push( generateDraftDocument({ applicationContext, + authorizedUser, caseEntity, document: orderForAmendedPetitionAndFilingFee, replacements: [formattedFiledDate, todayPlus30, todayPlus30], @@ -606,6 +609,7 @@ export const serveCaseToIrs = async ( generatedDocuments.push( generateDraftDocument({ applicationContext, + authorizedUser, caseEntity, document: orderForAmendedPetition, replacements: [formattedFiledDate, todayPlus60, todayPlus60], @@ -620,6 +624,7 @@ export const serveCaseToIrs = async ( generatedDocuments.push( generateDraftDocument({ applicationContext, + authorizedUser, caseEntity, document: orderPetitionersToShowCause, replacements: [formattedFiledDate, todayPlus60], From 858a6825fc498800dcffceadd0da5e1a1bfbede9 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 15:49:04 -0700 Subject: [PATCH 357/523] 10417: remove getCurrentUser in the worker. Replace the user argument with authorizedUser. --- web-api/src/lambdas/pdfGeneration/pdf-generation.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web-api/src/lambdas/pdfGeneration/pdf-generation.ts b/web-api/src/lambdas/pdfGeneration/pdf-generation.ts index 806d47fe735..2154661bf2e 100644 --- a/web-api/src/lambdas/pdfGeneration/pdf-generation.ts +++ b/web-api/src/lambdas/pdfGeneration/pdf-generation.ts @@ -36,8 +36,7 @@ export const changeOfAddressHandler = async event => { await applicationContext.getUseCaseHelpers().generateChangeOfAddressHelper({ applicationContext, - // TODO: 10417 - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser: eventBody.requestUser, bypassDocketEntry: eventBody.bypassDocketEntry, contactInfo: eventBody.contactInfo, docketNumber: eventBody.docketNumber, From d8c8d7fc3741eb85346f8977f4773df30e05d2d8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 22 Jul 2024 16:03:22 -0700 Subject: [PATCH 358/523] 10417: remove getCurrentUser in the worker. Replace the user argument with authorizedUser. --- .../queueUpdateAssociatedCasesWorker.test.ts | 60 ++++++++++++++----- .../user/queueUpdateAssociatedCasesWorker.ts | 4 +- web-api/src/gateways/worker/workerRouter.ts | 6 +- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.test.ts b/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.test.ts index 8aa1b0cfbdb..0b1a3cd8bee 100644 --- a/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.test.ts +++ b/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.test.ts @@ -11,11 +11,19 @@ describe('queueUpdateAssociatedCasesWorker', () => { applicationContext .getPersistenceGateway() .getDocketNumbersByUser.mockReturnValue(['111-20', '222-20', '333-20']); - applicationContext.getCurrentUser.mockReturnValue(MOCK_PRACTITIONER); - await queueUpdateAssociatedCasesWorker(applicationContext, { - user: MOCK_PRACTITIONER, - }); + await queueUpdateAssociatedCasesWorker( + applicationContext, + { + user: MOCK_PRACTITIONER, + }, + { + email: MOCK_PRACTITIONER.email!, + name: MOCK_PRACTITIONER.name, + role: MOCK_PRACTITIONER.role, + userId: MOCK_PRACTITIONER.userId, + }, + ); expect( await applicationContext.getPersistenceGateway().getDocketNumbersByUser, @@ -31,36 +39,46 @@ describe('queueUpdateAssociatedCasesWorker', () => { .getDocketNumbersByUser.mockReturnValue(['111-20', '222-20', '333-20']); applicationContext.getCurrentUser.mockReturnValue(MOCK_PRACTITIONER); applicationContext.getWorkerGateway().queueWork.mockReturnValue({}); + const authorizedUser = { + email: MOCK_PRACTITIONER.email!, + name: MOCK_PRACTITIONER.name, + role: MOCK_PRACTITIONER.role, + userId: MOCK_PRACTITIONER.userId, + }; - await queueUpdateAssociatedCasesWorker(applicationContext, { - user: MOCK_PRACTITIONER, - }); + await queueUpdateAssociatedCasesWorker( + applicationContext, + { + user: MOCK_PRACTITIONER, + }, + authorizedUser, + ); expect( applicationContext.getWorkerGateway().queueWork, ).toHaveBeenCalledWith(applicationContext, { message: { + authorizedUser, payload: { docketNumber: '111-20', user: MOCK_PRACTITIONER }, type: MESSAGE_TYPES.UPDATE_ASSOCIATED_CASE, - user: MOCK_PRACTITIONER, }, }); expect( applicationContext.getWorkerGateway().queueWork, ).toHaveBeenCalledWith(applicationContext, { message: { + authorizedUser, payload: { docketNumber: '222-20', user: MOCK_PRACTITIONER }, type: MESSAGE_TYPES.UPDATE_ASSOCIATED_CASE, - user: MOCK_PRACTITIONER, }, }); expect( applicationContext.getWorkerGateway().queueWork, ).toHaveBeenCalledWith(applicationContext, { message: { + authorizedUser, payload: { docketNumber: '333-20', user: MOCK_PRACTITIONER }, type: MESSAGE_TYPES.UPDATE_ASSOCIATED_CASE, - user: MOCK_PRACTITIONER, }, }); }); @@ -71,36 +89,46 @@ describe('queueUpdateAssociatedCasesWorker', () => { .getDocketNumbersByUser.mockReturnValue(['111-20', '222-20', '333-20']); applicationContext.getCurrentUser.mockReturnValue(petitionerUser); applicationContext.getWorkerGateway().queueWork.mockReturnValue({}); + const authorizedUser = { + email: petitionerUser.email, + name: petitionerUser.name, + role: petitionerUser.role, + userId: petitionerUser.userId, + }; - await queueUpdateAssociatedCasesWorker(applicationContext, { - user: petitionerUser, - }); + await queueUpdateAssociatedCasesWorker( + applicationContext, + { + user: petitionerUser, + }, + authorizedUser, + ); expect( applicationContext.getWorkerGateway().queueWork, ).toHaveBeenCalledWith(applicationContext, { message: { + authorizedUser, payload: { docketNumber: '111-20', user: petitionerUser }, type: MESSAGE_TYPES.UPDATE_ASSOCIATED_CASE, - user: petitionerUser, }, }); expect( applicationContext.getWorkerGateway().queueWork, ).toHaveBeenCalledWith(applicationContext, { message: { + authorizedUser, payload: { docketNumber: '222-20', user: petitionerUser }, type: MESSAGE_TYPES.UPDATE_ASSOCIATED_CASE, - user: petitionerUser, }, }); expect( applicationContext.getWorkerGateway().queueWork, ).toHaveBeenCalledWith(applicationContext, { message: { + authorizedUser, payload: { docketNumber: '333-20', user: petitionerUser }, type: MESSAGE_TYPES.UPDATE_ASSOCIATED_CASE, - user: petitionerUser, }, }); }); diff --git a/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.ts b/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.ts index 7f965bb3d0b..99031861223 100644 --- a/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.ts +++ b/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { MESSAGE_TYPES } from '@web-api/gateways/worker/workerRouter'; import { RawPractitioner } from '../../../../../shared/src/business/entities/Practitioner'; import { RawUser } from '../../../../../shared/src/business/entities/User'; @@ -6,6 +7,7 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; export const queueUpdateAssociatedCasesWorker = async ( applicationContext: ServerApplicationContext, { user }: { user: RawUser | RawPractitioner }, + authorizedUser: AuthUser, ): Promise => { const docketNumbersAssociatedWithUser = await applicationContext .getPersistenceGateway() @@ -18,7 +20,7 @@ export const queueUpdateAssociatedCasesWorker = async ( docketNumbersAssociatedWithUser.map(docketNumber => applicationContext.getWorkerGateway().queueWork(applicationContext, { message: { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, payload: { docketNumber, user }, type: MESSAGE_TYPES.UPDATE_ASSOCIATED_CASE, }, diff --git a/web-api/src/gateways/worker/workerRouter.ts b/web-api/src/gateways/worker/workerRouter.ts index 25169b33242..c61b7316710 100644 --- a/web-api/src/gateways/worker/workerRouter.ts +++ b/web-api/src/gateways/worker/workerRouter.ts @@ -36,7 +36,11 @@ export const workerRouter = async ( case MESSAGE_TYPES.QUEUE_UPDATE_ASSOCIATED_CASES: await applicationContext .getUseCases() - .queueUpdateAssociatedCasesWorker(applicationContext, message.payload); + .queueUpdateAssociatedCasesWorker( + applicationContext, + message.payload, + message.authorizedUser, + ); break; default: throw new Error( From 97b6685a207ffe5b92fd7fa2db984a70bdb6d300 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Tue, 23 Jul 2024 07:51:43 -0500 Subject: [PATCH 359/523] 10417 remove getCurrentUser from fileAndServeDocumentOnOneCase --- .../useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts index 66a6a4d63d4..7b47ed61a18 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts @@ -91,7 +91,7 @@ export const fileAndServeDocumentOnOneCase = async ({ }); return new Case(validRawCaseEntity, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser: user, }); }; From 5300ad62fe87490a14bb7965db09d95d8e8eaffa Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Tue, 23 Jul 2024 08:03:03 -0500 Subject: [PATCH 360/523] 10417 cont'd remove getCurrentUser from serveCourtIssuedDocumentInteractor --- ...rtIssuedDocumentInteractor.locking.test.ts | 38 +++++++++++++------ .../serveCourtIssuedDocumentInteractor.ts | 10 +++-- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.locking.test.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.locking.test.ts index 466e9be08a3..f13e3f1e207 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.locking.test.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.locking.test.ts @@ -9,6 +9,7 @@ import { serveCourtIssuedDocumentInteractor, } from './serveCourtIssuedDocumentInteractor'; import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { testPdfDoc } from '../../../../../shared/src/business/test/getFakeFile'; jest.mock('@web-api/business/useCases/addCoverToPdf'); @@ -53,17 +54,16 @@ describe('handleLockError', () => { .getUserById.mockReturnValue(docketClerkUser); }); - it('should determine who the user is based on applicationContext', async () => { - await handleLockError(applicationContext, { foo: 'bar' }); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it('should send a notification to the user with "retry_async_request" and the originalRequest', async () => { const mockOriginalRequest = { clientConnectionId: mockClientConnectionId, foo: 'bar', }; - await handleLockError(applicationContext, mockOriginalRequest); + await handleLockError( + applicationContext, + mockOriginalRequest, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -134,7 +134,11 @@ describe('serveCourtIssuedDocumentInteractor', () => { it('should throw a ServiceUnavailableError if a Case is currently locked', async () => { await expect( - serveCourtIssuedDocumentInteractor(applicationContext, mockRequest), + serveCourtIssuedDocumentInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -144,7 +148,11 @@ describe('serveCourtIssuedDocumentInteractor', () => { it('should return a "retry_async_request" notification with the original request', async () => { await expect( - serveCourtIssuedDocumentInteractor(applicationContext, mockRequest), + serveCourtIssuedDocumentInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -157,7 +165,7 @@ describe('serveCourtIssuedDocumentInteractor', () => { originalRequest: mockRequest, requestToRetry: 'serve_court_issued_document', }, - userId: docketClerkUser.userId, + userId: mockDocketClerkUser.userId, }); expect( @@ -172,7 +180,11 @@ describe('serveCourtIssuedDocumentInteractor', () => { }); it('should acquire a lock that lasts for 15 minutes', async () => { - await serveCourtIssuedDocumentInteractor(applicationContext, mockRequest); + await serveCourtIssuedDocumentInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -184,7 +196,11 @@ describe('serveCourtIssuedDocumentInteractor', () => { }); it('should remove the lock', async () => { - await serveCourtIssuedDocumentInteractor(applicationContext, mockRequest); + await serveCourtIssuedDocumentInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().removeLock, diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts index a7c496603b9..6ad6c253b5d 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts @@ -213,9 +213,11 @@ export const determineEntitiesToLock = ( ttl: 15 * 60, }); -export const handleLockError = async (applicationContext, originalRequest) => { - const user = applicationContext.getCurrentUser(); - +export const handleLockError = async ( + applicationContext, + originalRequest, + authorizedUser: UnknownAuthUser, +) => { await applicationContext.getNotificationGateway().sendNotificationToUser({ applicationContext, clientConnectionId: originalRequest.clientConnectionId, @@ -224,7 +226,7 @@ export const handleLockError = async (applicationContext, originalRequest) => { originalRequest, requestToRetry: 'serve_court_issued_document', }, - userId: user.userId, + userId: authorizedUser?.userId || '', }); }; From 81004fa4bd11ffa52bc6cd6a9141f30cb03e373f Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Tue, 23 Jul 2024 08:26:56 -0500 Subject: [PATCH 361/523] 10417 remove getCurrentUser from updatePractitionerUserInteractor --- ...PractitionerUserInteractor.locking.test.ts | 38 +++++++++++++------ .../updatePractitionerUserInteractor.ts | 5 +-- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.locking.test.ts b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.locking.test.ts index 47c4d0627ca..7e34d5ca5dd 100644 --- a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.locking.test.ts +++ b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.locking.test.ts @@ -12,6 +12,7 @@ import { handleLockError, updatePractitionerUserInteractor, } from './updatePractitionerUserInteractor'; +import { mockAdmissionsClerkUser } from '@shared/test/mockAuthUsers'; describe('determineEntitiesToLock', () => { const mockPractitioner: RawPractitioner = MOCK_PRACTITIONER; @@ -55,17 +56,16 @@ describe('handleLockError', () => { .getUserById.mockReturnValue(admissionsClerkUser); }); - it('should determine who the user is based on applicationContext', async () => { - await handleLockError(applicationContext, { foo: 'bar' }); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it('should send a notification to the user with "retry_async_request" and the originalRequest', async () => { const mockOriginalRequest = { clientConnectionId: mockClientConnectionId, foo: 'bar', }; - await handleLockError(applicationContext, mockOriginalRequest); + await handleLockError( + applicationContext, + mockOriginalRequest, + mockAdmissionsClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -119,7 +119,11 @@ describe('updatePractitionerUserInteractor', () => { it('should throw a ServiceUnavailableError if a Case is currently locked', async () => { await expect( - updatePractitionerUserInteractor(applicationContext, mockRequest), + updatePractitionerUserInteractor( + applicationContext, + mockRequest, + mockAdmissionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -129,7 +133,11 @@ describe('updatePractitionerUserInteractor', () => { it('should return a "retry_async_request" notification with the original request', async () => { await expect( - updatePractitionerUserInteractor(applicationContext, mockRequest), + updatePractitionerUserInteractor( + applicationContext, + mockRequest, + mockAdmissionsClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -141,7 +149,7 @@ describe('updatePractitionerUserInteractor', () => { originalRequest: mockRequest, requestToRetry: 'update_practitioner_user', }, - userId: admissionsClerkUser.userId, + userId: mockAdmissionsClerkUser.userId, }); expect( @@ -156,7 +164,11 @@ describe('updatePractitionerUserInteractor', () => { }); it('should acquire a lock that lasts for 15 minutes', async () => { - await updatePractitionerUserInteractor(applicationContext, mockRequest); + await updatePractitionerUserInteractor( + applicationContext, + mockRequest, + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -167,7 +179,11 @@ describe('updatePractitionerUserInteractor', () => { }); }); it('should remove the lock', async () => { - await updatePractitionerUserInteractor(applicationContext, mockRequest); + await updatePractitionerUserInteractor( + applicationContext, + mockRequest, + mockAdmissionsClerkUser, + ); expect( applicationContext.getPersistenceGateway().removeLock, diff --git a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts index c1f70787990..e1143acb82e 100644 --- a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts +++ b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts @@ -207,9 +207,8 @@ const getUpdatedFieldNames = ({ export const handleLockError = async ( applicationContext: ServerApplicationContext, originalRequest: any, + authorizedUser: UnknownAuthUser, ) => { - const user = applicationContext.getCurrentUser(); - await applicationContext.getNotificationGateway().sendNotificationToUser({ applicationContext, clientConnectionId: originalRequest.clientConnectionId, @@ -218,7 +217,7 @@ export const handleLockError = async ( originalRequest, requestToRetry: 'update_practitioner_user', }, - userId: user.userId, + userId: authorizedUser?.userId || '', }); }; From 69e080c4bc7748cdbe8b4a79d62accbba830f668 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 23 Jul 2024 09:14:07 -0700 Subject: [PATCH 362/523] 10417: remove getCurrentUser --- .../generateChangeOfAddressTemplate.ts | 10 ++++++- .../generateChangeOfAddressHelper.ts | 11 +++++++ .../service/createChangeItems.test.ts | 1 + .../service/createChangeItems.ts | 30 ++++++++++++++++++- .../user/updateAssociatedCaseWorker.ts | 1 + ...atePetitionerInformationInteractor.test.ts | 15 ++++++++++ .../updatePetitionerInformationInteractor.ts | 22 +++++++++++++- 7 files changed, 87 insertions(+), 3 deletions(-) diff --git a/shared/src/business/utilities/generateChangeOfAddressTemplate.ts b/shared/src/business/utilities/generateChangeOfAddressTemplate.ts index 11853d7421a..c87919cbc24 100644 --- a/shared/src/business/utilities/generateChangeOfAddressTemplate.ts +++ b/shared/src/business/utilities/generateChangeOfAddressTemplate.ts @@ -34,7 +34,15 @@ export const getAddressPhoneDiff = ({ newData, oldData }) => { * @param {object} providers.oldData the old contact information * @returns {string} documentType for the address / phone change scenario */ -export const getDocumentTypeForAddressChange = ({ diff, newData, oldData }) => { +export const getDocumentTypeForAddressChange = ({ + diff, + newData, + oldData, +}: { + diff?: any; + newData: any; + oldData: any; +}) => { let documentType; const initialDiff = diff || getAddressPhoneDiff({ newData, oldData }); diff --git a/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts b/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts index 45a65b03bbe..3828e92b50d 100644 --- a/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts +++ b/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts @@ -89,6 +89,7 @@ export const generateChangeOfAddressHelper = async ({ if (!bypassDocketEntry && caseEntity.shouldGenerateNoticesForCase()) { await prepareToGenerateAndServeDocketEntry({ applicationContext, + authorizedUser, caseEntity, newData, oldData, @@ -161,11 +162,20 @@ export const generateChangeOfAddressHelper = async ({ */ const prepareToGenerateAndServeDocketEntry = async ({ applicationContext, + authorizedUser, caseEntity, newData, oldData, practitionerName, user, +}: { + applicationContext: any; + caseEntity: any; + newData: any; + oldData: any; + practitionerName: any; + user: any; + authorizedUser: AuthUser; }) => { const documentType = applicationContext .getUtilities() @@ -192,6 +202,7 @@ const prepareToGenerateAndServeDocketEntry = async ({ newData.name = practitionerName; const { changeOfAddressDocketEntry } = await generateAndServeDocketEntry({ applicationContext, + authorizedUser, barNumber: user.barNumber, caseEntity, docketMeta, diff --git a/web-api/src/business/useCaseHelper/service/createChangeItems.test.ts b/web-api/src/business/useCaseHelper/service/createChangeItems.test.ts index e80f337e5e6..f4f3638fd77 100644 --- a/web-api/src/business/useCaseHelper/service/createChangeItems.test.ts +++ b/web-api/src/business/useCaseHelper/service/createChangeItems.test.ts @@ -23,6 +23,7 @@ describe('generateAndServeDocketEntry', () => { }); testArguments = { applicationContext, + authorizedUser: mockAdmissionsClerkUser, barNumber: 'DD44444', caseEntity: testCaseEntity, contactName: 'Test Petitioner', diff --git a/web-api/src/business/useCaseHelper/service/createChangeItems.ts b/web-api/src/business/useCaseHelper/service/createChangeItems.ts index aeea3dc9f73..7bccda65c0c 100644 --- a/web-api/src/business/useCaseHelper/service/createChangeItems.ts +++ b/web-api/src/business/useCaseHelper/service/createChangeItems.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { DOCKET_SECTION, @@ -6,6 +7,7 @@ import { SERVICE_INDICATOR_TYPES, } from '../../../../../shared/src/business/entities/EntityConstants'; import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; import { addCoverToPdf } from '../../useCases/addCoverToPdf'; import { getCaseCaptionMeta } from '../../../../../shared/src/business/utilities/getCaseCaptionMeta'; @@ -24,6 +26,7 @@ import { getCaseCaptionMeta } from '../../../../../shared/src/business/utilities */ const createDocketEntryForChange = async ({ applicationContext, + authorizedUser, caseEntity, docketMeta = {}, documentType, @@ -31,6 +34,16 @@ const createDocketEntryForChange = async ({ oldData, servedParties, user, +}: { + applicationContext: any; + caseEntity: any; + docketMeta: any; + documentType: any; + newData: any; + oldData: any; + servedParties: any; + user: any; + authorizedUser: AuthUser; }) => { const caseDetail = caseEntity.validate().toRawObject(); const { caseCaptionExtension, caseTitle } = getCaseCaptionMeta(caseDetail); @@ -79,7 +92,7 @@ const createDocketEntryForChange = async ({ processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, ...docketMeta, }, - { authorizedUser: applicationContext.getCurrentUser() }, + { authorizedUser }, ); changeOfAddressDocketEntry.setFiledBy(user); @@ -160,6 +173,7 @@ const createWorkItemForChange = async ({ export const generateAndServeDocketEntry = async ({ applicationContext, + authorizedUser, barNumber, caseEntity, contactName, @@ -170,6 +184,19 @@ export const generateAndServeDocketEntry = async ({ privatePractitionersRepresentingContact, servedParties, user, +}: { + applicationContext: ServerApplicationContext; + barNumber: any; + caseEntity: any; + contactName: any; + docketMeta: any; + documentType: any; + newData: any; + oldData: any; + privatePractitionersRepresentingContact: any; + servedParties: any; + user: any; + authorizedUser: AuthUser; }) => { const partyWithPaperService = caseEntity.hasPartyWithServiceType( SERVICE_INDICATOR_TYPES.SI_PAPER, @@ -196,6 +223,7 @@ export const generateAndServeDocketEntry = async ({ let url; ({ changeOfAddressDocketEntry, url } = await createDocketEntryForChange({ applicationContext, + authorizedUser, barNumber, caseEntity, contactName, diff --git a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts index 9dea2a09809..6166da66479 100644 --- a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts +++ b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts @@ -187,6 +187,7 @@ const updateCaseEntityAndGenerateChange = async ({ .getUseCaseHelpers() .generateAndServeDocketEntry({ applicationContext, + authorizedUser, caseEntity, documentType, newData, diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts index 51cc0daf85d..532a9e52a0f 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.test.ts @@ -82,6 +82,21 @@ describe('updatePetitionerInformationInteractor', () => { .getCaseByDocketNumber.mockImplementation(() => mockCase); }); + it('should throw an error when an undefined user attempts to update petitioner information', async () => { + await expect( + updatePetitionerInformationInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + updatedPetitionerData: {}, + }, + undefined, + ), + ).rejects.toThrow( + 'User attempting to update petitioner information is not an auth user', + ); + }); + it('should throw an error when the user making the request does not have permission to edit petition details', async () => { await expect( updatePetitionerInformationInteractor( diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts index d716e2b6017..8dcd8b7b9a9 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts @@ -1,3 +1,8 @@ +import { + AuthUser, + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { CASE_STATUS_TYPES, ROLES, @@ -14,7 +19,6 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; import { defaults, pick } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -50,10 +54,18 @@ export const getIsUserAuthorized = ({ const updateCaseEntityAndGenerateChange = async ({ applicationContext, + authorizedUser, caseEntity, petitionerOnCase, user, userHasAnEmail, +}: { + applicationContext: ServerApplicationContext; + caseEntity: any; + petitionerOnCase: any; + user: any; + userHasAnEmail: any; + authorizedUser: AuthUser; }) => { const newData = { email: petitionerOnCase.newEmail, @@ -81,6 +93,7 @@ const updateCaseEntityAndGenerateChange = async ({ .getUseCaseHelpers() .generateAndServeDocketEntry({ applicationContext, + authorizedUser, caseEntity, documentType, newData, @@ -111,6 +124,12 @@ export const updatePetitionerInformation = async ( { docketNumber, updatedPetitionerData }, authorizedUser: UnknownAuthUser, ) => { + if (!isAuthUser(authorizedUser)) { + throw new Error( + 'User attempting to update petitioner information is not an auth user', + ); + } + const oldCase = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ applicationContext, docketNumber }); @@ -284,6 +303,7 @@ export const updatePetitionerInformation = async ( await updateCaseEntityAndGenerateChange({ applicationContext, + authorizedUser, caseEntity, petitionerOnCase: oldCaseContact, user: authorizedUser, From a3aeedea07de3510356eba39b00fa1238a6465fb Mon Sep 17 00:00:00 2001 From: Jim deVos Date: Tue, 23 Jul 2024 09:32:59 -0700 Subject: [PATCH 363/523] 10417: cleanup commented getCurrentUser refs --- .../caseNote/deleteUserCaseNoteInteractor.test.ts | 5 ----- .../updateOtherStatisticsInteractor.test.ts | 5 ----- ...createCsvCustomCaseReportFileInteractor.test.ts | 8 -------- .../updateDocketEntryMetaInteractor.test.ts | 5 ----- ...ocumentContentsForDocketEntryInteractor.test.ts | 14 -------------- ...ternallyFiledDocumentInteractor.locking.test.ts | 2 -- .../serveExternallyFiledDocumentInteractor.test.ts | 5 ----- ...tOfCaseDocumentsFiledByJudgesInteractor.test.ts | 4 ---- 8 files changed, 48 deletions(-) diff --git a/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.ts b/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.ts index 6f727ce2669..d47eb43b837 100644 --- a/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.ts +++ b/web-api/src/business/useCases/caseNote/deleteUserCaseNoteInteractor.test.ts @@ -9,7 +9,6 @@ import { omit } from 'lodash'; describe('deleteUserCaseNoteInteractor', () => { it('throws an error if the user is not valid or authorized', async () => { - // applicationContext.getCurrentUser.mockReturnValue({}); let user = {} as UnknownAuthUser; await expect( @@ -31,10 +30,6 @@ describe('deleteUserCaseNoteInteractor', () => { section: 'colvinChambers', userId: '6805d1ab-18d0-43ec-bafb-654e83405416', }) as UnknownAuthUser; - - // applicationContext.getCurrentUser.mockReturnValue( - // omit(mockUser, 'section'), - // ); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(mockUser); diff --git a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.ts b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.ts index c0793fec635..bac8d35e215 100644 --- a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.ts +++ b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.test.ts @@ -18,10 +18,6 @@ describe('updateOtherStatisticsInteractor', () => { beforeEach(() => { mockLock = undefined; - // applicationContext.getCurrentUser.mockReturnValue({ - // role: ROLES.docketClerk, - // userId: 'docketClerk', - // }); authorizedUser = mockDocketClerkUser; applicationContext @@ -30,7 +26,6 @@ describe('updateOtherStatisticsInteractor', () => { }); it('should throw an error if the user is unauthorized to update case statistics', async () => { - // applicationContext.getCurrentUser.mockReturnValue({}); authorizedUser = {} as UnknownAuthUser; await expect( diff --git a/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.test.ts b/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.test.ts index 0eac3179977..bbc1f8c325d 100644 --- a/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.test.ts +++ b/web-api/src/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor.test.ts @@ -21,10 +21,6 @@ describe('createCsvCustomCaseReportFileInteractor', () => { } as any; beforeEach(() => { - // applicationContext.getCurrentUser = jest - // .fn() - // .mockReturnValue(docketClerkUser); - applicationContext.getNotificationGateway().sendNotificationToUser = jest .fn() .mockReturnValue(null); @@ -106,10 +102,6 @@ describe('createCsvCustomCaseReportFileInteractor', () => { }); it('should throw an error if a user is not authorized', async () => { - // applicationContext.getCurrentUser = jest - // .fn() - // .mockReturnValue(privatePractitionerUser); - await expect( createCsvCustomCaseReportFileInteractor( applicationContext, diff --git a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.ts b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.ts index 1a734e04448..dea9d2dd9fd 100644 --- a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.test.ts @@ -121,9 +121,6 @@ describe('updateDocketEntryMetaInteractor', () => { judge: 'Buch', }, ]; - - // applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue({ @@ -198,8 +195,6 @@ describe('updateDocketEntryMetaInteractor', () => { }); it('should throw an Unauthorized error if the user is not authorized', async () => { - // applicationContext.getCurrentUser.mockReturnValue({}); - await expect( updateDocketEntryMetaInteractor( applicationContext, diff --git a/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.test.ts b/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.test.ts index 174e74d8e77..636f6e49d5e 100644 --- a/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.test.ts +++ b/web-api/src/business/useCases/document/getDocumentContentsForDocketEntryInteractor.test.ts @@ -11,11 +11,6 @@ import { describe('getDocumentContentsForDocketEntryInteractor', () => { const mockDocumentContentsId = '599dbad3-4912-4a61-9525-3da245700893'; beforeEach(() => { - // applicationContext.getCurrentUser.mockReturnValue({ - // name: 'Tasha Yar', - // role: ROLES.docketClerk, - // }); - applicationContext.getPersistenceGateway().getDocument.mockReturnValue( Buffer.from( JSON.stringify({ @@ -27,10 +22,6 @@ describe('getDocumentContentsForDocketEntryInteractor', () => { }); it('should throw an error when the logged in user does not have permission to EDIT_ORDER', async () => { - // applicationContext.getCurrentUser.mockReturnValue({ - // name: 'Tasha Yar', - // role: ROLES.inactivePractitioner, - // }); let authorizedUser = { ...mockPrivatePractitionerUser, role: ROLES.inactivePractitioner, @@ -47,11 +38,6 @@ describe('getDocumentContentsForDocketEntryInteractor', () => { }); it('should allow the logged in internal user with permissions to edit the order', async () => { - // applicationContext.getCurrentUser.mockReturnValue({ - // name: 'Test Judge', - // role: ROLES.judge, - // }); - await getDocumentContentsForDocketEntryInteractor( applicationContext, { diff --git a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.locking.test.ts b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.locking.test.ts index a1b3575c6db..8af162cb418 100644 --- a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.locking.test.ts +++ b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.locking.test.ts @@ -117,8 +117,6 @@ describe('serveExternallyFiledDocumentInteractor', () => { beforeEach(() => { mockLock = undefined; // unlocked - // applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getUseCaseHelpers() .fileAndServeDocumentOnOneCase.mockImplementation( diff --git a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.test.ts b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.test.ts index 6dd2f068a8d..1a39eab09cc 100644 --- a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.test.ts @@ -32,9 +32,6 @@ describe('serveExternallyFiledDocumentInteractor', () => { { docketEntryId: mockDocketEntryId, documentTitle: 'something cool' }, ], }; - - // applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(mockCase); @@ -57,8 +54,6 @@ describe('serveExternallyFiledDocumentInteractor', () => { }); it('should throw an error when the user is not authorized to serve externally filed documents', async () => { - // applicationContext.getCurrentUser.mockReturnValue({}); - await expect( serveExternallyFiledDocumentInteractor( applicationContext, diff --git a/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.test.ts b/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.test.ts index 94169391ed8..288c0da941d 100644 --- a/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.test.ts +++ b/web-api/src/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor.test.ts @@ -30,8 +30,6 @@ describe('getCountOfCaseDocumentsFiledByJudgesInteractor', () => { }; beforeEach(() => { - // applicationContext.getCurrentUser.mockReturnValue(judgeUser); - applicationContext .getPersistenceGateway() .fetchEventCodesCountForJudges.mockResolvedValueOnce( @@ -41,8 +39,6 @@ describe('getCountOfCaseDocumentsFiledByJudgesInteractor', () => { }); it('should return an error when the user is not authorized to generate the report', async () => { - // applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - await expect( getCountOfCaseDocumentsFiledByJudgesInteractor( applicationContext, From be984fd7ea2a741ebfef24fc39bb3d5441ab68fb Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 23 Jul 2024 09:39:04 -0700 Subject: [PATCH 364/523] 10417: remove getCurrentUser, add docs --- docs/remove-get-current-user.md | 1 + .../editPaperFilingInteractor.locking.test.ts | 45 ++++++++----- .../docketEntry/editPaperFilingInteractor.ts | 67 ++++++++++++------- 3 files changed, 72 insertions(+), 41 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index a8b79cd274a..d02308d6e0d 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -6,6 +6,7 @@ - Go back to all // TODO 10417 - Look at validateRawCollection() - Look at all references of genericHandler to make sure authorizedUser is being passed in. +- check instances of `handleLockError` (or `OnLockError`) # Web-Client Steps to transition getCurrentUser() in web-client diff --git a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.locking.test.ts b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.locking.test.ts index a72571e1ba3..8bc572d3751 100644 --- a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.locking.test.ts +++ b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.locking.test.ts @@ -7,8 +7,9 @@ import { editPaperFilingInteractor, handleLockError, } from './editPaperFilingInteractor'; -import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { docketClerkUser } from '@shared/test/mockUsers'; import { getContactPrimary } from '../../../../../shared/src/business/entities/cases/Case'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('determineEntitiesToLock', () => { let mockParams; @@ -46,21 +47,16 @@ describe('determineEntitiesToLock', () => { describe('handleLockError', () => { const mockClientConnectionId = '987654'; - beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - }); - - it('should determine who the user is based on applicationContext', async () => { - await handleLockError(applicationContext, { foo: 'bar' }); - expect(applicationContext.getCurrentUser).toHaveBeenCalled(); - }); - it('should send a notification to the user with "retry_async_request" and the originalRequest', async () => { const mockOriginalRequest = { clientConnectionId: mockClientConnectionId, foo: 'bar', }; - await handleLockError(applicationContext, mockOriginalRequest); + await handleLockError( + applicationContext, + mockOriginalRequest, + mockDocketClerkUser, + ); expect( applicationContext.getNotificationGateway().sendNotificationToUser.mock .calls[0][0].message, @@ -99,7 +95,6 @@ describe('editPaperFilingInteractor', () => { applicationContext .getPersistenceGateway() .getLock.mockImplementation(() => mockLock); - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); @@ -133,7 +128,11 @@ describe('editPaperFilingInteractor', () => { it('should throw a ServiceUnavailableError if a Case is currently locked', async () => { await expect( - editPaperFilingInteractor(applicationContext, mockRequest), + editPaperFilingInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -143,7 +142,11 @@ describe('editPaperFilingInteractor', () => { it('should return a "retry_async_request" notification with the original request', async () => { await expect( - editPaperFilingInteractor(applicationContext, mockRequest), + editPaperFilingInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -156,7 +159,7 @@ describe('editPaperFilingInteractor', () => { originalRequest: mockRequest, requestToRetry: 'edit_paper_filing', }, - userId: docketClerkUser.userId, + userId: mockDocketClerkUser.userId, }); expect( @@ -171,7 +174,11 @@ describe('editPaperFilingInteractor', () => { }); it('should acquire a lock that lasts for 15 minutes', async () => { - await editPaperFilingInteractor(applicationContext, mockRequest); + await editPaperFilingInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -190,7 +197,11 @@ describe('editPaperFilingInteractor', () => { }); it('should remove the lock', async () => { - await editPaperFilingInteractor(applicationContext, mockRequest); + await editPaperFilingInteractor( + applicationContext, + mockRequest, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().removeLock, ).toHaveBeenCalledWith({ diff --git a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts index 87f27f19acc..6ed966e454c 100644 --- a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts @@ -1,3 +1,7 @@ +import { + AuthUser, + UnknownAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { Case, isLeadCase, @@ -14,7 +18,6 @@ import { } from '../../../../../shared/src/authorization/authorizationClientService'; import { RawUser } from '@shared/business/entities/User'; import { ServerApplicationContext } from '@web-api/applicationContext'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { cloneDeep, uniq } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -46,6 +49,7 @@ export const editPaperFiling = async ( const { caseEntity, docketEntryEntity } = await getDocketEntryToEdit({ applicationContext, + authorizedUser, docketEntryId: request.docketEntryId, docketNumber: request.documentMetadata.docketNumber, }); @@ -62,6 +66,7 @@ export const editPaperFiling = async ( return editPaperFilingStrategy({ applicationContext, + authorizedUser, caseEntity, docketEntryEntity, request, @@ -92,6 +97,7 @@ const getEditPaperFilingStrategy = ({ const saveForLaterStrategy = async ({ applicationContext, + authorizedUser, caseEntity, docketEntryEntity, request, @@ -100,15 +106,15 @@ const saveForLaterStrategy = async ({ request: IEditPaperFilingRequest; caseEntity: Case; docketEntryEntity: DocketEntry; + authorizedUser: AuthUser; }) => { - const authorizedUser = applicationContext.getCurrentUser(); - const user = await applicationContext .getPersistenceGateway() .getUserById({ applicationContext, userId: authorizedUser.userId }); const updatedDocketEntryEntity = await updateDocketEntry({ applicationContext, + authorizedUser, caseEntity, docketEntry: docketEntryEntity, documentMetadata: request.documentMetadata, @@ -145,6 +151,7 @@ const saveForLaterStrategy = async ({ const multiDocketServeStrategy = async ({ applicationContext, + authorizedUser, caseEntity, docketEntryEntity, request, @@ -153,6 +160,7 @@ const multiDocketServeStrategy = async ({ caseEntity: Case; docketEntryEntity: DocketEntry; request: IEditPaperFilingRequest; + authorizedUser: AuthUser; }) => { validateDocketEntryCanBeServed({ documentMetadata: request.documentMetadata, @@ -170,7 +178,7 @@ const multiDocketServeStrategy = async ({ const consolidatedCaseEntities = consolidatedCaseRecords.map( consolidatedCase => new Case(consolidatedCase, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }), ); @@ -181,10 +189,9 @@ const multiDocketServeStrategy = async ({ const caseEntitiesToFileOn = [caseEntity, ...consolidatedCaseEntities]; - const authorizedUser = applicationContext.getCurrentUser(); - await serveDocketEntry({ applicationContext, + authorizedUser, caseEntitiesToFileOn, clientConnectionId: request.clientConnectionId, docketEntryEntity, @@ -197,6 +204,7 @@ const multiDocketServeStrategy = async ({ const singleDocketServeStrategy = async ({ applicationContext, + authorizedUser, caseEntity, docketEntryEntity, request, @@ -205,6 +213,7 @@ const singleDocketServeStrategy = async ({ caseEntity: Case; docketEntryEntity: DocketEntry; request: IEditPaperFilingRequest; + authorizedUser: AuthUser; }) => { validateDocketEntryCanBeServed({ documentMetadata: request.documentMetadata, @@ -212,10 +221,9 @@ const singleDocketServeStrategy = async ({ const caseEntitiesToFileOn = [caseEntity]; - const authorizedUser = applicationContext.getCurrentUser(); - await serveDocketEntry({ applicationContext, + authorizedUser, caseEntitiesToFileOn, clientConnectionId: request.clientConnectionId, docketEntryEntity, @@ -229,6 +237,7 @@ const singleDocketServeStrategy = async ({ // *********************************** Small Helper Functions *********************************** const serveDocketEntry = async ({ applicationContext, + authorizedUser, caseEntitiesToFileOn, clientConnectionId, docketEntryEntity, @@ -245,6 +254,7 @@ const serveDocketEntry = async ({ userId: string; subjectCaseEntity: Case; message: string; + authorizedUser: AuthUser; }) => { await applicationContext .getPersistenceGateway() @@ -262,6 +272,7 @@ const serveDocketEntry = async ({ const updatedDocketEntry = await updateDocketEntry({ applicationContext, + authorizedUser, caseEntity: subjectCaseEntity, docketEntry: docketEntryEntity, documentMetadata, @@ -274,7 +285,7 @@ const serveDocketEntry = async ({ applicationContext, caseEntity: aCase, docketEntryEntity: new DocketEntry(cloneDeep(updatedDocketEntry), { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }), subjectCaseDocketNumber: subjectCaseEntity.docketNumber, user, @@ -376,6 +387,7 @@ const validateMultiDocketPaperFilingRequest = ({ const updateDocketEntry = async ({ applicationContext, + authorizedUser, caseEntity, docketEntry, documentMetadata, @@ -386,6 +398,7 @@ const updateDocketEntry = async ({ docketEntry: DocketEntry; documentMetadata: any; userId: string; + authorizedUser: AuthUser; }): Promise => { const editableFields = { addToCoversheet: documentMetadata.addToCoversheet, @@ -425,7 +438,7 @@ const updateDocketEntry = async ({ userId, }, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, petitioners: caseEntity.petitioners, }, ); @@ -474,12 +487,14 @@ const updateAndSaveWorkItem = async ({ const getDocketEntryToEdit = async ({ applicationContext, + authorizedUser, docketEntryId, docketNumber, }: { applicationContext: ServerApplicationContext; docketNumber: string; docketEntryId: string; + authorizedUser: AuthUser; }): Promise<{ caseEntity: Case; docketEntryEntity: DocketEntry; @@ -492,7 +507,7 @@ const getDocketEntryToEdit = async ({ }); const caseEntity = new Case(caseToUpdate, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }); const docketEntryEntity = caseEntity.getDocketEntryById({ @@ -521,19 +536,23 @@ export const determineEntitiesToLock = ( ttl: 900, }); -export const handleLockError = async (applicationContext, originalRequest) => { - const user = applicationContext.getCurrentUser(); - - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - clientConnectionId: originalRequest.clientConnectionId, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'edit_paper_filing', - }, - userId: user.userId, - }); +export const handleLockError = async ( + applicationContext, + originalRequest, + authorizedUser: UnknownAuthUser, +) => { + if (authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + clientConnectionId: originalRequest.clientConnectionId, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'edit_paper_filing', + }, + userId: authorizedUser.userId, + }); + } }; export const editPaperFilingInteractor = withLocking( From 3d796b22bad68f6535335642e734ebfd18e077e3 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 23 Jul 2024 10:18:13 -0700 Subject: [PATCH 365/523] 10417: add authorizedUser to updateCaseAndAssociations low hanging fruit --- docs/remove-get-current-user.md | 1 + .../useCases/prioritizeCaseInteractor.ts | 1 + .../useCases/removeCasePendingItemInteractor.ts | 4 +++- .../removePdfFromDocketEntryInteractor.ts | 4 +++- ...emovePetitionerAndUpdateCaptionInteractor.ts | 1 + ...emoveSignatureFromDocumentInteractor.test.ts | 15 +++++++++++++++ .../removeSignatureFromDocumentInteractor.ts | 11 ++++++++++- .../saveCaseDetailInternalEditInteractor.ts | 1 + .../saveSignedDocumentInteractor.test.ts | 17 +++++++++++++++++ .../useCases/saveSignedDocumentInteractor.ts | 14 ++++++++++++-- .../sealCaseContactAddressInteractor.ts | 1 + .../src/business/useCases/sealCaseInteractor.ts | 1 + .../useCases/unblockCaseFromTrialInteractor.ts | 1 + .../useCases/unprioritizeCaseInteractor.ts | 1 + .../business/useCases/unsealCaseInteractor.ts | 1 + .../useCases/updateCaseContextInteractor.ts | 1 + .../useCases/updateCaseDetailsInteractor.ts | 1 + .../useCases/updateContactInteractor.ts | 1 + .../updateQcCompleteForTrialInteractor.ts | 1 + .../associateIrsPractitionerToCase.ts | 1 + .../associatePrivatePractitionerToCase.ts | 1 + .../updateCaseAndAssociations.ts | 9 ++------- .../generateChangeOfAddressHelper.ts | 1 + .../addDraftStampOrderDocketEntryInteractor.ts | 4 +++- .../useCases/addPetitionerToCaseInteractor.ts | 1 + .../useCases/archiveDraftDocumentInteractor.ts | 1 + .../useCases/blockCaseFromTrialInteractor.ts | 1 + .../deleteCounselFromCaseInteractor.ts | 1 + .../updateCounselOnCaseInteractor.ts | 1 + .../addConsolidatedCaseInteractor.ts | 1 + .../removeConsolidatedCasesInteractor.ts | 3 +++ .../createCaseDeadlineInteractor.ts | 1 + .../deleteCaseDeadlineInteractor.ts | 1 + .../useCases/caseNote/saveCaseNoteInteractor.ts | 1 + .../addDeficiencyStatisticInteractor.ts | 1 + .../updateOtherStatisticsInteractor.ts | 1 + .../archiveCorrespondenceDocumentInteractor.ts | 1 + .../fileCourtIssuedOrderInteractor.ts | 1 + .../updateCourtIssuedOrderInteractor.ts | 3 ++- .../docketEntry/addPaperFilingInteractor.ts | 1 + .../completeDocketEntryQCInteractor.ts | 1 + .../docketEntry/editPaperFilingInteractor.ts | 1 + .../fileCourtIssuedDocketEntryInteractor.ts | 1 + .../updateCourtIssuedDocketEntryInteractor.ts | 1 + .../updateDocketEntryMetaInteractor.ts | 1 + .../fileExternalDocumentInteractor.ts | 1 + .../serveCaseToIrs/serveCaseToIrsInteractor.ts | 1 + .../addCaseToTrialSessionInteractor.ts | 1 + .../deleteTrialSessionInteractor.ts | 1 + .../removeCaseFromTrialInteractor.ts | 1 + .../serveThirtyDayNoticeInteractor.ts | 1 + .../setTrialSessionCalendarInteractor.ts | 3 +++ .../updateTrialSessionInteractor.ts | 1 + .../useCases/user/updateAssociatedCaseWorker.ts | 2 ++ .../updatePetitionerInformationInteractor.ts | 1 + .../workItems/completeWorkItemInteractor.ts | 1 + 56 files changed, 119 insertions(+), 14 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index d02308d6e0d..dbd5a03a259 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -7,6 +7,7 @@ - Look at validateRawCollection() - Look at all references of genericHandler to make sure authorizedUser is being passed in. - check instances of `handleLockError` (or `OnLockError`) +- Look at all new Case and new DocketEntry # Web-Client Steps to transition getCurrentUser() in web-client diff --git a/shared/src/business/useCases/prioritizeCaseInteractor.ts b/shared/src/business/useCases/prioritizeCaseInteractor.ts index 2756ea0fa2e..4c960a25e5a 100644 --- a/shared/src/business/useCases/prioritizeCaseInteractor.ts +++ b/shared/src/business/useCases/prioritizeCaseInteractor.ts @@ -57,6 +57,7 @@ export const prioritizeCase = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/shared/src/business/useCases/removeCasePendingItemInteractor.ts b/shared/src/business/useCases/removeCasePendingItemInteractor.ts index 85005d1dc27..cf7d700416e 100644 --- a/shared/src/business/useCases/removeCasePendingItemInteractor.ts +++ b/shared/src/business/useCases/removeCasePendingItemInteractor.ts @@ -3,6 +3,7 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -16,7 +17,7 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the updated case data */ export const removeCasePendingItem = async ( - applicationContext, + applicationContext: ServerApplicationContext, { docketEntryId, docketNumber }, authorizedUser: UnknownAuthUser, ) => { @@ -47,6 +48,7 @@ export const removeCasePendingItem = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: updatedCaseEntity, }); diff --git a/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts b/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts index e8347574e42..93b6c0b2005 100644 --- a/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts +++ b/shared/src/business/useCases/removePdfFromDocketEntryInteractor.ts @@ -3,6 +3,7 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; @@ -16,7 +17,7 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @returns {object} the updated case data */ export const removePdfFromDocketEntry = async ( - applicationContext, + applicationContext: ServerApplicationContext, { docketEntryId, docketNumber }, authorizedUser: UnknownAuthUser, ) => { @@ -50,6 +51,7 @@ export const removePdfFromDocketEntry = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts b/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts index e4bf148565a..3de8032c5e3 100644 --- a/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts +++ b/shared/src/business/useCases/removePetitionerAndUpdateCaptionInteractor.ts @@ -76,6 +76,7 @@ export const removePetitionerAndUpdateCaption = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.test.ts b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.test.ts index 8578f445b65..6613063f340 100644 --- a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.test.ts +++ b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.test.ts @@ -36,6 +36,21 @@ describe('removeSignatureFromDocumentInteractor', () => { .getCaseByDocketNumber.mockReturnValue(mockCase); }); + it('should throw an error when user is undefined', async () => { + await expect( + removeSignatureFromDocumentInteractor( + applicationContext, + { + docketEntryId: mockDocketEntryId, + docketNumber: mockCase.docketNumber, + }, + undefined, + ), + ).rejects.toThrow( + 'User attempting to remove signature from document is not an auth user', + ); + }); + it('should retrieve the original, unsigned document from S3', async () => { await removeSignatureFromDocumentInteractor( applicationContext, diff --git a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts index 704544cd897..b714c8d9f3c 100644 --- a/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts +++ b/shared/src/business/useCases/removeSignatureFromDocumentInteractor.ts @@ -1,6 +1,9 @@ import { Case } from '../entities/cases/Case'; import { ServerApplicationContext } from '@web-api/applicationContext'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; /** * Removes a signature from a document @@ -16,6 +19,11 @@ export const removeSignatureFromDocumentInteractor = async ( { docketEntryId, docketNumber }, authorizedUser: UnknownAuthUser, ) => { + if (!isAuthUser(authorizedUser)) { + throw new Error( + 'User attempting to remove signature from document is not an auth user', + ); + } const caseRecord = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ @@ -47,6 +55,7 @@ export const removeSignatureFromDocumentInteractor = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts index 087b3ce8a21..880ee55df1e 100644 --- a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts +++ b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts @@ -164,6 +164,7 @@ export const saveCaseDetailInternalEdit = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts b/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts index b00828dbaaf..398800368f7 100644 --- a/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts +++ b/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts @@ -55,6 +55,23 @@ describe('saveSignedDocumentInteractor', () => { ]); }); + it('should throw an error when an unknown user attempts to save a signed document', async () => { + await expect( + saveSignedDocumentInteractor( + applicationContext, + { + docketNumber: mockCase.docketNumber, + nameForSigning: mockSigningName, + originalDocketEntryId: mockOriginalDocketEntryId, + signedDocketEntryId: mockSignedDocketEntryId, + } as any, + undefined, + ), + ).rejects.toThrow( + 'User attempting to save signed document is not an auth user', + ); + }); + it('should save the original, unsigned document to S3 with a new id', async () => { await saveSignedDocumentInteractor( applicationContext, diff --git a/shared/src/business/useCases/saveSignedDocumentInteractor.ts b/shared/src/business/useCases/saveSignedDocumentInteractor.ts index 4b4cc7c2b41..16605772220 100644 --- a/shared/src/business/useCases/saveSignedDocumentInteractor.ts +++ b/shared/src/business/useCases/saveSignedDocumentInteractor.ts @@ -5,7 +5,11 @@ import { } from '../entities/EntityConstants'; import { DocketEntry } from '../entities/DocketEntry'; import { Message } from '../entities/Message'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { ServerApplicationContext } from '@web-api/applicationContext'; +import { + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; import { orderBy } from 'lodash'; const saveOriginalDocumentWithNewId = async ({ @@ -63,7 +67,7 @@ const replaceOriginalWithSignedDocument = async ({ * @returns {object} an object containing the updated caseEntity and the signed document ID */ export const saveSignedDocumentInteractor = async ( - applicationContext, + applicationContext: ServerApplicationContext, { docketNumber, nameForSigning, @@ -73,6 +77,11 @@ export const saveSignedDocumentInteractor = async ( }, authorizedUser: UnknownAuthUser, ) => { + if (!isAuthUser(authorizedUser)) { + throw new Error( + 'User attempting to save signed document is not an auth user', + ); + } const caseRecord = await applicationContext .getPersistenceGateway() .getCaseByDocketNumber({ @@ -168,6 +177,7 @@ export const saveSignedDocumentInteractor = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/shared/src/business/useCases/sealCaseContactAddressInteractor.ts b/shared/src/business/useCases/sealCaseContactAddressInteractor.ts index aaab5548f2e..4e65c13a64c 100644 --- a/shared/src/business/useCases/sealCaseContactAddressInteractor.ts +++ b/shared/src/business/useCases/sealCaseContactAddressInteractor.ts @@ -54,6 +54,7 @@ export const sealCaseContactAddress = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/shared/src/business/useCases/sealCaseInteractor.ts b/shared/src/business/useCases/sealCaseInteractor.ts index 28cb1a0529c..350c2ea3154 100644 --- a/shared/src/business/useCases/sealCaseInteractor.ts +++ b/shared/src/business/useCases/sealCaseInteractor.ts @@ -36,6 +36,7 @@ export const sealCase = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: newCase, }); diff --git a/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts b/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts index 41269bb20b8..6a0a088f0af 100644 --- a/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts +++ b/shared/src/business/useCases/unblockCaseFromTrialInteractor.ts @@ -49,6 +49,7 @@ export const unblockCaseFromTrial = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/shared/src/business/useCases/unprioritizeCaseInteractor.ts b/shared/src/business/useCases/unprioritizeCaseInteractor.ts index 2d419311b61..302cba9bd43 100644 --- a/shared/src/business/useCases/unprioritizeCaseInteractor.ts +++ b/shared/src/business/useCases/unprioritizeCaseInteractor.ts @@ -60,6 +60,7 @@ export const unprioritizeCase = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/shared/src/business/useCases/unsealCaseInteractor.ts b/shared/src/business/useCases/unsealCaseInteractor.ts index 79da9d6319f..12b0878765f 100644 --- a/shared/src/business/useCases/unsealCaseInteractor.ts +++ b/shared/src/business/useCases/unsealCaseInteractor.ts @@ -36,6 +36,7 @@ export const unsealCase = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: newCase, }); diff --git a/shared/src/business/useCases/updateCaseContextInteractor.ts b/shared/src/business/useCases/updateCaseContextInteractor.ts index b9d6c4ab940..774adf4ee2b 100644 --- a/shared/src/business/useCases/updateCaseContextInteractor.ts +++ b/shared/src/business/useCases/updateCaseContextInteractor.ts @@ -114,6 +114,7 @@ export const updateCaseContext = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: newCase, }); diff --git a/shared/src/business/useCases/updateCaseDetailsInteractor.ts b/shared/src/business/useCases/updateCaseDetailsInteractor.ts index 73b1d9dde79..e2652d190b1 100644 --- a/shared/src/business/useCases/updateCaseDetailsInteractor.ts +++ b/shared/src/business/useCases/updateCaseDetailsInteractor.ts @@ -133,6 +133,7 @@ export const updateCaseDetails = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: newCaseEntity, }); diff --git a/shared/src/business/useCases/updateContactInteractor.ts b/shared/src/business/useCases/updateContactInteractor.ts index 07b9ee87d6b..5d11ba72779 100644 --- a/shared/src/business/useCases/updateContactInteractor.ts +++ b/shared/src/business/useCases/updateContactInteractor.ts @@ -240,6 +240,7 @@ export const updateContact = async ( if (shouldUpdateCase) { await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); } diff --git a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts index ced92da22e8..4d2cf2f9160 100644 --- a/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts +++ b/shared/src/business/useCases/updateQcCompleteForTrialInteractor.ts @@ -50,6 +50,7 @@ export const updateQcCompleteForTrial = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: newCase, }); diff --git a/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts b/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts index 747dc9a324f..c3c81d2deea 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/associateIrsPractitionerToCase.ts @@ -53,6 +53,7 @@ export const associateIrsPractitionerToCase = async ({ await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); } diff --git a/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts b/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts index cc0cbb0b1e9..9bc71cdb93e 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/associatePrivatePractitionerToCase.ts @@ -82,6 +82,7 @@ export const associatePrivatePractitionerToCase = async ({ await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts index 4830cab1322..cf638bc8e99 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts @@ -447,14 +447,9 @@ export const updateCaseAndAssociations = async ({ caseToUpdate, }: { applicationContext: ServerApplicationContext; - // TODO 10417: making authorizedUser an optional property for now. Make required when when updateCaseAndAssociations references are refactored. - authorizedUser?: AuthUser; + authorizedUser: AuthUser; caseToUpdate: any; }): Promise => { - // TODO 10417: remove this if-block when updateCaseAndAssociations references are refactored - if (!authorizedUser) { - authorizedUser = applicationContext.getCurrentUser(); - } const caseEntity: Case = caseToUpdate.validate ? caseToUpdate : new Case(caseToUpdate, { @@ -471,7 +466,7 @@ export const updateCaseAndAssociations = async ({ const validRawCaseEntity = caseEntity.validate().toRawObject(); const validRawOldCaseEntity = new Case(oldCaseEntity, { - authorizedUser: applicationContext.getCurrentUser(), + authorizedUser, }) .validate() .toRawObject(); diff --git a/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts b/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts index 3828e92b50d..2b40dfd0a37 100644 --- a/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts +++ b/web-api/src/business/useCaseHelper/generateChangeOfAddressHelper.ts @@ -100,6 +100,7 @@ export const generateChangeOfAddressHelper = async ({ await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); } catch (error) { diff --git a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts index 197af68002b..bc15d8911ac 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.ts @@ -9,6 +9,7 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { Stamp } from '../../../../../shared/src/business/entities/Stamp'; import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; @@ -27,7 +28,7 @@ import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; * @param {string} providers.stampData the stampData from the form */ export const addDraftStampOrderDocketEntry = async ( - applicationContext, + applicationContext: ServerApplicationContext, { docketNumber, formattedDraftDocumentTitle, @@ -131,6 +132,7 @@ export const addDraftStampOrderDocketEntry = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); }; diff --git a/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts b/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts index 7f8ad2d28e9..8a0c0e495b7 100644 --- a/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts +++ b/web-api/src/business/useCases/addPetitionerToCaseInteractor.ts @@ -48,6 +48,7 @@ export const addPetitionerToCase = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts b/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts index e41fb8405fc..84ec8a788c4 100644 --- a/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts +++ b/web-api/src/business/useCases/archiveDraftDocumentInteractor.ts @@ -48,6 +48,7 @@ export const archiveDraftDocument = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/blockCaseFromTrialInteractor.ts b/web-api/src/business/useCases/blockCaseFromTrialInteractor.ts index 28a20e54493..1fe3133cfd8 100644 --- a/web-api/src/business/useCases/blockCaseFromTrialInteractor.ts +++ b/web-api/src/business/useCases/blockCaseFromTrialInteractor.ts @@ -47,6 +47,7 @@ export const blockCaseFromTrial = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts index 43fc3737a90..ce4c7c43579 100644 --- a/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts +++ b/web-api/src/business/useCases/caseAssociation/deleteCounselFromCaseInteractor.ts @@ -57,6 +57,7 @@ export const deleteCounselFromCase = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity.validate().toRawObject(), }); }; diff --git a/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts b/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts index d50abee29fb..953f385c377 100644 --- a/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts +++ b/web-api/src/business/useCases/caseAssociation/updateCounselOnCaseInteractor.ts @@ -89,6 +89,7 @@ const updateCounselOnCase = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts b/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts index 6eb2b01d4b3..1e8935e68ee 100644 --- a/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts +++ b/web-api/src/business/useCases/caseConsolidation/addConsolidatedCaseInteractor.ts @@ -94,6 +94,7 @@ export const addConsolidatedCase = async ( updateCasePromises.push( applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }), ); diff --git a/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts b/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts index 7560be91030..cf5e2314419 100644 --- a/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts +++ b/web-api/src/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor.ts @@ -68,6 +68,7 @@ export const removeConsolidatedCases = async ( updateCasePromises.push( applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }), ); @@ -82,6 +83,7 @@ export const removeConsolidatedCases = async ( updateCasePromises.push( applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }), ); @@ -107,6 +109,7 @@ export const removeConsolidatedCases = async ( updateCasePromises.push( applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }), ); diff --git a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts index 3eca2953451..9e040f51c51 100644 --- a/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts +++ b/web-api/src/business/useCases/caseDeadline/createCaseDeadlineInteractor.ts @@ -51,6 +51,7 @@ export const createCaseDeadline = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts b/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts index bd48f8b3f52..e950c02150a 100644 --- a/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts +++ b/web-api/src/business/useCases/caseDeadline/deleteCaseDeadlineInteractor.ts @@ -43,6 +43,7 @@ export const deleteCaseDeadline = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: updatedCase, }); return new Case(result, { authorizedUser }).validate().toRawObject(); diff --git a/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts b/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts index de06ff22b06..cd716d0ab0d 100644 --- a/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts +++ b/web-api/src/business/useCases/caseNote/saveCaseNoteInteractor.ts @@ -46,6 +46,7 @@ export const saveCaseNote = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate, }); diff --git a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts index 510b5c956e7..ef95c8361f1 100644 --- a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.ts @@ -80,6 +80,7 @@ export const addDeficiencyStatistic = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: newCase, }); diff --git a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts index 327105621db..526c22494b4 100644 --- a/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts +++ b/web-api/src/business/useCases/caseStatistics/updateOtherStatisticsInteractor.ts @@ -44,6 +44,7 @@ export const updateOtherStatistics = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: newCase, }); diff --git a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts index 08355fe9c56..758b9d52246 100644 --- a/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts +++ b/web-api/src/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor.ts @@ -44,6 +44,7 @@ export const archiveCorrespondenceDocument = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); }; diff --git a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts index a025ce4b40b..d05aac72ea7 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/fileCourtIssuedOrderInteractor.ts @@ -97,6 +97,7 @@ export const fileCourtIssuedOrder = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts index 61aea2a9b7c..e43f1042615 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor.ts @@ -15,7 +15,7 @@ import { get } from 'lodash'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; export const updateCourtIssuedOrder = async ( - applicationContext, + applicationContext: ServerApplicationContext, { docketEntryIdToEdit, documentMetadata }, authorizedUser: UnknownAuthUser, ) => { @@ -124,6 +124,7 @@ export const updateCourtIssuedOrder = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts index 0e985991409..26a39cde7bc 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts @@ -176,6 +176,7 @@ export const addPaperFiling = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity.validate().toRawObject(), }); } diff --git a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts index 54062ba920c..610c88fc1c2 100644 --- a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts @@ -337,6 +337,7 @@ const completeDocketEntryQC = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts index 6ed966e454c..86e1003bd8a 100644 --- a/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/editPaperFilingInteractor.ts @@ -129,6 +129,7 @@ const saveForLaterStrategy = async ({ await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts index 2db1f35ed91..91059ffe4f7 100644 --- a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts @@ -166,6 +166,7 @@ export const fileCourtIssuedDocketEntry = async ( const saveItems = [ applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }), ]; diff --git a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts index 42ff20b3446..e4596606c72 100644 --- a/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor.ts @@ -95,6 +95,7 @@ export const updateCourtIssuedDocketEntry = async ( }), applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }), ]; diff --git a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts index 7d1b8dba4d6..453a5ea9e67 100644 --- a/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/updateDocketEntryMetaInteractor.ts @@ -185,6 +185,7 @@ export const updateDocketEntryMeta = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts index ac5f7a174e3..65b1138d811 100644 --- a/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts +++ b/web-api/src/business/useCases/externalDocument/fileExternalDocumentInteractor.ts @@ -213,6 +213,7 @@ export const fileExternalDocument = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts index bf3cd2374d5..5862ae35f66 100644 --- a/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts +++ b/web-api/src/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor.ts @@ -654,6 +654,7 @@ export const serveCaseToIrs = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts index 1a726b3744d..fc8d136fa9c 100644 --- a/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/addCaseToTrialSessionInteractor.ts @@ -94,6 +94,7 @@ export const addCaseToTrialSession = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts index e40c8dfb972..500b17a7412 100644 --- a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.ts @@ -84,6 +84,7 @@ export const deleteTrialSessionInteractor = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); } diff --git a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts index 29eb9e594d8..d73832eea21 100644 --- a/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/removeCaseFromTrialInteractor.ts @@ -101,6 +101,7 @@ export const removeCaseFromTrial = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts index 864a1cac188..0fab5738c16 100644 --- a/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/serveThirtyDayNoticeInteractor.ts @@ -204,6 +204,7 @@ export const serveThirtyDayNoticeInteractor = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts index 9c1e8a0aff8..e2338d0a7d2 100644 --- a/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setTrialSessionCalendarInteractor.ts @@ -214,6 +214,7 @@ const removeManuallyAddedCaseFromTrialSession = ( return applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); }; @@ -243,6 +244,7 @@ const setManuallyAddedCaseAsCalendared = async ( }), applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }), ]); @@ -274,6 +276,7 @@ const setTrialSessionCalendarForEligibleCase = async ( }), applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }), applicationContext diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index 47346c12697..51e5c10cbf1 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -297,6 +297,7 @@ const updateCasesAndSetNoticeOfChange = async ({ await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); } diff --git a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts index 6166da66479..461b0ea7941 100644 --- a/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts +++ b/web-api/src/business/useCases/user/updateAssociatedCaseWorker.ts @@ -78,6 +78,7 @@ export const updatePetitionerCase = async ({ await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate, }); }; @@ -126,6 +127,7 @@ export const updatePractitionerCase = async ({ await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: validatedCaseToUpdate, }); }; diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts index 8dcd8b7b9a9..0c9ef452e44 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts @@ -316,6 +316,7 @@ export const updatePetitionerInformation = async ( .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts index e90446ab4de..6d69f5d2fdd 100644 --- a/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts +++ b/web-api/src/business/useCases/workItems/completeWorkItemInteractor.ts @@ -83,6 +83,7 @@ export const completeWorkItem = async ( await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser, caseToUpdate, }); From 0397c750a6084c53545c0c9ca535d8bf03f71d79 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 23 Jul 2024 11:11:35 -0700 Subject: [PATCH 366/523] 10417 rm getCurrentUser and fix tests --- .../updateCaseAndAssociations.test.ts | 32 +++++++++++++++++ .../updateCaseAndAssociations.ts | 4 +-- .../fileAndServeDocumentOnOneCase.ts | 8 +++++ ...eckForReadyForTrialCasesInteractor.test.ts | 36 ++++--------------- .../checkForReadyForTrialCasesInteractor.ts | 6 ++-- ...esForCaseTrialSessionCalendarInteractor.ts | 1 + 6 files changed, 53 insertions(+), 34 deletions(-) diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts index fa3155f4a69..82ac728f0ad 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts @@ -79,6 +79,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: undefined, caseToUpdate, }); @@ -97,6 +98,7 @@ describe('updateCaseAndAssociations', () => { it('always sends valid entities to the updateCase persistence method', async () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: validMockCase, }); expect( @@ -118,6 +120,7 @@ describe('updateCaseAndAssociations', () => { await expect( updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...validMockCase, associatedJudge: 'Judge Arnold', @@ -216,6 +219,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate, }); @@ -253,6 +257,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate, }); @@ -289,6 +294,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate, }); @@ -328,6 +334,7 @@ describe('updateCaseAndAssociations', () => { updatedCase.mailingDate = '2025-01-05T05:22:16.001Z'; await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: updatedCase, }); expect( @@ -340,6 +347,7 @@ describe('updateCaseAndAssociations', () => { updatedCase.associatedJudgeId = '2f46a889-901c-4e8b-b2bb-c3994e2c75c1'; await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: updatedCase, }); const { workItem } = @@ -356,6 +364,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: updatedCase, }); @@ -371,6 +380,7 @@ describe('updateCaseAndAssociations', () => { updatedCase.caseCaption = 'Some caption changed'; await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: updatedCase, }); @@ -384,6 +394,7 @@ describe('updateCaseAndAssociations', () => { updatedCase.status = CASE_STATUS_TYPES.generalDocket; await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: updatedCase, }); @@ -399,6 +410,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: updatedCase, }); @@ -421,6 +433,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...validMockCase, trialDate: undefined, @@ -436,6 +449,7 @@ describe('updateCaseAndAssociations', () => { it('the trial location has been updated', async () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...validMockCase, trialDate: '2021-01-02T05:22:16.001Z', @@ -464,6 +478,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...validMockCase, trialLocation: undefined, @@ -493,6 +508,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...validMockCase, leadDocketNumber: undefined, @@ -517,6 +533,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...validMockCase, leadDocketNumber: '202-20', @@ -537,6 +554,7 @@ describe('updateCaseAndAssociations', () => { .getCaseByDocketNumber.mockReturnValue(validMockCase); await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: validMockCase, }); expect( @@ -573,6 +591,7 @@ describe('updateCaseAndAssociations', () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate, }); @@ -608,6 +627,7 @@ describe('updateCaseAndAssociations', () => { it('does not call updateIrsPractitionerOnCase or removeIrsPractitionerOnCase if all IRS practitioners are unchanged', async () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: mockCaseWithIrsPractitioners, }); expect( @@ -627,6 +647,7 @@ describe('updateCaseAndAssociations', () => { }; await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...mockCaseWithIrsPractitioners, irsPractitioners: [updatedPractitioner], @@ -652,6 +673,7 @@ describe('updateCaseAndAssociations', () => { it('removes an irsPractitioner from a case with existing irsPractitioners', async () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...mockCaseWithIrsPractitioners, irsPractitioners: [], @@ -676,6 +698,7 @@ describe('updateCaseAndAssociations', () => { it('calls updateIrsPractitionerOnCase to update gsi1pk for unchanged irsPractitioners when the case is part of a consolidated group', async () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...mockCaseWithIrsPractitioners, leadDocketNumber: '101-23', @@ -728,6 +751,7 @@ describe('updateCaseAndAssociations', () => { it('does not call updatePrivatePractitionerOnCase or removePrivatePractitionerOnCase if all private practitioners are unchanged', async () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: mockCaseWithIrsAndPrivatePractitioners, }); expect( @@ -749,6 +773,7 @@ describe('updateCaseAndAssociations', () => { }; await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...mockCaseWithIrsAndPrivatePractitioners, privatePractitioners: [updatedPractitioner], @@ -776,6 +801,7 @@ describe('updateCaseAndAssociations', () => { it('calls updatePrivatePractitionerOnCase to update gsi1pk for unchanged privatePractitioners when the case is part of a consolidated group', async () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...mockCaseWithIrsAndPrivatePractitioners, leadDocketNumber: '101-23', @@ -804,6 +830,7 @@ describe('updateCaseAndAssociations', () => { it('removes an privatePractitioner from a case with existing privatePractitioners', async () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...mockCaseWithIrsAndPrivatePractitioners, privatePractitioners: [], @@ -841,6 +868,7 @@ describe('updateCaseAndAssociations', () => { it('completes without altering message records if no message updates are necessary', async () => { await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: validMockCase, }); expect( @@ -861,6 +889,7 @@ describe('updateCaseAndAssociations', () => { await expect( updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...validMockCase, caseCaption: 'Some other caption', @@ -881,6 +910,7 @@ describe('updateCaseAndAssociations', () => { await expect( updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: { ...validMockCase, caseCaption: 'Some other caption', @@ -922,6 +952,7 @@ describe('updateCaseAndAssociations', () => { }; await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: updatedCase, }); expect( @@ -941,6 +972,7 @@ describe('updateCaseAndAssociations', () => { }; await updateCaseAndAssociations({ applicationContext, + authorizedUser: mockDocketClerkUser, caseToUpdate: updatedCase, }); expect( diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts index cf638bc8e99..f298179b26e 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts @@ -1,4 +1,3 @@ -import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { CaseDeadline } from '../../../../../shared/src/business/entities/CaseDeadline'; import { Correspondence } from '../../../../../shared/src/business/entities/Correspondence'; @@ -7,6 +6,7 @@ import { IrsPractitioner } from '../../../../../shared/src/business/entities/Irs import { Message } from '../../../../../shared/src/business/entities/Message'; import { PrivatePractitioner } from '../../../../../shared/src/business/entities/PrivatePractitioner'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; import diff from 'diff-arrays-of-objects'; @@ -447,7 +447,7 @@ export const updateCaseAndAssociations = async ({ caseToUpdate, }: { applicationContext: ServerApplicationContext; - authorizedUser: AuthUser; + authorizedUser: UnknownAuthUser; caseToUpdate: any; }): Promise => { const caseEntity: Case = caseToUpdate.validate diff --git a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts index 7b47ed61a18..b6b63bf22f5 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts @@ -1,6 +1,7 @@ import { Case } from '../../../../../shared/src/business/entities/cases/Case'; import { DOCKET_SECTION } from '../../../../../shared/src/business/entities/EntityConstants'; import { ENTERED_AND_SERVED_EVENT_CODES } from '../../../../../shared/src/business/entities/courtIssuedDocument/CourtIssuedDocumentConstants'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { WorkItem } from '../../../../../shared/src/business/entities/WorkItem'; import { aggregatePartiesForService } from '../../../../../shared/src/business/utilities/aggregatePartiesForService'; @@ -10,6 +11,12 @@ export const fileAndServeDocumentOnOneCase = async ({ docketEntryEntity, subjectCaseDocketNumber, user, +}: { + applicationContext: ServerApplicationContext; + caseEntity: any; + docketEntryEntity: any; + subjectCaseDocketNumber: any; + user: any; }) => { const servedParties = aggregatePartiesForService(caseEntity); @@ -87,6 +94,7 @@ export const fileAndServeDocumentOnOneCase = async ({ .getUseCaseHelpers() .updateCaseAndAssociations({ applicationContext, + authorizedUser: user, caseToUpdate: caseEntity, }); diff --git a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.test.ts b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.test.ts index 7782a9b3479..e6515b8384a 100644 --- a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.test.ts +++ b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.test.ts @@ -3,7 +3,6 @@ import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../shared/src/test/mockLock'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { checkForReadyForTrialCasesInteractor } from './checkForReadyForTrialCasesInteractor'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('checkForReadyForTrialCasesInteractor', () => { let mockCasesReadyForTrial; @@ -29,10 +28,7 @@ describe('checkForReadyForTrialCasesInteractor', () => { .getCaseByDocketNumber.mockReturnValue(MOCK_CASE); await expect( - checkForReadyForTrialCasesInteractor( - applicationContext, - mockDocketClerkUser, - ), + checkForReadyForTrialCasesInteractor(applicationContext), ).resolves.not.toThrow(); expect( @@ -50,10 +46,7 @@ describe('checkForReadyForTrialCasesInteractor', () => { mockCasesReadyForTrial = [{ docketNumber: '101-20' }]; await expect( - checkForReadyForTrialCasesInteractor( - applicationContext, - mockDocketClerkUser, - ), + checkForReadyForTrialCasesInteractor(applicationContext), ).resolves.not.toThrow(); expect( @@ -71,10 +64,7 @@ describe('checkForReadyForTrialCasesInteractor', () => { mockCasesReadyForTrial = [{ docketNumber: '101-20' }]; await expect( - checkForReadyForTrialCasesInteractor( - applicationContext, - mockDocketClerkUser, - ), + checkForReadyForTrialCasesInteractor(applicationContext), ).resolves.not.toThrow(); expect( @@ -104,10 +94,7 @@ describe('checkForReadyForTrialCasesInteractor', () => { mockCasesReadyForTrial = [{ docketNumber: '101-20' }]; await expect( - checkForReadyForTrialCasesInteractor( - applicationContext, - mockDocketClerkUser, - ), + checkForReadyForTrialCasesInteractor(applicationContext), ).resolves.not.toThrow(); expect( @@ -145,10 +132,7 @@ describe('checkForReadyForTrialCasesInteractor', () => { ]); await expect( - checkForReadyForTrialCasesInteractor( - applicationContext, - mockDocketClerkUser, - ), + checkForReadyForTrialCasesInteractor(applicationContext), ).resolves.not.toThrow(); expect( @@ -172,10 +156,7 @@ describe('checkForReadyForTrialCasesInteractor', () => { .getPersistenceGateway() .getReadyForTrialCases.mockReturnValue([{ docketNumber: '101-20' }]); - await checkForReadyForTrialCasesInteractor( - applicationContext, - mockDocketClerkUser, - ); + await checkForReadyForTrialCasesInteractor(applicationContext); expect( applicationContext.getPersistenceGateway() @@ -208,10 +189,7 @@ describe('checkForReadyForTrialCasesInteractor', () => { ]); await expect( - checkForReadyForTrialCasesInteractor( - applicationContext, - mockDocketClerkUser, - ), + checkForReadyForTrialCasesInteractor(applicationContext), ).resolves.not.toThrow(); expect(applicationContext.getUtilities().sleep).toHaveBeenCalledTimes(1); expect( diff --git a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts index 10988875966..c1913452ef3 100644 --- a/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts +++ b/web-api/src/business/useCases/checkForReadyForTrialCasesInteractor.ts @@ -2,7 +2,6 @@ import { CASE_STATUS_TYPES } from '../../../../shared/src/business/entities/Enti import { Case } from '../../../../shared/src/business/entities/cases/Case'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { acquireLock } from '@web-api/business/useCaseHelper/acquireLock'; import { createISODateString } from '../../../../shared/src/business/utilities/DateHandler'; import { uniqBy } from 'lodash'; @@ -12,7 +11,6 @@ import { uniqBy } from 'lodash'; */ export const checkForReadyForTrialCasesInteractor = async ( applicationContext: ServerApplicationContext, - authorizedUser: UnknownAuthUser, ) => { applicationContext.logger.debug('Time', createISODateString()); @@ -27,6 +25,7 @@ export const checkForReadyForTrialCasesInteractor = async ( const caseEntity = entity.validate(); await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser: undefined, caseToUpdate: caseEntity, }); @@ -52,6 +51,7 @@ export const checkForReadyForTrialCasesInteractor = async ( try { await acquireLock({ applicationContext, + authorizedUser: undefined, identifiers: [`case|${docketNumber}`], onLockError: new ServiceUnavailableError( `${docketNumber} is currently being updated`, @@ -83,7 +83,7 @@ export const checkForReadyForTrialCasesInteractor = async ( if (caseToCheck) { const caseEntity = new Case(caseToCheck, { - authorizedUser, + authorizedUser: undefined, }); if (caseEntity.status === CASE_STATUS_TYPES.generalDocket) { caseEntity.checkForReadyForTrial(); diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index e485a3b3303..6235c56c000 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -306,6 +306,7 @@ const setNoticeForCase = async ({ await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ applicationContext, + authorizedUser: undefined, caseToUpdate: caseEntity, }); From 0d447e5ff7ee0f025f07a1267b00ff3f6019e98b Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 23 Jul 2024 11:23:59 -0700 Subject: [PATCH 367/523] 10417 rm getCurrentUser and fix tests --- .../getCaseDeadlinesForCaseInteractor.test.ts | 9 -- .../addDeficiencyStatisticInteractor.test.ts | 55 ++++++----- ...cumentInteractor.consolidatedCases.test.ts | 94 +++++++++++-------- ...rtIssuedDocumentInteractor.locking.test.ts | 2 - 4 files changed, 87 insertions(+), 73 deletions(-) diff --git a/web-api/src/business/useCases/caseDeadline/getCaseDeadlinesForCaseInteractor.test.ts b/web-api/src/business/useCases/caseDeadline/getCaseDeadlinesForCaseInteractor.test.ts index ff9946cf065..25e68fa89b9 100644 --- a/web-api/src/business/useCases/caseDeadline/getCaseDeadlinesForCaseInteractor.test.ts +++ b/web-api/src/business/useCases/caseDeadline/getCaseDeadlinesForCaseInteractor.test.ts @@ -1,5 +1,3 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; -import { User } from '../../../../../shared/src/business/entities/User'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getCaseDeadlinesForCaseInteractor } from './getCaseDeadlinesForCaseInteractor'; @@ -12,15 +10,8 @@ describe('getCaseDeadlinesForCaseInteractor', () => { docketNumber: '123-20', }; - const mockUser = new User({ - name: 'Test Petitionsclerk', - role: ROLES.petitionsClerk, - userId: '6805d1ab-18d0-43ec-bafb-654e83405416', - }); - it('gets the case deadlines', async () => { applicationContext.environment.stage = 'local'; - applicationContext.getCurrentUser.mockReturnValue(mockUser); applicationContext .getPersistenceGateway() diff --git a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.test.ts b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.test.ts index 6f7bcc995df..8acce62e9bf 100644 --- a/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.test.ts +++ b/web-api/src/business/useCases/caseStatistics/addDeficiencyStatisticInteractor.test.ts @@ -1,9 +1,9 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { addDeficiencyStatisticInteractor } from './addDeficiencyStatisticInteractor'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; describe('addDeficiencyStatisticInteractor', () => { const mockStatistic = { @@ -39,11 +39,6 @@ describe('addDeficiencyStatisticInteractor', () => { beforeEach(() => { mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: 'docketClerk', - }); - applicationContext .getPersistenceGateway() .getCaseByDocketNumber.mockReturnValue(Promise.resolve(MOCK_CASE)); @@ -53,10 +48,14 @@ describe('addDeficiencyStatisticInteractor', () => { mockLock = MOCK_LOCK; await expect( - addDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - ...mockStatistic, - } as any), + addDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + ...mockStatistic, + } as any, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); expect( @@ -65,10 +64,14 @@ describe('addDeficiencyStatisticInteractor', () => { }); it('should acquire and remove the lock on the case', async () => { - await addDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - ...mockStatistic, - } as any); + await addDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + ...mockStatistic, + } as any, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().createLock, @@ -87,20 +90,26 @@ describe('addDeficiencyStatisticInteractor', () => { }); it('should throw an error if the user is unauthorized to update case statistics', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - await expect( - addDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - } as any), + addDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + } as any, + undefined, + ), ).rejects.toThrow('Unauthorized for editing statistics'); }); it('should call updateCase with the updated case statistics and return the updated case', async () => { - const result = await addDeficiencyStatisticInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - ...mockStatistic, - } as any); + const result = await addDeficiencyStatisticInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + ...mockStatistic, + } as any, + mockDocketClerkUser, + ); expect(result).toMatchObject({ statistics: [mockStatistic], diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.consolidatedCases.test.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.consolidatedCases.test.ts index 49f6d3e9afa..143ab721fba 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.consolidatedCases.test.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.consolidatedCases.test.ts @@ -11,6 +11,7 @@ import { import { MOCK_DOCUMENTS } from '../../../../../shared/src/test/mockDocketEntry'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { docketClerkUser } from '../../../../../shared/src/test/mockUsers'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { serveCourtIssuedDocumentInteractor } from './serveCourtIssuedDocumentInteractor'; import { v4 as uuidv4 } from 'uuid'; @@ -52,9 +53,6 @@ describe('serveCourtIssuedDocumentInteractor consolidated cases', () => { applicationContext .getPersistenceGateway() .getUserById.mockReturnValue(docketClerkUser); - - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getUseCaseHelpers() .countPagesInDocument.mockReturnValue(1); @@ -120,15 +118,19 @@ describe('serveCourtIssuedDocumentInteractor consolidated cases', () => { }); it('should call serveDocumentAndGetPaperServicePdf and pass the resulting url and success message to `sendNotificationToUser` along with the `clientConnectionId`', async () => { - await serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId, - docketEntryId: leadCaseDocketEntries[0].docketEntryId, - docketNumbers: [ - MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, - MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, - ], - subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, - }); + await serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: leadCaseDocketEntries[0].docketEntryId, + docketNumbers: [ + MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, + MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, + ], + subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getUseCaseHelpers().serveDocumentAndGetPaperServicePdf, @@ -170,15 +172,20 @@ describe('serveCourtIssuedDocumentInteractor consolidated cases', () => { .mockRejectedValueOnce(new Error(expectedErrorString)); await expect( - serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId, - docketEntryId: leadCaseDocketEntries[0].docketEntryId, - docketNumbers: [ - MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, - MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, - ], - subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, - }), + serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: leadCaseDocketEntries[0].docketEntryId, + docketNumbers: [ + MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, + MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, + ], + subjectCaseDocketNumber: + MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(expectedErrorString); const initialCall = 1; @@ -217,15 +224,20 @@ describe('serveCourtIssuedDocumentInteractor consolidated cases', () => { .mockRejectedValueOnce(innerError); await expect( - serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId, - docketEntryId: leadCaseDocketEntries[0].docketEntryId, - docketNumbers: [ - MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, - MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, - ], - subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, - }), + serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: leadCaseDocketEntries[0].docketEntryId, + docketNumbers: [ + MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, + MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, + ], + subjectCaseDocketNumber: + MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, + }, + mockDocketClerkUser, + ), ).rejects.toThrow(expectedErrorString); expect(applicationContext.logger.error).toHaveBeenCalledTimes(1); @@ -235,15 +247,19 @@ describe('serveCourtIssuedDocumentInteractor consolidated cases', () => { }); it('should create a single source of truth for the document by saving only one copy', async () => { - await serveCourtIssuedDocumentInteractor(applicationContext, { - clientConnectionId, - docketEntryId: leadCaseDocketEntries[0].docketEntryId, - docketNumbers: [ - MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, - MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, - ], - subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, - }); + await serveCourtIssuedDocumentInteractor( + applicationContext, + { + clientConnectionId, + docketEntryId: leadCaseDocketEntries[0].docketEntryId, + docketNumbers: [ + MOCK_CONSOLIDATED_1_CASE_WITH_PAPER_SERVICE.docketNumber, + MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE.docketNumber, + ], + subjectCaseDocketNumber: MOCK_LEAD_CASE_WITH_PAPER_SERVICE.docketNumber, + }, + mockDocketClerkUser, + ); expect( applicationContext.getPersistenceGateway().saveDocumentFromLambda, diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.locking.test.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.locking.test.ts index f13e3f1e207..670774e07bb 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.locking.test.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.locking.test.ts @@ -104,8 +104,6 @@ describe('serveCourtIssuedDocumentInteractor', () => { beforeEach(() => { mockLock = undefined; // unlocked - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getUseCaseHelpers() .fileAndServeDocumentOnOneCase.mockImplementation( From c8cc0c3443d484be7023954213de5b074574471e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 23 Jul 2024 14:02:59 -0700 Subject: [PATCH 368/523] 10417 rm getCurrentUser and fix tests --- web-api/src/applicationContext.ts | 17 +---------- .../addPaperFilingInteractor.locking.test.ts | 6 ++-- .../docketEntry/addPaperFilingInteractor.ts | 22 ++++++++------- ...leteDocketEntryWorksheetInteractor.test.ts | 1 - .../getPractitionerDocumentInteractor.test.ts | 15 ++-------- ...getPractitionerDocumentsInteractor.test.ts | 11 -------- .../getPractitionersByNameInteractor.test.ts | 14 ---------- ...PractitionerUserInteractor.locking.test.ts | 1 - .../deleteTrialSessionInteractor.test.ts | 6 ---- ...tTrialSessionWorkingCopyInteractor.test.ts | 2 -- .../getTrialSessionsInteractor.test.ts | 18 +++++------- .../setForHearingInteractor.test.ts | 1 - .../updateTrialSessionInteractor.test.ts | 11 +------- .../queueUpdateAssociatedCasesWorker.test.ts | 2 -- ...ntactInformationInteractor.locking.test.ts | 2 -- web-api/src/lambdas/v1/getCaseLambda.test.ts | 24 ---------------- .../v1/getDocumentDownloadUrlLambda.test.ts | 23 +-------------- web-api/src/lambdas/v2/getCaseLambda.test.ts | 28 +------------------ web-api/src/lambdas/v2/getCaseLambda.ts | 2 +- .../v2/getDocumentDownloadUrlLambda.test.ts | 23 +-------------- .../getDocumentQCServedForSection.test.ts | 4 --- .../getDocumentQCServedForUser.test.ts | 4 --- .../putWorkItemInUsersOutbox.test.ts | 4 --- ...rDocketClerkFilingExternalDocument.test.ts | 4 --- 24 files changed, 32 insertions(+), 213 deletions(-) diff --git a/web-api/src/applicationContext.ts b/web-api/src/applicationContext.ts index ea1f79a3467..bdee2a12690 100644 --- a/web-api/src/applicationContext.ts +++ b/web-api/src/applicationContext.ts @@ -12,7 +12,6 @@ import { MAX_SEARCH_CLIENT_RESULTS, MAX_SEARCH_RESULTS, ORDER_TYPES, - Role, SESSION_STATUS_GROUPS, TRIAL_SESSION_SCOPE_TYPES, } from '../../shared/src/business/entities/EntityConstants'; @@ -102,20 +101,7 @@ export const createApplicationContext = ( appContextUser = {}, logger = createLogger(), ) => { - let user; - - if (appContextUser) { - user = new User(appContextUser); - } - - const getCurrentUser = (): { - role: Role; - userId: string; - email: string; - name: string; - } => { - return user; - }; + const user = new User(appContextUser); if (process.env.NODE_ENV === 'production') { const authenticated = user && Object.keys(user).length; @@ -170,7 +156,6 @@ export const createApplicationContext = ( STATUS_TYPES: CASE_STATUS_TYPES, TRIAL_SESSION_SCOPE_TYPES, }), - getCurrentUser, getDispatchers: () => ({ sendBulkTemplatedEmail, sendNotificationOfSealing: diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.locking.test.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.locking.test.ts index 52bd17e66e9..1bc5d9e951b 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.locking.test.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.locking.test.ts @@ -49,9 +49,11 @@ describe('handleLockError', () => { .getUserById.mockReturnValue(docketClerkUser); }); - it('should determine who the user is based on method arg, not applicationContext', async () => { + it('should send notification to user when there is a lock error', async () => { await handleLockError(applicationContext, { foo: 'bar' }, docketClerkUser); - expect(applicationContext.getCurrentUser).not.toHaveBeenCalled(); + expect( + applicationContext.getNotificationGateway().sendNotificationToUser, + ).toHaveBeenCalled(); }); it('should send a notification to the user with "retry_async_request" and the originalRequest', async () => { diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts index 26a39cde7bc..7baa50829fd 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts @@ -291,16 +291,18 @@ export const handleLockError = async ( originalRequest, authorizedUser: UnknownAuthUser, ) => { - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - clientConnectionId: originalRequest.clientConnectionId, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'add_paper_filing', - }, - userId: authorizedUser!.userId, - }); + if (authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + clientConnectionId: originalRequest.clientConnectionId, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'add_paper_filing', + }, + userId: authorizedUser.userId, + }); + } }; export const addPaperFilingInteractor = withLocking( diff --git a/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.test.ts b/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.test.ts index 4aebaa12fd1..fff4681e1eb 100644 --- a/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.test.ts +++ b/web-api/src/business/useCases/pendingMotion/deleteDocketEntryWorksheetInteractor.test.ts @@ -16,7 +16,6 @@ describe('deleteDocketEntryWorksheetInteractor', () => { }); it('should throw an Unauthorized Error when user does not have permission', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); await expect( deleteDocketEntryWorksheetInteractor( applicationContext, diff --git a/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.test.ts b/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.test.ts index eb310dc3e0e..87a6726bfed 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerDocumentInteractor.test.ts @@ -1,13 +1,10 @@ -import { - PRACTITIONER_DOCUMENT_TYPES_MAP, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; +import { PRACTITIONER_DOCUMENT_TYPES_MAP } from '../../../../../shared/src/business/entities/EntityConstants'; import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getPractitionerDocumentInteractor } from './getPractitionerDocumentInteractor'; import { mockAdmissionsClerkUser, - mockPetitionsClerkUser, + mockPetitionerUser, } from '@shared/test/mockAuthUsers'; describe('getPractitionerDocumentInteractor', () => { @@ -26,12 +23,6 @@ describe('getPractitionerDocumentInteractor', () => { }); it('should throw an unauthorized error when the user does not have permission to update the practitioner user', async () => { - const testPetitionerUser = { - role: ROLES.petitioner, - userId: 'petitioner', - }; - applicationContext.getCurrentUser.mockReturnValueOnce(testPetitionerUser); - await expect( getPractitionerDocumentInteractor( applicationContext, @@ -39,7 +30,7 @@ describe('getPractitionerDocumentInteractor', () => { barNumber, practitionerDocumentFileId, }, - mockPetitionsClerkUser, + mockPetitionerUser, ), ).rejects.toThrow(UnauthorizedError); }); diff --git a/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.test.ts b/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.test.ts index 0fe5d026179..ce363ebce23 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionerDocumentsInteractor.test.ts @@ -1,4 +1,3 @@ -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getPractitionerDocumentsInteractor } from './getPractitionerDocumentsInteractor'; import { @@ -8,11 +7,6 @@ import { describe('getPractitionersDocumentsInteractor', () => { it('throws an unauthorized error exception when user is not an admissions clerk', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'petitioner', - }); - await expect( getPractitionerDocumentsInteractor( applicationContext, @@ -25,11 +19,6 @@ describe('getPractitionersDocumentsInteractor', () => { }); it('returns and validates the documents returned from persistence', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.admissionsClerk, - userId: 'bob', - }); - applicationContext .getPersistenceGateway() .getPractitionerDocuments.mockResolvedValue([ diff --git a/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.test.ts b/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.test.ts index 3db48d6dd7a..eff6fdb8899 100644 --- a/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.test.ts +++ b/web-api/src/business/useCases/practitioner/getPractitionersByNameInteractor.test.ts @@ -8,19 +8,7 @@ import { describe('getPractitionersByNameInteractor', () => { describe('Logged in User', () => { - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitionsClerk, - userId: 'petitionsClerk', - }); - }); - it('returns an unauthorized error on petitioner user role', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'petitioner', - }); - await expect( getPractitionersByNameInteractor( applicationContext, @@ -96,8 +84,6 @@ describe('getPractitionersByNameInteractor', () => { describe('Public User', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(undefined); - applicationContext .getPersistenceGateway() .getPractitionersByName.mockReturnValue({ diff --git a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.locking.test.ts b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.locking.test.ts index 7e34d5ca5dd..06af9bf8b69 100644 --- a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.locking.test.ts +++ b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.locking.test.ts @@ -101,7 +101,6 @@ describe('updatePractitionerUserInteractor', () => { beforeEach(() => { mockLock = undefined; // unlocked - applicationContext.getCurrentUser.mockReturnValue(admissionsClerkUser); applicationContext .getPersistenceGateway() diff --git a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.ts index 7b6d55aeaf9..9ca7a0e1745 100644 --- a/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/deleteTrialSessionInteractor.test.ts @@ -1,7 +1,6 @@ import { MOCK_CASE } from '../../../../../shared/src/test/mockCase'; import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; import { MOCK_TRIAL_REGULAR } from '../../../../../shared/src/test/mockTrial'; -import { ROLES } from '../../../../../shared/src/business/entities/EntityConstants'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { deleteTrialSessionInteractor } from './deleteTrialSessionInteractor'; @@ -31,11 +30,6 @@ describe('deleteTrialSessionInteractor', () => { }); it('throws error if user is unauthorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.petitioner, - userId: 'petitioner', - }); - await expect( deleteTrialSessionInteractor( applicationContext, diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.ts index 35652a4d81c..dea89042fad 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor.test.ts @@ -45,7 +45,6 @@ describe('Get trial session working copy', () => { trialLocation: 'Birmingham, Alabama', }); - applicationContext.getCurrentUser.mockImplementation(() => user); applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ ...user, section: 'colvinsChambers', @@ -198,7 +197,6 @@ describe('Get trial session working copy', () => { trialClerk: undefined, trialLocation: 'Birmingham, Alabama', }); - applicationContext.getCurrentUser.mockReturnValue(); const result = await getTrialSessionWorkingCopyInteractor( applicationContext, { diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts index 3abbd63f244..60e283bdd13 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts @@ -6,20 +6,16 @@ import { TrialSessionInfoDTO } from '../../../../../shared/src/business/dto/tria import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { getTrialSessionsInteractor } from './getTrialSessionsInteractor'; -import { omit } from 'lodash'; import { - petitionerUser, - petitionsClerkUser, -} from '../../../../../shared/src/test/mockUsers'; + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; +import { omit } from 'lodash'; describe('getTrialSessionsInteractor', () => { - beforeEach(() => { - //applicationContext.getCurrentUser.mockReturnValue(petitionsClerkUser); - }); - it('should throw an unauthorized error when the user does not have permission to view trial sessions', async () => { await expect( - getTrialSessionsInteractor(applicationContext, petitionerUser), + getTrialSessionsInteractor(applicationContext, mockPetitionerUser), ).rejects.toThrow(new UnauthorizedError('Unauthorized')); }); @@ -31,7 +27,7 @@ describe('getTrialSessionsInteractor', () => { ]); await expect( - getTrialSessionsInteractor(applicationContext, petitionsClerkUser), + getTrialSessionsInteractor(applicationContext, mockPetitionsClerkUser), ).rejects.toThrow('The TrialSession entity was invalid.'); }); @@ -45,7 +41,7 @@ describe('getTrialSessionsInteractor', () => { const trialSessionDTOs = await getTrialSessionsInteractor( applicationContext, - petitionsClerkUser, + mockPetitionsClerkUser, ); trialSessionDTOs.forEach(trialSessionDTO => { diff --git a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.test.ts b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.test.ts index ce39c335745..7d79136b3a7 100644 --- a/web-api/src/business/useCases/trialSessions/setForHearingInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/setForHearingInteractor.test.ts @@ -19,7 +19,6 @@ describe('setForHearingInteractor', () => { mockCase = MOCK_CASE; - applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser); applicationContext .getPersistenceGateway() .getTrialSessionById.mockImplementation(() => mockTrialSession); diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.ts index 111906a720b..47461af33ad 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.test.ts @@ -10,12 +10,7 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; -import { - docketClerkUser, - judgeUser, - petitionerUser, - trialClerkUser, -} from '@shared/test/mockUsers'; +import { judgeUser, trialClerkUser } from '@shared/test/mockUsers'; import { mockDocketClerkUser, mockPetitionerUser, @@ -24,8 +19,6 @@ import { updateTrialSessionInteractor } from './updateTrialSessionInteractor'; describe('updateTrialSessionInteractor', () => { beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - applicationContext .getUseCaseHelpers() .saveFileAndGenerateUrl.mockReturnValue({ @@ -39,8 +32,6 @@ describe('updateTrialSessionInteractor', () => { }); it('should throw an error when the user is not unauthorized to update a trial session', async () => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - await expect( updateTrialSessionInteractor( applicationContext, diff --git a/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.test.ts b/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.test.ts index 0b1a3cd8bee..f75182142a8 100644 --- a/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.test.ts +++ b/web-api/src/business/useCases/user/queueUpdateAssociatedCasesWorker.test.ts @@ -37,7 +37,6 @@ describe('queueUpdateAssociatedCasesWorker', () => { applicationContext .getPersistenceGateway() .getDocketNumbersByUser.mockReturnValue(['111-20', '222-20', '333-20']); - applicationContext.getCurrentUser.mockReturnValue(MOCK_PRACTITIONER); applicationContext.getWorkerGateway().queueWork.mockReturnValue({}); const authorizedUser = { email: MOCK_PRACTITIONER.email!, @@ -87,7 +86,6 @@ describe('queueUpdateAssociatedCasesWorker', () => { applicationContext .getPersistenceGateway() .getDocketNumbersByUser.mockReturnValue(['111-20', '222-20', '333-20']); - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); applicationContext.getWorkerGateway().queueWork.mockReturnValue({}); const authorizedUser = { email: petitionerUser.email, diff --git a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.locking.test.ts b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.locking.test.ts index 529d15fd50f..337e76034d4 100644 --- a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.locking.test.ts +++ b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.locking.test.ts @@ -102,8 +102,6 @@ describe('updateUserContactInformationInteractor', () => { beforeEach(() => { mockLock = undefined; // unlocked - applicationContext.getCurrentUser.mockReturnValue(MOCK_PRACTITIONER); - applicationContext.getPersistenceGateway().getUserById.mockReturnValue({ ...MOCK_PRACTITIONER, entityName: 'Practitioner', diff --git a/web-api/src/lambdas/v1/getCaseLambda.test.ts b/web-api/src/lambdas/v1/getCaseLambda.test.ts index d8e421b6a9f..1902acfddb3 100644 --- a/web-api/src/lambdas/v1/getCaseLambda.test.ts +++ b/web-api/src/lambdas/v1/getCaseLambda.test.ts @@ -1,7 +1,4 @@ -import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { MOCK_CASE_WITH_TRIAL_SESSION } from '../../../../shared/src/test/mockCase'; -import { MOCK_USERS } from '../../../../shared/src/test/mockUsers'; -import { Role } from '@shared/business/entities/EntityConstants'; import { getCaseLambda } from './getCaseLambda'; import { createTestApplicationContext as mockCreateTestApplicationContext } from '@shared/business/test/createTestApplicationContext'; import { getCaseInteractor as mockGetCaseInteractor } from '@shared/business/useCases/getCaseInteractor'; @@ -22,8 +19,6 @@ jest.mock('@web-api/applicationContext', () => { .fn() .mockImplementation(mockGetCaseInteractor); - appContext.getCurrentUser = jest.fn().mockReturnValue(mockUser); - if (mockShouldThrowError) { appContext.getDocumentClient = jest.fn().mockReturnValue({ query: jest.fn().mockRejectedValue(new Error('test error')), @@ -44,19 +39,15 @@ const mockDynamoCaseRecord = Object.assign({}, MOCK_CASE_WITH_TRIAL_SESSION, { let mockItems; let mockFeatureFlag; let mockShouldThrowError; -let mockUser; const setupMock = ({ featureFlag, items, shouldThrowError, - user, }: { items: (typeof mockDynamoCaseRecord)[]; featureFlag: boolean; shouldThrowError: boolean; - user: AuthUser; }) => { - mockUser = user; mockItems = items; mockShouldThrowError = shouldThrowError; mockFeatureFlag = featureFlag; @@ -115,12 +106,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG featureFlag: true, items: [], shouldThrowError: false, - user: { - email: '', - name: '', - role: 'roleWithNoPermissions' as Role, - userId: '', - }, }); const response = await getCaseLambda(REQUEST_EVENT, {}); @@ -138,12 +123,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG featureFlag: true, items: [mockDynamoCaseRecord], shouldThrowError: false, - user: { - email: '', - name: '', - role: 'roleWithNoPermissions' as Role, - userId: '', - }, }); const response = await getCaseLambda(REQUEST_EVENT, {}); @@ -167,7 +146,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG featureFlag: true, items: [], shouldThrowError: false, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getCaseLambda(REQUEST_EVENT, {}); @@ -185,7 +163,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG featureFlag: true, items: [], shouldThrowError: true, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getCaseLambda(REQUEST_EVENT, {}); @@ -206,7 +183,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG featureFlag: isFeatureFlagOn, items: [mockDynamoCaseRecord], shouldThrowError: false, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getCaseLambda(REQUEST_EVENT, {}); diff --git a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts index 4fcd20f6ae1..594ba5786e5 100644 --- a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts +++ b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts @@ -1,10 +1,5 @@ -import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { - CASE_STATUS_TYPES, - Role, -} from '@shared/business/entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; import { MOCK_PETITION } from '@shared/test/mockDocketEntry'; -import { MOCK_USERS } from '../../../../shared/src/test/mockUsers'; import { getDocumentDownloadUrlLambda } from './getDocumentDownloadUrlLambda'; import { createTestApplicationContext as mockCreateTestApplicationContext } from '@shared/business/test/createTestApplicationContext'; import { getDownloadPolicyUrlInteractor as mockGetDownloadPolicyUrlInteractor } from '@web-api/business/useCases/document/getDownloadPolicyUrlInteractor'; @@ -20,8 +15,6 @@ jest.mock('@web-api/applicationContext', () => { .fn() .mockImplementation(mockGetDownloadPolicyUrlInteractor); - appContext.getCurrentUser = jest.fn().mockReturnValue(mockUser); - appContext.getDocumentClient = jest.fn().mockReturnValue({ query: jest.fn().mockResolvedValue({ Items: mockItems, @@ -51,20 +44,16 @@ jest.mock('@web-api/applicationContext', () => { let mockFeatureFlag; let mockShouldThrowError; -let mockUser; let mockItems; const setupMock = ({ featureFlag, items, shouldThrowError, - user, }: { items: any[]; featureFlag: boolean; shouldThrowError: boolean; - user: AuthUser; }) => { - mockUser = user; mockShouldThrowError = shouldThrowError; mockFeatureFlag = featureFlag; mockItems = items; @@ -95,12 +84,6 @@ describe('getDocumentDownloadUrlLambda', () => { featureFlag: true, items: [], shouldThrowError: false, - user: { - email: '', - name: '', - role: 'roleWithNoPermissions' as Role, - userId: '', - }, }); const response = await getDocumentDownloadUrlLambda(REQUEST_EVENT, {}); @@ -122,7 +105,6 @@ describe('getDocumentDownloadUrlLambda', () => { featureFlag: true, items: [], shouldThrowError: false, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getDocumentDownloadUrlLambda(request, {}); @@ -162,7 +144,6 @@ describe('getDocumentDownloadUrlLambda', () => { }, ], shouldThrowError: false, - user: MOCK_USERS['2eee98ac-613f-46bc-afd5-2574d1b15664'] as AuthUser, }); const response = await getDocumentDownloadUrlLambda(request, {}); @@ -187,7 +168,6 @@ describe('getDocumentDownloadUrlLambda', () => { featureFlag: true, items: [], shouldThrowError: true, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getDocumentDownloadUrlLambda(request, {}); @@ -228,7 +208,6 @@ describe('getDocumentDownloadUrlLambda', () => { }, ], shouldThrowError: false, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getDocumentDownloadUrlLambda(request, {}); diff --git a/web-api/src/lambdas/v2/getCaseLambda.test.ts b/web-api/src/lambdas/v2/getCaseLambda.test.ts index 554b8aa0326..1bb57d38ba2 100644 --- a/web-api/src/lambdas/v2/getCaseLambda.test.ts +++ b/web-api/src/lambdas/v2/getCaseLambda.test.ts @@ -1,11 +1,6 @@ -import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { MOCK_CASE_WITH_TRIAL_SESSION } from '../../../../shared/src/test/mockCase'; import { MOCK_COMPLEX_CASE } from '../../../../shared/src/test/mockComplexCase'; -import { - MOCK_PRACTITIONER, - MOCK_USERS, -} from '../../../../shared/src/test/mockUsers'; -import { Role } from '@shared/business/entities/EntityConstants'; +import { MOCK_PRACTITIONER } from '../../../../shared/src/test/mockUsers'; import { getCaseLambda } from './getCaseLambda'; import { createTestApplicationContext as mockCreateTestApplicationContext } from '@shared/business/test/createTestApplicationContext'; import { getCaseInteractor as mockGetCaseInteractor } from '@shared/business/useCases/getCaseInteractor'; @@ -26,8 +21,6 @@ jest.mock('@web-api/applicationContext', () => { .fn() .mockImplementation(mockGetCaseInteractor); - appContext.getCurrentUser = jest.fn().mockReturnValue(mockUser); - if (mockShouldThrowError) { appContext.getDocumentClient = jest.fn().mockReturnValue({ query: jest.fn().mockRejectedValue(new Error('test error')), @@ -42,19 +35,15 @@ jest.mock('@web-api/applicationContext', () => { let mockItems; let mockFeatureFlag; let mockShouldThrowError; -let mockUser; const setupMock = ({ featureFlag, items, shouldThrowError, - user, }: { items: any[]; featureFlag: boolean; shouldThrowError: boolean; - user: AuthUser; }) => { - mockUser = user; mockItems = items; mockShouldThrowError = shouldThrowError; mockFeatureFlag = featureFlag; @@ -93,12 +82,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG featureFlag: true, items: [], shouldThrowError: false, - user: { - email: '', - name: '', - role: 'roleWithNoPermissions' as Role, - userId: '', - }, }); const response = await getCaseLambda(REQUEST_EVENT, {}); @@ -116,12 +99,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG featureFlag: true, items: [mockDynamoCaseRecord], shouldThrowError: false, - user: { - email: '', - name: '', - role: 'roleWithNoPermissions' as Role, - userId: '', - }, }); const response = await getCaseLambda(REQUEST_EVENT, {}); @@ -145,7 +122,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG featureFlag: true, items: [], shouldThrowError: false, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getCaseLambda(REQUEST_EVENT, {}); @@ -163,7 +139,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG featureFlag: true, items: [], shouldThrowError: true, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getCaseLambda(REQUEST_EVENT, {}); @@ -208,7 +183,6 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG mockPrivatePractitionerRecord, ], shouldThrowError: false, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getCaseLambda(REQUEST_EVENT, {}); diff --git a/web-api/src/lambdas/v2/getCaseLambda.ts b/web-api/src/lambdas/v2/getCaseLambda.ts index b151404b285..9670df29113 100644 --- a/web-api/src/lambdas/v2/getCaseLambda.ts +++ b/web-api/src/lambdas/v2/getCaseLambda.ts @@ -14,7 +14,7 @@ import { v2ApiWrapper } from './v2ApiWrapper'; export const getCaseLambda = ( event, authorizedUser: UnknownAuthUser, - options, + options, // TODO 10417 Remove all instances of passing in options via lambda params ) => genericHandler( event, diff --git a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts index d1363c4b194..5a242381d20 100644 --- a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts +++ b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts @@ -1,10 +1,5 @@ -import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { - CASE_STATUS_TYPES, - Role, -} from '@shared/business/entities/EntityConstants'; +import { CASE_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; import { MOCK_PETITION } from '@shared/test/mockDocketEntry'; -import { MOCK_USERS } from '../../../../shared/src/test/mockUsers'; import { getDocumentDownloadUrlLambda } from './getDocumentDownloadUrlLambda'; import { createTestApplicationContext as mockCreateTestApplicationContext } from '@shared/business/test/createTestApplicationContext'; import { getDownloadPolicyUrlInteractor as mockGetDownloadPolicyUrlInteractor } from '@web-api/business/useCases/document/getDownloadPolicyUrlInteractor'; @@ -20,8 +15,6 @@ jest.mock('@web-api/applicationContext', () => { .fn() .mockImplementation(mockGetDownloadPolicyUrlInteractor); - appContext.getCurrentUser = jest.fn().mockReturnValue(mockUser); - appContext.getDocumentClient = jest.fn().mockReturnValue({ query: jest.fn().mockResolvedValue({ Items: mockItems, @@ -51,20 +44,16 @@ jest.mock('@web-api/applicationContext', () => { let mockFeatureFlag; let mockShouldThrowError; -let mockUser; let mockItems; const setupMock = ({ featureFlag, items, shouldThrowError, - user, }: { items: any[]; featureFlag: boolean; shouldThrowError: boolean; - user: AuthUser; }) => { - mockUser = user; mockShouldThrowError = shouldThrowError; mockFeatureFlag = featureFlag; mockItems = items; @@ -95,12 +84,6 @@ describe('getDocumentDownloadUrlLambda', () => { featureFlag: true, items: [], shouldThrowError: false, - user: { - email: '', - name: '', - role: 'roleWithNoPermissions' as Role, - userId: '', - }, }); const response = await getDocumentDownloadUrlLambda(REQUEST_EVENT, {}); @@ -122,7 +105,6 @@ describe('getDocumentDownloadUrlLambda', () => { featureFlag: true, items: [], shouldThrowError: false, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getDocumentDownloadUrlLambda(request, {}); @@ -162,7 +144,6 @@ describe('getDocumentDownloadUrlLambda', () => { }, ], shouldThrowError: false, - user: MOCK_USERS['2eee98ac-613f-46bc-afd5-2574d1b15664'] as AuthUser, }); const response = await getDocumentDownloadUrlLambda(request, {}); @@ -187,7 +168,6 @@ describe('getDocumentDownloadUrlLambda', () => { featureFlag: true, items: [], shouldThrowError: true, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getDocumentDownloadUrlLambda(request, {}); @@ -228,7 +208,6 @@ describe('getDocumentDownloadUrlLambda', () => { }, ], shouldThrowError: false, - user: MOCK_USERS['b7d90c05-f6cd-442c-a168-202db587f16f'] as AuthUser, }); const response = await getDocumentDownloadUrlLambda(request, {}); diff --git a/web-api/src/persistence/dynamo/workitems/getDocumentQCServedForSection.test.ts b/web-api/src/persistence/dynamo/workitems/getDocumentQCServedForSection.test.ts index bf582ab9843..672e1bb3c7a 100644 --- a/web-api/src/persistence/dynamo/workitems/getDocumentQCServedForSection.test.ts +++ b/web-api/src/persistence/dynamo/workitems/getDocumentQCServedForSection.test.ts @@ -41,10 +41,6 @@ describe('getDocumentQCServedForSection', () => { }); it('invokes the persistence layer with pk of {userId}|outbox and {section}|outbox and other expected params', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - section: DOCKET_SECTION, - userId: '1805d1ab-18d0-43ec-bafb-654e83405416', - }); applicationContext.getDocumentClient.mockReturnValue({ query: queryStub, }); diff --git a/web-api/src/persistence/dynamo/workitems/getDocumentQCServedForUser.test.ts b/web-api/src/persistence/dynamo/workitems/getDocumentQCServedForUser.test.ts index f4b5ab5e459..72209bfd291 100644 --- a/web-api/src/persistence/dynamo/workitems/getDocumentQCServedForUser.test.ts +++ b/web-api/src/persistence/dynamo/workitems/getDocumentQCServedForUser.test.ts @@ -43,10 +43,6 @@ describe('getDocumentQCServedForUser', () => { }); it('should filter out the work items returned from persistence to only have served documents', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - section: DOCKET_SECTION, - userId: '1805d1ab-18d0-43ec-bafb-654e83405416', - }); applicationContext.getDocumentClient.mockReturnValue({ query: queryStub, }); diff --git a/web-api/src/persistence/dynamo/workitems/putWorkItemInUsersOutbox.test.ts b/web-api/src/persistence/dynamo/workitems/putWorkItemInUsersOutbox.test.ts index 7cc5a89218f..48fbb00ffb1 100644 --- a/web-api/src/persistence/dynamo/workitems/putWorkItemInUsersOutbox.test.ts +++ b/web-api/src/persistence/dynamo/workitems/putWorkItemInUsersOutbox.test.ts @@ -22,10 +22,6 @@ describe('putWorkItemInUsersOutbox', () => { it('invokes the persistence layer with pk of user-outbox|{userId} and section-outbox|{section} and other expected params', async () => { const timestamp = createISODateString(); - applicationContext.getCurrentUser.mockReturnValue({ - section: DOCKET_SECTION, - userId: '1805d1ab-18d0-43ec-bafb-654e83405416', - }); applicationContext.getDocumentClient.mockReturnValue({ get: getStub, put: putStub, diff --git a/web-api/src/persistence/dynamo/workitems/saveWorkItemForDocketClerkFilingExternalDocument.test.ts b/web-api/src/persistence/dynamo/workitems/saveWorkItemForDocketClerkFilingExternalDocument.test.ts index 88443632e41..35767656152 100644 --- a/web-api/src/persistence/dynamo/workitems/saveWorkItemForDocketClerkFilingExternalDocument.test.ts +++ b/web-api/src/persistence/dynamo/workitems/saveWorkItemForDocketClerkFilingExternalDocument.test.ts @@ -22,10 +22,6 @@ describe('saveWorkItemForDocketClerkFilingExternalDocument', () => { it('invokes the persistence layer 5 times to store the work item, user and section outbox records, and work item mapping record', async () => { const timestamp = createISODateString(); - applicationContext.getCurrentUser.mockReturnValue({ - section: DOCKET_SECTION, - userId: '1805d1ab-18d0-43ec-bafb-654e83405416', - }); applicationContext.getDocumentClient.mockReturnValue({ get: getStub, put: putStub, From c830b02d8c4c89c383c503332739db847188f63b Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 23 Jul 2024 14:51:13 -0700 Subject: [PATCH 369/523] 10417: rm getCurrentUser from tests --- docs/entity-locking.md | 23 ++++++++++--------- .../test/createTestApplicationContext.ts | 18 ++------------- web-api/src/lambdas/v1/getCaseLambda.test.ts | 4 ++-- .../v1/getDocumentDownloadUrlLambda.test.ts | 4 ++-- web-api/src/lambdas/v2/getCaseLambda.test.ts | 4 ++-- .../v2/getDocumentDownloadUrlLambda.test.ts | 4 ++-- web-client/src/applicationContextPublic.ts | 1 - .../canRequestAccessAction.test.ts | 5 ---- .../setPractitionerOnFormAction.test.ts | 4 ---- ...ondentCaseAssociationRequestAction.test.ts | 3 --- ...tDefaultJudgeNameBasedOnUserAction.test.ts | 2 -- ...erAssociatedWithTrialSessionAction.test.ts | 8 ------- .../completeDocumentSigningAction.test.ts | 4 ---- .../completeMotionStampingAction.test.ts | 4 ---- .../actions/createCaseFromPaperAction.test.ts | 3 --- ...tCompletedMessagesForSectionAction.test.ts | 1 - ...getDocumentQCInboxForSectionAction.test.ts | 3 --- .../actions/getUsersInSectionAction.test.ts | 3 --- .../setDefaultGenerationTypeAction.test.ts | 2 -- .../advancedSearchHelper.test.ts | 3 --- .../practitionerSearchHelper.test.ts | 6 ----- ...caseDetailPractitionerSearchHelper.test.ts | 6 ----- .../caseInventoryReportHelper.test.ts | 6 ----- .../documentViewerHelper.showButtons.test.ts | 6 ----- .../computeds/fileDocumentHelper.test.ts | 2 -- ...tedCaseDetail.formattedClosedCases.test.ts | 9 +------- ...attedCaseDetail.formattedOpenCases.test.ts | 9 +------- .../formattedDashboardTrialSessions.test.ts | 7 ------ .../formattedTrialSessionDetails.test.ts | 3 --- ...formattedWorkQueue.filterWorkItems.test.ts | 5 ---- .../presenter/computeds/headerHelper.test.ts | 1 - ...iesInformationHelper.formatCounsel.test.ts | 5 ---- .../computeds/reportMenuHelper.test.ts | 1 - .../scanBatchPreviewerHelper.test.ts | 4 ---- .../computeds/startCaseHelper.test.ts | 9 -------- .../computeds/viewCounselHelper.test.ts | 12 ++++------ .../sequences/chooseWorkQueueSequence.test.ts | 5 ---- ...ntablePendingReportForCaseSequence.test.ts | 5 ---- .../createClientTestApplicationContext.ts | 8 ------- 39 files changed, 28 insertions(+), 184 deletions(-) diff --git a/docs/entity-locking.md b/docs/entity-locking.md index 2d52f8eff08..2e0a1db0d83 100644 --- a/docs/entity-locking.md +++ b/docs/entity-locking.md @@ -135,18 +135,19 @@ You may wish for a function to be called if you fail to acquire a lock. One use const handleLockError = async ( applicationContext: IApplicationContext, originalRequest: any, + authorizedUser: UnknownAuthUser ) => { - const user = applicationContext.getCurrentUser(); - - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'update_something', - }, - userId: user.userId, - }); + if(authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'update_something', + }, + userId: user.userId, + }); + } }; ``` diff --git a/shared/src/business/test/createTestApplicationContext.ts b/shared/src/business/test/createTestApplicationContext.ts index df9e100a888..7e15fa12315 100644 --- a/shared/src/business/test/createTestApplicationContext.ts +++ b/shared/src/business/test/createTestApplicationContext.ts @@ -1,10 +1,7 @@ /* eslint-disable max-lines */ import * as DateHandler from '@shared/business/utilities/DateHandler'; import * as pdfLib from 'pdf-lib'; -import { - ALLOWLIST_FEATURE_FLAGS, - ROLES, -} from '@shared/business/entities/EntityConstants'; +import { ALLOWLIST_FEATURE_FLAGS } from '@shared/business/entities/EntityConstants'; import { Case, canAllowDocumentServiceForCase, @@ -155,9 +152,7 @@ const appContextProxy = (initial = {}, makeMock = true) => { return makeMock ? jest.fn().mockReturnValue(proxied) : proxied; }; -export const createTestApplicationContext = ({ - user, -}: { user?: User } = {}) => { +export const createTestApplicationContext = () => { const emptyAppContextProxy = appContextProxy(); const mockGetPdfJsReturnValue = { @@ -628,15 +623,6 @@ export const createTestApplicationContext = ({ ERROR_MAP_429, }; }), - getCurrentUser: jest.fn().mockImplementation(() => { - return new User( - user || { - name: 'richard', - role: ROLES.petitioner, - userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', - }, - ); - }), getCurrentUserPermissions: jest.fn(), getDispatchers: jest.fn().mockReturnValue({ sendBulkTemplatedEmail: jest.fn(), diff --git a/web-api/src/lambdas/v1/getCaseLambda.test.ts b/web-api/src/lambdas/v1/getCaseLambda.test.ts index 1902acfddb3..4613e9d6dc5 100644 --- a/web-api/src/lambdas/v1/getCaseLambda.test.ts +++ b/web-api/src/lambdas/v1/getCaseLambda.test.ts @@ -5,8 +5,8 @@ import { getCaseInteractor as mockGetCaseInteractor } from '@shared/business/use jest.mock('@web-api/applicationContext', () => { return { - createApplicationContext: user => { - let appContext = mockCreateTestApplicationContext(user); + createApplicationContext: () => { + let appContext = mockCreateTestApplicationContext(); appContext.getUseCases().getAllFeatureFlagsInteractor = jest .fn() .mockResolvedValue(mockFeatureFlag); diff --git a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts index 594ba5786e5..7be4d6c1f22 100644 --- a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts +++ b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts @@ -6,8 +6,8 @@ import { getDownloadPolicyUrlInteractor as mockGetDownloadPolicyUrlInteractor } jest.mock('@web-api/applicationContext', () => { return { - createApplicationContext: user => { - let appContext = mockCreateTestApplicationContext(user); + createApplicationContext: () => { + let appContext = mockCreateTestApplicationContext(); appContext.getUseCases().getAllFeatureFlagsInteractor = jest .fn() .mockResolvedValue(mockFeatureFlag); diff --git a/web-api/src/lambdas/v2/getCaseLambda.test.ts b/web-api/src/lambdas/v2/getCaseLambda.test.ts index 1bb57d38ba2..310f6795c87 100644 --- a/web-api/src/lambdas/v2/getCaseLambda.test.ts +++ b/web-api/src/lambdas/v2/getCaseLambda.test.ts @@ -7,8 +7,8 @@ import { getCaseInteractor as mockGetCaseInteractor } from '@shared/business/use jest.mock('@web-api/applicationContext', () => { return { - createApplicationContext: user => { - let appContext = mockCreateTestApplicationContext(user); + createApplicationContext: () => { + let appContext = mockCreateTestApplicationContext(); appContext.getUseCases().getAllFeatureFlagsInteractor = jest .fn() .mockResolvedValue(mockFeatureFlag); diff --git a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts index 5a242381d20..bea02cc14a7 100644 --- a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts +++ b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts @@ -6,8 +6,8 @@ import { getDownloadPolicyUrlInteractor as mockGetDownloadPolicyUrlInteractor } jest.mock('@web-api/applicationContext', () => { return { - createApplicationContext: user => { - let appContext = mockCreateTestApplicationContext(user); + createApplicationContext: () => { + let appContext = mockCreateTestApplicationContext(); appContext.getUseCases().getAllFeatureFlagsInteractor = jest .fn() .mockResolvedValue(mockFeatureFlag); diff --git a/web-client/src/applicationContextPublic.ts b/web-client/src/applicationContextPublic.ts index dca6e01c52c..6eaa6b508d1 100644 --- a/web-client/src/applicationContextPublic.ts +++ b/web-client/src/applicationContextPublic.ts @@ -169,7 +169,6 @@ const applicationContextPublic = { }, getCaseTitle: Case.getCaseTitle, getConstants: () => frozenConstants, - getCurrentUser: () => ({}), getEnvironment, getForceRefreshCallback() { return forceRefreshCallback; diff --git a/web-client/src/presenter/actions/CaseAssociationRequest/canRequestAccessAction.test.ts b/web-client/src/presenter/actions/CaseAssociationRequest/canRequestAccessAction.test.ts index 59aee3f9bd9..9f78c9eeed5 100644 --- a/web-client/src/presenter/actions/CaseAssociationRequest/canRequestAccessAction.test.ts +++ b/web-client/src/presenter/actions/CaseAssociationRequest/canRequestAccessAction.test.ts @@ -1,4 +1,3 @@ -import { ROLES } from '@shared/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { canRequestAccessAction } from './canRequestAccessAction'; import { presenter } from '../../presenter'; @@ -11,10 +10,6 @@ describe('canRequestAccessAction', () => { yes: jest.fn(), }; - (applicationContext.getCurrentUser as jest.Mock).mockReturnValue({ - role: ROLES.irsPractitioner, - }); - it('should call path.yes if props.isAssociated is false or undefined', async () => { await runAction(canRequestAccessAction, { modules: { diff --git a/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.test.ts b/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.test.ts index 2a1f5f45133..9e3aa56fb76 100644 --- a/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.test.ts +++ b/web-client/src/presenter/actions/FileDocument/setPractitionerOnFormAction.test.ts @@ -9,10 +9,6 @@ describe('setPractitionerOnFormAction', () => { presenter.providers.applicationContext = applicationContext; it('should not set state.form.practitioner when the logged in user is not a privatePractitioner', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: USER_ROLES.docketClerk, - }); - const { state } = await runAction(setPractitionerOnFormAction, { modules: { presenter }, state: { diff --git a/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.test.ts b/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.test.ts index 84951bcb23c..44c4b773b89 100644 --- a/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.test.ts +++ b/web-client/src/presenter/actions/FileDocument/submitRespondentCaseAssociationRequestAction.test.ts @@ -25,8 +25,6 @@ describe('submitRespondentCaseAssociationRequestAction', () => { }); it('should call submitCaseAssociationRequestInteractor when the logged in user is an IRS practitioner', async () => { - applicationContext.getCurrentUser.mockReturnValue(irsPractitionerUser); - await runAction(submitRespondentCaseAssociationRequestAction, { modules: { presenter }, state: { @@ -46,7 +44,6 @@ describe('submitRespondentCaseAssociationRequestAction', () => { }); it('should return the updated case as props', async () => { - applicationContext.getCurrentUser.mockReturnValue(irsPractitionerUser); applicationContext .getUseCases() .submitCaseAssociationRequestInteractor.mockResolvedValue(MOCK_CASE); diff --git a/web-client/src/presenter/actions/JudgeActivityReport/setDefaultJudgeNameBasedOnUserAction.test.ts b/web-client/src/presenter/actions/JudgeActivityReport/setDefaultJudgeNameBasedOnUserAction.test.ts index f56f1941861..1679328836c 100644 --- a/web-client/src/presenter/actions/JudgeActivityReport/setDefaultJudgeNameBasedOnUserAction.test.ts +++ b/web-client/src/presenter/actions/JudgeActivityReport/setDefaultJudgeNameBasedOnUserAction.test.ts @@ -8,8 +8,6 @@ describe('setDefaultJudgeNameBasedOnUserAction', () => { presenter.providers.applicationContext = applicationContext; it('should set state.judgeActivityReport.filters.judgeName to the last name of the current user', async () => { - applicationContext.getCurrentUser.mockReturnValue(judgeUser); - const { state } = await runAction(setDefaultJudgeNameBasedOnUserAction, { modules: { presenter, diff --git a/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.test.ts b/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.test.ts index dc1a8134a57..34470fa0c9b 100644 --- a/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.test.ts +++ b/web-client/src/presenter/actions/TrialSession/isUserAssociatedWithTrialSessionAction.test.ts @@ -59,10 +59,6 @@ describe('isUserAssociatedWithTrialSessionAction', () => { }); it('should return path.no() if the user is in the chambers section and their judge is not associated with the trial session', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: USER_ROLES.chambers, - userId: '234', - }); await runAction(isUserAssociatedWithTrialSessionAction, { modules: { presenter, @@ -104,10 +100,6 @@ describe('isUserAssociatedWithTrialSessionAction', () => { }); it('should return path.yes() if the current user is a trial clerk for this trial session', async () => { - applicationContext.getCurrentUser.mockReturnValue({ - role: USER_ROLES.trialClerk, - userId: '123', - }); await runAction(isUserAssociatedWithTrialSessionAction, { modules: { presenter, diff --git a/web-client/src/presenter/actions/completeDocumentSigningAction.test.ts b/web-client/src/presenter/actions/completeDocumentSigningAction.test.ts index 6e48972f47d..1670a225773 100644 --- a/web-client/src/presenter/actions/completeDocumentSigningAction.test.ts +++ b/web-client/src/presenter/actions/completeDocumentSigningAction.test.ts @@ -57,10 +57,6 @@ describe('completeDocumentSigningAction', () => { }, }; - applicationContext.getCurrentUser.mockReturnValue({ - userId: '15adf875-8c3c-4e94-91e9-a4c1bff51291', - }); - mockPdfjsObj = { getData: jest.fn().mockResolvedValue(true), }; diff --git a/web-client/src/presenter/actions/completeMotionStampingAction.test.ts b/web-client/src/presenter/actions/completeMotionStampingAction.test.ts index e5307b6f071..87678c7b188 100644 --- a/web-client/src/presenter/actions/completeMotionStampingAction.test.ts +++ b/web-client/src/presenter/actions/completeMotionStampingAction.test.ts @@ -57,10 +57,6 @@ describe('completeMotionStampingAction', () => { }, }; - applicationContext.getCurrentUser.mockReturnValue({ - userId: '15adf875-8c3c-4e94-91e9-a4c1bff51291', - }); - global.File = jest.fn(); uploadDocumentFromClient.mockReturnValue( diff --git a/web-client/src/presenter/actions/createCaseFromPaperAction.test.ts b/web-client/src/presenter/actions/createCaseFromPaperAction.test.ts index 10903a95fb2..122817ccdb4 100644 --- a/web-client/src/presenter/actions/createCaseFromPaperAction.test.ts +++ b/web-client/src/presenter/actions/createCaseFromPaperAction.test.ts @@ -48,9 +48,6 @@ describe('createCaseFromPaperAction', () => { requestForPlaceOfTrialFileId: '123', stinFileId: '123', }); - applicationContext.getCurrentUser.mockReturnValue({ - email: 'petitioner1@example.com', - }); }); it('should generate document ids for files selected, then call createCaseFromPaperInteractor with the petition metadata and ids and call the success path when finished', async () => { diff --git a/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.test.ts b/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.test.ts index fc37bbde565..5385c5b250b 100644 --- a/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.test.ts +++ b/web-client/src/presenter/actions/getCompletedMessagesForSectionAction.test.ts @@ -48,7 +48,6 @@ describe('getCompletedMessagesForSectionAction', () => { applicationContext.getUseCases().getCompletedMessagesForSectionInteractor .mock.calls[0][1], ).toEqual({ section: DOCKET_SECTION }); - expect(applicationContext.getCurrentUser).not.toHaveBeenCalled(); }); it("retrieves completed messages for the current user's section when state.messageBoxToDisplay.section is undefined", async () => { diff --git a/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.test.ts b/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.test.ts index c02297d0953..f06815db9ed 100644 --- a/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.test.ts +++ b/web-client/src/presenter/actions/getDocumentQCInboxForSectionAction.test.ts @@ -10,9 +10,6 @@ describe('getDocumentQCInboxForSectionAction', () => { const { CHIEF_JUDGE } = applicationContext.getConstants(); beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - section: 'judgy section', - }); applicationContext .getUseCases() .getDocumentQCInboxForSectionInteractor.mockReturnValue(mockWorkItems); diff --git a/web-client/src/presenter/actions/getUsersInSectionAction.test.ts b/web-client/src/presenter/actions/getUsersInSectionAction.test.ts index e35612cef41..8beeb0613d2 100644 --- a/web-client/src/presenter/actions/getUsersInSectionAction.test.ts +++ b/web-client/src/presenter/actions/getUsersInSectionAction.test.ts @@ -53,9 +53,6 @@ describe('getUsersInSectionAction', () => { it("should retrieve all the users in the current user's section when a section is not provided", async () => { const mockSection = 'Test User Section'; - applicationContext.getCurrentUser.mockReturnValue({ - section: mockSection, - }); applicationContext .getUseCases() .getUsersInSectionInteractor.mockReturnValue([]); diff --git a/web-client/src/presenter/actions/setDefaultGenerationTypeAction.test.ts b/web-client/src/presenter/actions/setDefaultGenerationTypeAction.test.ts index af9de48845f..2a7285d3c48 100644 --- a/web-client/src/presenter/actions/setDefaultGenerationTypeAction.test.ts +++ b/web-client/src/presenter/actions/setDefaultGenerationTypeAction.test.ts @@ -11,8 +11,6 @@ import { setDefaultGenerationTypeAction } from './setDefaultGenerationTypeAction describe('setDefaultGenerationTypeAction', () => { presenter.providers.applicationContext = applicationContext; - applicationContext.getCurrentUser.mockReturnValue(privatePractitionerUser); - it('should set the generation type to auto when the changed event code is EA', async () => { const { state } = await runAction(setDefaultGenerationTypeAction, { modules: { presenter }, diff --git a/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.ts b/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.ts index 5ee1a32698d..9608dbfc24a 100644 --- a/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.ts +++ b/web-client/src/presenter/computeds/AdvancedSearch/advancedSearchHelper.test.ts @@ -34,9 +34,6 @@ describe('advancedSearchHelper', () => { MAX_SEARCH_RESULTS: maxSearchResultsOverride, }; }, - getCurrentUser: () => { - return globalUser; - }, }, ); diff --git a/web-client/src/presenter/computeds/AdvancedSearch/practitionerSearchHelper.test.ts b/web-client/src/presenter/computeds/AdvancedSearch/practitionerSearchHelper.test.ts index 7631994e3c0..a6db9057d49 100644 --- a/web-client/src/presenter/computeds/AdvancedSearch/practitionerSearchHelper.test.ts +++ b/web-client/src/presenter/computeds/AdvancedSearch/practitionerSearchHelper.test.ts @@ -26,9 +26,6 @@ describe('practitionerSearchHelper', () => { PRACTITIONER_SEARCH_PAGE_SIZE: pageSizeOverride, }; }, - getCurrentUser: () => { - return globalUser; - }, }, ); @@ -85,9 +82,6 @@ describe('practitionerSearchHelper', () => { PRACTITIONER_SEARCH_PAGE_SIZE: pageSizeOverride, }; }, - getCurrentUser: () => { - return globalUser; - }, isPublicUser: () => true, }, ); diff --git a/web-client/src/presenter/computeds/caseDetailPractitionerSearchHelper.test.ts b/web-client/src/presenter/computeds/caseDetailPractitionerSearchHelper.test.ts index 7ba0ecfc5e8..fbe04d5f5a6 100644 --- a/web-client/src/presenter/computeds/caseDetailPractitionerSearchHelper.test.ts +++ b/web-client/src/presenter/computeds/caseDetailPractitionerSearchHelper.test.ts @@ -9,16 +9,10 @@ const caseDetailPractitionerSearchHelper = withAppContextDecorator( caseDetailPractitionerSearchHelperComputed, { ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, }, ); -let globalUser; - const getBaseState = user => { - globalUser = user; return { permissions: getUserPermissions(user), }; diff --git a/web-client/src/presenter/computeds/caseInventoryReportHelper.test.ts b/web-client/src/presenter/computeds/caseInventoryReportHelper.test.ts index 443bbdda81d..6eb10bf14a5 100644 --- a/web-client/src/presenter/computeds/caseInventoryReportHelper.test.ts +++ b/web-client/src/presenter/computeds/caseInventoryReportHelper.test.ts @@ -3,7 +3,6 @@ import { CHIEF_JUDGE, CLOSED_CASE_STATUSES, DOCKET_NUMBER_SUFFIXES, - ROLES, } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { caseInventoryReportHelper as caseInventoryReportHelperComputed } from './caseInventoryReportHelper'; @@ -26,11 +25,6 @@ describe('caseInventoryReportHelper', () => { }, ); - applicationContext.getCurrentUser = () => ({ - role: ROLES.docketClerk, - userId: '5d66d122-8417-427b-9048-c1ba8ab1ea68', - }); - it('should return all judges from state along with Chief Judge sorted alphabetically', () => { const result = runCompute(caseInventoryReportHelper, { state: { diff --git a/web-client/src/presenter/computeds/documentViewerHelper.showButtons.test.ts b/web-client/src/presenter/computeds/documentViewerHelper.showButtons.test.ts index 9b9cc03316e..44127801c2e 100644 --- a/web-client/src/presenter/computeds/documentViewerHelper.showButtons.test.ts +++ b/web-client/src/presenter/computeds/documentViewerHelper.showButtons.test.ts @@ -40,12 +40,6 @@ describe('documentViewerHelper', () => { }; }; - beforeAll(() => { - applicationContext.getCurrentUser = jest - .fn() - .mockReturnValue(docketClerkUser); - }); - describe('showCompleteQcButton', () => { const showCompleteQcButtonTests = [ { diff --git a/web-client/src/presenter/computeds/fileDocumentHelper.test.ts b/web-client/src/presenter/computeds/fileDocumentHelper.test.ts index fd101749915..21e5b6333d5 100644 --- a/web-client/src/presenter/computeds/fileDocumentHelper.test.ts +++ b/web-client/src/presenter/computeds/fileDocumentHelper.test.ts @@ -24,8 +24,6 @@ describe('fileDocumentHelper', () => { validationErrors: {}, }; - //applicationContext.getCurrentUser.mockReturnValue(docketClerkUser); - const fileDocumentHelper = withAppContextDecorator( fileDocumentHelperComputed, applicationContext, diff --git a/web-client/src/presenter/computeds/formattedCaseDetail.formattedClosedCases.test.ts b/web-client/src/presenter/computeds/formattedCaseDetail.formattedClosedCases.test.ts index 9ea3470c8e4..f41a779e01a 100644 --- a/web-client/src/presenter/computeds/formattedCaseDetail.formattedClosedCases.test.ts +++ b/web-client/src/presenter/computeds/formattedCaseDetail.formattedClosedCases.test.ts @@ -1,4 +1,3 @@ -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { formattedClosedCases as formattedClosedCasesComputed } from './formattedCaseDetail'; import { @@ -11,13 +10,7 @@ import { withAppContextDecorator } from '../../withAppContext'; describe('formattedClosedCases', () => { const formattedClosedCases = withAppContextDecorator( formattedClosedCasesComputed, - { - ...applicationContext, - getCurrentUser: () => ({ - role: ROLES.petitionsClerk, - userId: '111', - }), - }, + applicationContext, ); it('should return formatted closed cases', () => { diff --git a/web-client/src/presenter/computeds/formattedCaseDetail.formattedOpenCases.test.ts b/web-client/src/presenter/computeds/formattedCaseDetail.formattedOpenCases.test.ts index c0acbec9b49..81347a3c776 100644 --- a/web-client/src/presenter/computeds/formattedCaseDetail.formattedOpenCases.test.ts +++ b/web-client/src/presenter/computeds/formattedCaseDetail.formattedOpenCases.test.ts @@ -1,4 +1,3 @@ -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { formattedOpenCases as formattedOpenCasesComputed } from './formattedCaseDetail'; import { @@ -11,13 +10,7 @@ import { withAppContextDecorator } from '../../withAppContext'; describe('formattedOpenCases', () => { const formattedOpenCases = withAppContextDecorator( formattedOpenCasesComputed, - { - ...applicationContext, - getCurrentUser: () => ({ - role: ROLES.petitionsClerk, - userId: '111', - }), - }, + applicationContext, ); it('should return formatted open cases', () => { diff --git a/web-client/src/presenter/computeds/formattedDashboardTrialSessions.test.ts b/web-client/src/presenter/computeds/formattedDashboardTrialSessions.test.ts index dcd3adc1dd1..3ae829fa2b6 100644 --- a/web-client/src/presenter/computeds/formattedDashboardTrialSessions.test.ts +++ b/web-client/src/presenter/computeds/formattedDashboardTrialSessions.test.ts @@ -69,9 +69,6 @@ describe('formattedDashboardTrialSessions', () => { }); it('returns the expected recent and upcoming sessions', () => { - applicationContext.getCurrentUser = () => ({ - userId: '6', - }); const result = runCompute(formattedDashboardTrialSessions, { state: { trialSessions: TRIAL_SESSIONS_LIST, @@ -82,10 +79,6 @@ describe('formattedDashboardTrialSessions', () => { }); it('returns only open trial sessions', () => { - applicationContext.getCurrentUser = () => ({ - userId: '6', - }); - const trialSessions = [...TRIAL_SESSIONS_LIST]; trialSessions.forEach(session => { session.isCalendared = false; diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts index 1e206f3f3a7..93b4509897f 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts @@ -9,7 +9,6 @@ import { applicationContextForClient as applicationContext } from '@web-client/t import { colvinsChambersUser, docketClerk1User, - judgeUser, } from '../../../../shared/src/test/mockUsers'; import { formattedTrialSessionDetails as formattedTrialSessionDetailsComputed } from './formattedTrialSessionDetails'; import { omit } from 'lodash'; @@ -279,8 +278,6 @@ describe('formattedTrialSessionDetails', () => { startDate: FUTURE_DATE, }; - applicationContext.getCurrentUser.mockReturnValue(judgeUser); - const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, diff --git a/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts b/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts index a7d695192aa..e409dc5f1c2 100644 --- a/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts +++ b/web-client/src/presenter/computeds/formattedWorkQueue.filterWorkItems.test.ts @@ -107,11 +107,6 @@ describe('filterWorkItems', () => { let workQueueOutbox; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: ROLES.docketClerk, - userId: '7f87f5d1-dfce-4515-a1e4-5231ceac61bb', - }); - workItemPetitionsMyDocumentQCInbox = generateWorkItem({ assigneeId: petitionsClerk1.userId, docketNumber: '100-05', diff --git a/web-client/src/presenter/computeds/headerHelper.test.ts b/web-client/src/presenter/computeds/headerHelper.test.ts index c154a31d5ba..b544dbf6a3e 100644 --- a/web-client/src/presenter/computeds/headerHelper.test.ts +++ b/web-client/src/presenter/computeds/headerHelper.test.ts @@ -12,7 +12,6 @@ const headerHelper = withAppContextDecorator( ); const getBaseState = user => { - applicationContext.getCurrentUser = () => user; applicationContext.getPublicSiteUrl = () => 'localhost:5678/'; return { notifications: { diff --git a/web-client/src/presenter/computeds/partiesInformationHelper.formatCounsel.test.ts b/web-client/src/presenter/computeds/partiesInformationHelper.formatCounsel.test.ts index 47d5a380777..a8e7a05e3ab 100644 --- a/web-client/src/presenter/computeds/partiesInformationHelper.formatCounsel.test.ts +++ b/web-client/src/presenter/computeds/partiesInformationHelper.formatCounsel.test.ts @@ -1,5 +1,4 @@ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; -import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { formatCounsel } from './partiesInformationHelper'; describe('partiesInformationHelper', () => { @@ -7,10 +6,7 @@ describe('partiesInformationHelper', () => { let mockIrsPractitioner; - let mockUser; - beforeEach(() => { - mockUser = {}; mockIrsPractitioner = { barNumber: 'RT1111', email: mockEmail, @@ -18,7 +14,6 @@ describe('partiesInformationHelper', () => { role: ROLES.irsPractitioner, userId: 'c6df4afc-286b-4979-92e2-b788e49dc51d', }; - applicationContext.getCurrentUser.mockImplementation(() => mockUser); }); describe('formatCounsel', () => { diff --git a/web-client/src/presenter/computeds/reportMenuHelper.test.ts b/web-client/src/presenter/computeds/reportMenuHelper.test.ts index 3638d2346a3..ee390ee2bf3 100644 --- a/web-client/src/presenter/computeds/reportMenuHelper.test.ts +++ b/web-client/src/presenter/computeds/reportMenuHelper.test.ts @@ -16,7 +16,6 @@ describe('reportMenuHelper', () => { ); const getBaseState = user => { - applicationContext.getCurrentUser.mockReturnValue(user); return { currentPage: 'CaseDetailInternal', permissions: getUserPermissions(user), diff --git a/web-client/src/presenter/computeds/scanBatchPreviewerHelper.test.ts b/web-client/src/presenter/computeds/scanBatchPreviewerHelper.test.ts index b0b4884f415..53c215117dc 100644 --- a/web-client/src/presenter/computeds/scanBatchPreviewerHelper.test.ts +++ b/web-client/src/presenter/computeds/scanBatchPreviewerHelper.test.ts @@ -17,10 +17,6 @@ describe('scanBatchPreviewerHelper', () => { applicationContext, ); - applicationContext.getCurrentUser = () => ({ - role: applicationContext.getConstants().ROLES.privatePractitioner, - }); - beforeEach(() => { state.form = {}; }); diff --git a/web-client/src/presenter/computeds/startCaseHelper.test.ts b/web-client/src/presenter/computeds/startCaseHelper.test.ts index 59c7c8482fa..0b38f199b91 100644 --- a/web-client/src/presenter/computeds/startCaseHelper.test.ts +++ b/web-client/src/presenter/computeds/startCaseHelper.test.ts @@ -1,9 +1,7 @@ import { CASE_TYPES_MAP, FILING_TYPES, - ROLES, } from '../../../../shared/src/business/entities/EntityConstants'; -import { RawUser } from '@shared/business/entities/User'; import { applicationContext } from '../../applicationContext'; import { irsPractitionerUser, @@ -22,13 +20,6 @@ describe('startCaseHelper', () => { applicationContext, ); - beforeAll(() => { - applicationContext.getCurrentUser = () => - ({ - role: ROLES.petitioner, - }) as RawUser; - }); - it('sets showPetitionFileValid false when the petition file is not added to the petition', () => { const result = runCompute(startCaseHelper, { state: { diff --git a/web-client/src/presenter/computeds/viewCounselHelper.test.ts b/web-client/src/presenter/computeds/viewCounselHelper.test.ts index e684d1b4039..1698a962678 100644 --- a/web-client/src/presenter/computeds/viewCounselHelper.test.ts +++ b/web-client/src/presenter/computeds/viewCounselHelper.test.ts @@ -3,14 +3,10 @@ import { runCompute } from '@web-client/presenter/test.cerebral'; import { viewCounselHelper as viewCounselHelperComputed } from './viewCounselHelper'; import { withAppContextDecorator } from '../../../src/withAppContext'; -let globalUser; - -const viewCounselHelper = withAppContextDecorator(viewCounselHelperComputed, { - ...applicationContext, - getCurrentUser: () => { - return globalUser; - }, -}); +const viewCounselHelper = withAppContextDecorator( + viewCounselHelperComputed, + applicationContext, +); describe('viewCounselHelper', () => { it('returns the expected state when selected work items are set', () => { diff --git a/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts b/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts index b90dd0a4361..3b13cd16004 100644 --- a/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts +++ b/web-client/src/presenter/sequences/chooseWorkQueueSequence.test.ts @@ -5,14 +5,9 @@ import { docketClerk1User } from '@shared/test/mockUsers'; import { presenter } from '../presenter-mock'; describe('chooseWorkQueueSequence', () => { - const { PETITIONS_SECTION } = applicationContext.getConstants(); let cerebralTest; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - role: 'petitionsclerk', - section: PETITIONS_SECTION, - }); applicationContext .getUseCases() .getDocumentQCInboxForSectionInteractor.mockReturnValue([ diff --git a/web-client/src/presenter/sequences/gotoPrintablePendingReportForCaseSequence.test.ts b/web-client/src/presenter/sequences/gotoPrintablePendingReportForCaseSequence.test.ts index 81b1b51969a..7da1ae4d8a6 100644 --- a/web-client/src/presenter/sequences/gotoPrintablePendingReportForCaseSequence.test.ts +++ b/web-client/src/presenter/sequences/gotoPrintablePendingReportForCaseSequence.test.ts @@ -3,14 +3,9 @@ import { applicationContextForClient as applicationContext } from '@web-client/t import { gotoPrintablePendingReportForCaseSequence } from '../sequences/gotoPrintablePendingReportForCaseSequence'; import { presenter } from '../presenter-mock'; -const { CHAMBERS_SECTION } = applicationContext.getConstants(); - describe('gotoPrintablePendingReportForCaseSequence', () => { let cerebralTest; beforeAll(() => { - applicationContext.getCurrentUser.mockReturnValue({ - section: CHAMBERS_SECTION, - }); applicationContext .getUseCases() .generatePrintablePendingReportInteractor.mockReturnValue( diff --git a/web-client/src/test/createClientTestApplicationContext.ts b/web-client/src/test/createClientTestApplicationContext.ts index 1854e0b2f32..dfb4ee53731 100644 --- a/web-client/src/test/createClientTestApplicationContext.ts +++ b/web-client/src/test/createClientTestApplicationContext.ts @@ -25,7 +25,6 @@ import { getPublicSiteUrl, getUniqueId, } from '@shared/sharedAppContext'; -import { ROLES } from '@shared/business/entities/EntityConstants'; import { User } from '@shared/business/entities/User'; import { abbreviateState } from '@shared/business/utilities/abbreviateState'; import { aggregatePartiesForService } from '@shared/business/utilities/aggregatePartiesForService'; @@ -547,13 +546,6 @@ const createTestApplicationContext = () => { ERROR_MAP_429, }; }), - getCurrentUser: jest.fn().mockImplementation(() => { - return new User({ - name: 'richard', - role: ROLES.petitioner, - userId: 'a805d1ab-18d0-43ec-bafb-654e83405416', - }); - }), getCurrentUserPermissions: jest.fn(), getDispatchers: jest.fn().mockReturnValue({ sendBulkTemplatedEmail: jest.fn(), From deeda94fdee6efa5240c906d7e1e69cbe216e678 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 23 Jul 2024 15:06:57 -0700 Subject: [PATCH 370/523] 10417: Remove todos related to type changes. These are legitamte type errors that should be fixed in other contexts. --- docs/remove-get-current-user.md | 3 +++ .../addDraftStampOrderDocketEntryInteractor.test.ts | 3 +-- .../generateStampedCoversheetInteractor.test.ts | 1 - .../createCourtIssuedOrderPdfFromHtmlInteractor.ts | 4 ---- .../associatePrivatePractitionerWithCaseInteractor.ts | 2 -- .../business/useCases/messages/completeMessageInteractor.ts | 2 -- .../actions/completeWorkItemForDocumentSigningAction.ts | 1 - 7 files changed, 4 insertions(+), 12 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index dbd5a03a259..b10741d88f5 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -9,6 +9,9 @@ - check instances of `handleLockError` (or `OnLockError`) - Look at all new Case and new DocketEntry +# Problems we see with the app that are unrelated to changes +- generateStampedCoversheetInteractor does not have any authorization + # Web-Client Steps to transition getCurrentUser() in web-client 1. Find applicationContext.getCurrentUser() and replace with get(state.user); diff --git a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts index 8ddf5d1080a..d88a90af791 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts @@ -82,8 +82,7 @@ describe('addDraftStampOrderDocketEntryInteractor', () => { }); }); - //TODO 10417: authorizedUser never has judgeFullName property - is this test still relevant? - it("should set the filedBy to the current user's name if there is no judge full name on the user", async () => { + it("should set the filedBy to the current user's name", async () => { await addDraftStampOrderDocketEntryInteractor( applicationContext, args, diff --git a/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.test.ts b/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.test.ts index f69e3bc4129..8ada6af2192 100644 --- a/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.test.ts +++ b/web-api/src/business/useCaseHelper/stampDisposition/generateStampedCoversheetInteractor.test.ts @@ -4,7 +4,6 @@ import { applicationContext } from '../../../../../shared/src/business/test/crea import { generateStampedCoversheetInteractor } from './generateStampedCoversheetInteractor'; import { mockPetitionerUser } from '@shared/test/mockAuthUsers'; -// TODO 10417: these tests pass irrespective of which mock user (or even no user) describe('generateStampedCoversheetInteractor', () => { const mockDocketEntryId = MOCK_CASE.docketEntries[0].docketEntryId; diff --git a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts index 664d6890c4b..f9ddb08c21d 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts @@ -67,8 +67,6 @@ export const createCourtIssuedOrderPdfFromHtmlInteractor = async ( addedDocketNumbers, caseCaptionExtension, caseTitle, - // TODO 10417: docketNumberwithSuffix should be properly typed - // @ts-ignore docketNumberWithSuffix, nameOfClerk, orderContent: contentHtml, @@ -79,8 +77,6 @@ export const createCourtIssuedOrderPdfFromHtmlInteractor = async ( return await applicationContext.getUseCaseHelpers().saveFileAndGenerateUrl({ applicationContext, - // TODO 10417: file should be properly typed - // @ts-ignore file: orderPdf, useTempBucket: true, }); diff --git a/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts b/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts index 0ee9e45767f..401a1a4e665 100644 --- a/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts +++ b/web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts @@ -39,7 +39,6 @@ export const associatePrivatePractitionerWithCase = async ( throw new UnauthorizedError('Unauthorized'); } - // TODO 10417: type for practitioner lookup is wrong here const user = await applicationContext .getPersistenceGateway() .getUserById({ applicationContext, userId }); @@ -50,7 +49,6 @@ export const associatePrivatePractitionerWithCase = async ( docketNumber, representing, serviceIndicator, - //@ts-ignore 10417: fix typing in future update user, }); }; diff --git a/web-api/src/business/useCases/messages/completeMessageInteractor.ts b/web-api/src/business/useCases/messages/completeMessageInteractor.ts index 9265133633b..39f1e73f990 100644 --- a/web-api/src/business/useCases/messages/completeMessageInteractor.ts +++ b/web-api/src/business/useCases/messages/completeMessageInteractor.ts @@ -47,8 +47,6 @@ export const completeMessageInteractor = async ( applicationContext, }).validate(); - // TODO 10417: fix typing for call to markAsCompleted - // @ts-ignore fix typing for call to markAsCompleted updatedMessage.markAsCompleted({ message: message.messageBody, user }); const validatedRawMessage = updatedMessage.validate().toRawObject(); diff --git a/web-client/src/presenter/actions/completeWorkItemForDocumentSigningAction.ts b/web-client/src/presenter/actions/completeWorkItemForDocumentSigningAction.ts index 43577cf5661..ed8bb25d6e4 100644 --- a/web-client/src/presenter/actions/completeWorkItemForDocumentSigningAction.ts +++ b/web-client/src/presenter/actions/completeWorkItemForDocumentSigningAction.ts @@ -22,7 +22,6 @@ export const completeWorkItemForDocumentSigningAction = async ({ await applicationContext .getUseCases() - // TODO 10417 I removed userId from what was passed in here because it doesn't appear to be used, but want to confirm. .completeWorkItemInteractor(applicationContext, { workItemId: workItemIdToClose, }); From 3bd4b2185e51e222ad88d6dbd7d747b94a238263 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 23 Jul 2024 15:39:44 -0700 Subject: [PATCH 371/523] 10417: rm getCurrentUser from tests --- shared/src/business/test/createTestApplicationContext.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/shared/src/business/test/createTestApplicationContext.ts b/shared/src/business/test/createTestApplicationContext.ts index 7e15fa12315..13b94ab9837 100644 --- a/shared/src/business/test/createTestApplicationContext.ts +++ b/shared/src/business/test/createTestApplicationContext.ts @@ -623,7 +623,6 @@ export const createTestApplicationContext = () => { ERROR_MAP_429, }; }), - getCurrentUserPermissions: jest.fn(), getDispatchers: jest.fn().mockReturnValue({ sendBulkTemplatedEmail: jest.fn(), sendNotificationOfSealing: jest.fn(), From 44a4e3b05fdd5abc610bd681b65324966511dc73 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 24 Jul 2024 08:25:11 -0500 Subject: [PATCH 372/523] 10417 fix removeCounselFromRemovedPractitioner tests --- .../caseAssociation/removeCounselFromRemovedPetitioner.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts b/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts index 8db63fd67aa..87355e41d0b 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/removeCounselFromRemovedPetitioner.test.ts @@ -141,11 +141,12 @@ describe('removeCounselFromRemovedPetitioner', () => { }, ], }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); const updatedCase = await removeCounselFromRemovedPetitioner({ applicationContext, + authorizedUser: mockPetitionsClerkUser, caseEntity, petitionerContactId: mockContactSecondaryId, }); From 7753b2953d63db96ada615a65d775c8c17aae7d0 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 24 Jul 2024 08:39:52 -0500 Subject: [PATCH 373/523] 10417 pass in user for lambda tests --- web-api/src/lambdas/v1/getCaseLambda.test.ts | 26 +++++++++--- .../v1/getDocumentDownloadUrlLambda.test.ts | 28 +++++++++++-- web-api/src/lambdas/v2/getCaseLambda.test.ts | 26 +++++++++--- .../v2/getDocumentDownloadUrlLambda.test.ts | 41 ++++++++++++++++--- 4 files changed, 101 insertions(+), 20 deletions(-) diff --git a/web-api/src/lambdas/v1/getCaseLambda.test.ts b/web-api/src/lambdas/v1/getCaseLambda.test.ts index 4613e9d6dc5..f4da9333ab9 100644 --- a/web-api/src/lambdas/v1/getCaseLambda.test.ts +++ b/web-api/src/lambdas/v1/getCaseLambda.test.ts @@ -1,6 +1,10 @@ import { MOCK_CASE_WITH_TRIAL_SESSION } from '../../../../shared/src/test/mockCase'; import { getCaseLambda } from './getCaseLambda'; import { createTestApplicationContext as mockCreateTestApplicationContext } from '@shared/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { getCaseInteractor as mockGetCaseInteractor } from '@shared/business/useCases/getCaseInteractor'; jest.mock('@web-api/applicationContext', () => { @@ -108,7 +112,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser, {}); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -125,7 +129,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser, {}); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); @@ -148,7 +152,11 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda( + REQUEST_EVENT, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -165,7 +173,11 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: true, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda( + REQUEST_EVENT, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe(500); expect(response.headers['Content-Type']).toBe('application/json'); @@ -185,7 +197,11 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda( + REQUEST_EVENT, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); diff --git a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts index 7be4d6c1f22..da9e4c27f14 100644 --- a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts +++ b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts @@ -2,6 +2,10 @@ import { CASE_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; import { MOCK_PETITION } from '@shared/test/mockDocketEntry'; import { getDocumentDownloadUrlLambda } from './getDocumentDownloadUrlLambda'; import { createTestApplicationContext as mockCreateTestApplicationContext } from '@shared/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { getDownloadPolicyUrlInteractor as mockGetDownloadPolicyUrlInteractor } from '@web-api/business/useCases/document/getDownloadPolicyUrlInteractor'; jest.mock('@web-api/applicationContext', () => { @@ -107,7 +111,11 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: false, }); - const response = await getDocumentDownloadUrlLambda(request, {}); + const response = await getDocumentDownloadUrlLambda( + request, + mockPetitionerUser, + {}, + ); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -146,7 +154,11 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: false, }); - const response = await getDocumentDownloadUrlLambda(request, {}); + const response = await getDocumentDownloadUrlLambda( + request, + mockPetitionerUser, + {}, + ); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -170,7 +182,11 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: true, }); - const response = await getDocumentDownloadUrlLambda(request, {}); + const response = await getDocumentDownloadUrlLambda( + request, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe(500); expect(response.headers['Content-Type']).toBe('application/json'); @@ -210,7 +226,11 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: false, }); - const response = await getDocumentDownloadUrlLambda(request, {}); + const response = await getDocumentDownloadUrlLambda( + request, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); diff --git a/web-api/src/lambdas/v2/getCaseLambda.test.ts b/web-api/src/lambdas/v2/getCaseLambda.test.ts index 310f6795c87..3ecd2b5def0 100644 --- a/web-api/src/lambdas/v2/getCaseLambda.test.ts +++ b/web-api/src/lambdas/v2/getCaseLambda.test.ts @@ -3,6 +3,10 @@ import { MOCK_COMPLEX_CASE } from '../../../../shared/src/test/mockComplexCase'; import { MOCK_PRACTITIONER } from '../../../../shared/src/test/mockUsers'; import { getCaseLambda } from './getCaseLambda'; import { createTestApplicationContext as mockCreateTestApplicationContext } from '@shared/business/test/createTestApplicationContext'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { getCaseInteractor as mockGetCaseInteractor } from '@shared/business/useCases/getCaseInteractor'; jest.mock('@web-api/applicationContext', () => { @@ -84,7 +88,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser, {}); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -101,7 +105,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser, {}); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); @@ -124,7 +128,11 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda( + REQUEST_EVENT, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -141,7 +149,11 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: true, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda( + REQUEST_EVENT, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe(500); expect(response.headers['Content-Type']).toBe('application/json'); @@ -185,7 +197,11 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, {}); + const response = await getCaseLambda( + REQUEST_EVENT, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); diff --git a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts index bea02cc14a7..f297c91097d 100644 --- a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts +++ b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts @@ -1,7 +1,11 @@ -import { CASE_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; +import { + CASE_STATUS_TYPES, + Role, +} from '@shared/business/entities/EntityConstants'; import { MOCK_PETITION } from '@shared/test/mockDocketEntry'; import { getDocumentDownloadUrlLambda } from './getDocumentDownloadUrlLambda'; import { createTestApplicationContext as mockCreateTestApplicationContext } from '@shared/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { getDownloadPolicyUrlInteractor as mockGetDownloadPolicyUrlInteractor } from '@web-api/business/useCases/document/getDownloadPolicyUrlInteractor'; jest.mock('@web-api/applicationContext', () => { @@ -86,7 +90,16 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: false, }); - const response = await getDocumentDownloadUrlLambda(REQUEST_EVENT, {}); + const response = await getDocumentDownloadUrlLambda( + REQUEST_EVENT, + { + email: 'test@e.mail', + name: '', + role: 'roleWithNoPermissions' as Role, + userId: '612e3eb3-332c-4f1f-aaff-44ac8eae9a5f', + }, + {}, + ); expect(response.statusCode).toBe(403); expect(response.headers['Content-Type']).toBe('application/json'); @@ -107,7 +120,11 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: false, }); - const response = await getDocumentDownloadUrlLambda(request, {}); + const response = await getDocumentDownloadUrlLambda( + request, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -146,7 +163,11 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: false, }); - const response = await getDocumentDownloadUrlLambda(request, {}); + const response = await getDocumentDownloadUrlLambda( + request, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -170,7 +191,11 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: true, }); - const response = await getDocumentDownloadUrlLambda(request, {}); + const response = await getDocumentDownloadUrlLambda( + request, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe(500); expect(response.headers['Content-Type']).toBe('application/json'); @@ -210,7 +235,11 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: false, }); - const response = await getDocumentDownloadUrlLambda(request, {}); + const response = await getDocumentDownloadUrlLambda( + request, + mockDocketClerkUser, + {}, + ); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); From b7cd8b19ab870a30814688ac4d7f3e03851f1ed4 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 24 Jul 2024 10:06:11 -0500 Subject: [PATCH 374/523] 10417 fix locking tests --- .../useCaseHelper/acquireLock.test.ts | 53 ++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/web-api/src/business/useCaseHelper/acquireLock.test.ts b/web-api/src/business/useCaseHelper/acquireLock.test.ts index 953754dc73a..008d306ddb4 100644 --- a/web-api/src/business/useCaseHelper/acquireLock.test.ts +++ b/web-api/src/business/useCaseHelper/acquireLock.test.ts @@ -3,6 +3,7 @@ import { MOCK_LOCK } from '../../../../shared/src/test/mockLock'; import { ServiceUnavailableError } from '@web-api/errors/errors'; import { acquireLock, checkLock, removeLock, withLocking } from './acquireLock'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; const onLockError = new ServiceUnavailableError('The case is currently locked'); @@ -26,6 +27,7 @@ describe('acquireLock', () => { beforeEach(() => { mockCall = { applicationContext, + authorizedUser: mockDocketClerkUser, identifiers: ['case|123-45'], onLockError, retries: 0, @@ -147,6 +149,7 @@ describe('acquireLock', () => { expect(mockCallbackFunction).toHaveBeenCalledWith( applicationContext, mockCall.options, + mockDocketClerkUser, ); }); @@ -241,12 +244,20 @@ describe('withLocking', () => { it('does not throw a ServiceUnavailableError if the feature flag is false and we could not acquire the lock on the specified identifier', async () => { await expect( - func(applicationContext, { docketNumber: '123-45' }), + func( + applicationContext, + { docketNumber: '123-45' }, + mockDocketClerkUser, + ), ).resolves.not.toThrow(); expect(mockInteractor).toHaveBeenCalledTimes(1); - expect(mockInteractor).toHaveBeenCalledWith(applicationContext, { - docketNumber: '123-45', - }); + expect(mockInteractor).toHaveBeenCalledWith( + applicationContext, + { + docketNumber: '123-45', + }, + mockDocketClerkUser, + ); }); it('creates a lock for the specified entity', async () => { @@ -292,11 +303,19 @@ describe('withLocking', () => { const onLockErrorFunction = jest.fn(); func = withLocking(mockInteractor, getLockInfo, onLockErrorFunction); await expect( - func(applicationContext, { docketNumber: '123-45' }), + func( + applicationContext, + { docketNumber: '123-45' }, + mockDocketClerkUser, + ), ).rejects.toThrow(ServiceUnavailableError); - expect(onLockErrorFunction).toHaveBeenCalledWith(applicationContext, { - docketNumber: '123-45', - }); + expect(onLockErrorFunction).toHaveBeenCalledWith( + applicationContext, + { + docketNumber: '123-45', + }, + mockDocketClerkUser, + ); }); it('throws a ServiceUnavailableError if an onLockError function is provided', async () => { @@ -328,11 +347,19 @@ describe('withLocking', () => { }); it('calls the specified callback function', async () => { - await func(applicationContext, { docketNumber: '123-45' }); + await func( + applicationContext, + { docketNumber: '123-45' }, + mockDocketClerkUser, + ); expect(mockInteractor).toHaveBeenCalledTimes(1); - expect(mockInteractor).toHaveBeenCalledWith(applicationContext, { - docketNumber: '123-45', - }); + expect(mockInteractor).toHaveBeenCalledWith( + applicationContext, + { + docketNumber: '123-45', + }, + mockDocketClerkUser, + ); }); it('removes the lock for the specified identifier', async () => { @@ -406,6 +433,7 @@ describe('checkLock', () => { mockFeatureFlagValue = true; // enabled mockCall = { applicationContext, + authorizedUser: mockDocketClerkUser, identifier: 'case|123-45', }; }); @@ -475,6 +503,7 @@ describe('checkLock', () => { expect(mockCallbackFunction).toHaveBeenCalledWith( applicationContext, mockCall.options, + mockDocketClerkUser, ); }); }); From acd6bed99abc62cee6bb3f52824a5684159d33a0 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 24 Jul 2024 10:10:04 -0500 Subject: [PATCH 375/523] 10417 fix workerRouter tests --- web-api/src/gateways/worker/workerRouter.test.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web-api/src/gateways/worker/workerRouter.test.ts b/web-api/src/gateways/worker/workerRouter.test.ts index c15ac250646..29f5b13727a 100644 --- a/web-api/src/gateways/worker/workerRouter.test.ts +++ b/web-api/src/gateways/worker/workerRouter.test.ts @@ -22,7 +22,11 @@ describe('workerRouter', () => { expect( applicationContext.getUseCases().updateAssociatedCaseWorker, - ).toHaveBeenCalledWith(applicationContext, mockMessage.payload); + ).toHaveBeenCalledWith( + applicationContext, + mockMessage.payload, + mockMessage.authorizedUser, + ); }); it('should make a call to queue a user`s associated cases for update when the message type is QUEUE_UPDATE_ASSOCIATED_CASES', async () => { @@ -40,7 +44,11 @@ describe('workerRouter', () => { expect( applicationContext.getUseCases().queueUpdateAssociatedCasesWorker, - ).toHaveBeenCalledWith(applicationContext, mockMessage.payload); + ).toHaveBeenCalledWith( + applicationContext, + mockMessage.payload, + mockMessage.authorizedUser, + ); }); it('should throw an error when the message type provided was not recognized by the router', async () => { From dcba91b48e272aeef9b31914960c30f5030e3860 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 24 Jul 2024 10:14:39 -0700 Subject: [PATCH 376/523] 10417: rm authorizedUser from genericHandler. Do direct import of interactors --- .../batchDownloadTrialSessionInteractor.ts | 12 ++++--- .../src/lambdas/auth/forgotPasswordLambda.ts | 9 +++-- .../generateEntryOfAppearancePdfLambda.ts | 27 ++++++-------- .../getCaseDeadlinesForCaseLambda.ts | 9 +++-- .../caseDeadline/getCaseDeadlinesLambda.ts | 22 +++++------- .../caseDeadline/updateCaseDeadlineLambda.ts | 5 +-- .../lambdas/caseNote/deleteCaseNoteLambda.ts | 3 +- .../caseNote/deleteUserCaseNoteLambda.ts | 3 +- .../caseNote/getUserCaseNoteForCasesLambda.ts | 17 +++++---- .../lambdas/caseNote/getUserCaseNoteLambda.ts | 3 +- .../lambdas/caseNote/saveCaseNoteLambda.ts | 30 +++++++--------- .../caseNote/updateUserCaseNoteLambda.ts | 3 +- .../updateCaseWorksheetLambda.ts | 13 ++++--- .../cases/addConsolidatedCaseLambda.ts | 24 ++++++------- .../cases/addDeficiencyStatisticLambda.ts | 24 ++++++------- .../cases/addPetitionerToCaseLambda.ts | 24 ++++++------- .../lambdas/cases/blockCaseFromTrialLambda.ts | 30 +++++++--------- .../lambdas/cases/caseAdvancedSearchLambda.ts | 22 +++++------- .../cases/checkForReadyForTrialCasesLambda.ts | 19 +++------- .../cases/createCaseFromPaperLambda.ts | 22 +++++------- web-api/src/lambdas/cases/createCaseLambda.ts | 3 +- .../cases/deleteDeficiencyStatisticLambda.ts | 17 +++++---- .../fileAndServeCourtIssuedDocumentLambda.ts | 22 +++++------- .../cases/generateDocketRecordPdfLambda.ts | 17 +++++---- .../generatePractitionerCaseListPdfLambda.ts | 1 - .../src/lambdas/cases/getCaseExistsLambda.ts | 9 +++-- web-api/src/lambdas/cases/getCaseLambda.ts | 19 +++++----- .../lambdas/cases/getCasesForUserLambda.ts | 13 ++----- .../src/lambdas/cases/prioritizeCaseLambda.ts | 24 ++++++------- ...rivatePractitionerCaseAssociationLambda.ts | 24 ++++++------- ...ractitionerPendingCaseAssociationLambda.ts | 26 ++++++-------- .../cases/removeCasePendingItemLambda.ts | 22 +++++------- .../cases/removeConsolidatedCasesLambda.ts | 19 +++++----- .../removePetitionerAndUpdateCaptionLambda.ts | 24 ++++++------- .../cases/saveCaseDetailInternalEditLambda.ts | 26 ++++++-------- .../cases/sealCaseContactAddressLambda.ts | 22 +++++------- web-api/src/lambdas/cases/sealCaseLambda.ts | 22 +++++------- .../sendMaintenanceNotificationsLambda.ts | 9 +++-- .../src/lambdas/cases/serveCaseToIrsLambda.ts | 3 +- .../cases/serveCourtIssuedDocumentLambda.ts | 17 +++++---- .../cases/unblockCaseFromTrialLambda.ts | 22 +++++------- .../lambdas/cases/unprioritizeCaseLambda.ts | 22 +++++------- web-api/src/lambdas/cases/unsealCaseLambda.ts | 22 +++++------- .../lambdas/cases/updateCaseContextLambda.ts | 24 ++++++------- .../lambdas/cases/updateCaseDetailsLambda.ts | 24 ++++++------- .../cases/updateCaseTrialSortTagsLambda.ts | 22 +++++------- .../src/lambdas/cases/updateContactLambda.ts | 22 +++++------- .../cases/updateCounselOnCaseLambda.ts | 24 ++++++------- .../cases/updateDeficiencyStatisticLambda.ts | 19 +++++----- .../cases/updateOtherStatisticsLambda.ts | 19 +++++----- .../updatePetitionerInformationLambda.ts | 24 ++++++------- .../cases/updateQcCompleteForTrialLambda.ts | 24 ++++++------- .../cases/verifyPendingCaseForUserLambda.ts | 9 +++-- .../archiveCorrespondenceDocumentLambda.ts | 17 +++++---- .../fileCorrespondenceDocumentLambda.ts | 17 +++++---- .../updateCorrespondenceDocumentLambda.ts | 17 +++++---- .../appendAmendedPetitionFormLambda.ts | 1 - ...createCourtIssuedOrderPdfFromHtmlLambda.ts | 17 +++++---- .../lambdas/documents/addCoversheetLambda.ts | 1 - .../lambdas/documents/addPaperFilingLambda.ts | 3 +- .../documents/archiveDraftDocumentLambda.ts | 18 ++++------ .../batchDownloadDocketEntriesLambda.ts | 18 ++++------ .../documents/completeDocketEntryQCLambda.ts | 18 ++++------ .../documents/downloadPolicyUrlLambda.ts | 18 ++++------ .../fileCourtIssuedDocketEntryLambda.ts | 22 +++++------- .../fileCourtIssuedOrderToCaseLambda.ts | 18 ++++------ .../fileExternalDocumentToCaseLambda.ts | 13 ++++--- .../generateDraftStampOrderLambda.ts | 1 - .../generatePrintableFilingReceiptLambda.ts | 18 ++++------ ...getDocumentContentsForDocketEntryLambda.ts | 13 ++++--- .../documents/getDocumentDownloadUrlLambda.ts | 18 ++++------ .../documents/getUploadPolicyLambda.ts | 22 +++++------- .../documents/opinionAdvancedSearchLambda.ts | 28 +++++++-------- .../documents/orderAdvancedSearchLambda.ts | 18 ++++------ .../removePdfFromDocketEntryLambda.ts | 18 ++++------ .../removeSignatureFromDocumentLambda.ts | 18 ++++------ .../documents/saveSignedDocumentLambda.ts | 34 ++++++++---------- .../documents/sealDocketEntryLambda.ts | 3 +- .../serveExternallyFiledDocumentLambda.ts | 17 +++++---- .../documents/strikeDocketEntryLambda.ts | 3 +- .../documents/unsealDocketEntryLambda.ts | 30 +++++++--------- .../updateCourtIssuedDocketEntryLambda.ts | 13 ++++--- .../updateCourtIssuedOrderToCaseLambda.ts | 19 +++++----- .../documents/updateDocketEntryMetaLambda.ts | 19 +++++----- .../lambdas/documents/validatePdfLambda.ts | 9 +++-- .../email/handleBounceNotificationsLambda.ts | 5 ++- .../featureFlag/getAllFeatureFlagsLambda.ts | 5 ++- .../health/getCachedHealthCheckLambda.ts | 5 ++- .../lambdas/health/getHealthCheckLambda.ts | 5 ++- .../health/setHealthCheckCacheLambda.ts | 5 ++- .../maintenance/getMaintenanceModeLambda.ts | 5 ++- .../associateIrsPractitionerWithCaseLambda.ts | 22 +++++------- ...ociatePrivatePractitionerWithCaseLambda.ts | 17 +++++---- .../lambdas/messages/completeMessageLambda.ts | 13 ++++--- .../lambdas/messages/createMessageLambda.ts | 3 +- .../lambdas/messages/forwardMessageLambda.ts | 11 +++--- .../getCompletedMessagesForSectionLambda.ts | 22 +++++------- .../getCompletedMessagesForUserLambda.ts | 17 +++++---- .../getInboxMessagesForSectionLambda.ts | 17 +++++---- .../messages/getInboxMessagesForUserLambda.ts | 17 +++++---- .../messages/getMessageThreadLambda.ts | 3 +- .../messages/getMessagesForCaseLambda.ts | 22 +++++------- .../getOutboxMessagesForSectionLambda.ts | 17 +++++---- .../getOutboxMessagesForUserLambda.ts | 22 +++++------- .../lambdas/notifications/connectLambda.ts | 1 - .../lambdas/notifications/disconnectLambda.ts | 9 +++-- .../deletePractitionerDocumentLambda.ts | 21 ++++++----- .../editPractitionerDocumentLambda.ts | 19 +++++----- ...etPractitionerDocumentDownloadUrlLambda.ts | 21 ++++++----- .../getPractitionerDocumentLambda.ts | 9 +++-- .../getPractitionerDocumentsLambda.ts | 22 +++++------- .../getPractitionersByNameLambda.ts | 19 +++++----- .../updatePractitionerUserLambda.ts | 28 +++++++-------- .../public-api/casePublicSearchLambda.ts | 9 +++-- .../generatePublicDocketRecordPdfLambda.ts | 17 ++++++--- .../getCaseForPublicDocketSearchLambda.ts | 9 +++-- .../public-api/getPublicCaseExistsLambda.ts | 9 +++-- .../lambdas/public-api/getPublicCaseLambda.ts | 9 +++-- .../getPublicDocumentDownloadUrlLambda.ts | 23 ++++++------ .../public-api/opinionPublicSearchLambda.ts | 11 +++--- .../public-api/orderPublicSearchLambda.ts | 9 +++-- .../public-api/todaysOpinionsLambda.ts | 5 ++- .../lambdas/public-api/todaysOrdersLambda.ts | 8 +++-- .../lambdas/reports/coldCaseReportLambda.ts | 10 ++---- .../createCsvCustomCaseReportFileLambda.ts | 13 ++++--- ...eratePrintableCaseInventoryReportLambda.ts | 1 - .../lambdas/reports/getBlockedCasesLambda.ts | 22 +++++------- .../reports/getCaseInventoryReportLambda.ts | 17 +++++---- .../reports/getCaseWorksheetsByJudgeLambda.ts | 13 ++++--- .../reports/getCasesClosedByJudgeLambda.ts | 17 +++++---- ...CountOfCaseDocumentsFiledByJudgesLambda.ts | 13 ++++--- ...ialSessionsForJudgeActivityReportLambda.ts | 17 +++++---- .../batchDownloadTrialSessionLambda.ts | 24 ++++++------- .../trialSessions/closeTrialSessionLambda.ts | 3 +- .../trialSessions/createTrialSessionLambda.ts | 3 +- .../trialSessions/deleteTrialSessionLambda.ts | 3 +- .../generateTrialCalendarPdfLambda.ts | 9 +++-- ...getCalendaredCasesForTrialSessionLambda.ts | 17 +++++---- .../getEligibleCasesForTrialSessionLambda.ts | 17 +++++---- ...tePrintableTrialSessionCopyReportLambda.ts | 36 +++++++++---------- .../getPaperServicePdfUrlLambda.ts | 1 - .../getTrialSessionDetailsLambda.ts | 17 +++++---- .../getTrialSessionWorkingCopyLambda.ts | 17 +++++---- .../getTrialSessionsForJudgeLambda.ts | 13 ++++--- .../trialSessions/getTrialSessionsLambda.ts | 5 ++- .../removeCaseFromTrialLambda.ts | 17 ++++++--- .../runTrialSessionPlanningReportLambda.ts | 17 +++++---- .../trialSessions/saveCalendarNoteLambda.ts | 3 +- .../serveThirtyDayNoticeLambda.ts | 19 +++++----- .../trialSessions/setForHearingLambda.ts | 3 +- ...tNoticesForCalendaredTrialSessionLambda.ts | 26 ++++++-------- .../setTrialSessionCalendarLambda.ts | 17 ++++++--- .../trialSessions/updateTrialSessionLambda.ts | 3 +- .../updateTrialSessionWorkingCopyLambda.ts | 17 +++++---- .../users/checkEmailAvailabilityLambda.ts | 17 +++++---- .../lambdas/users/getAllUsersByRoleLambda.ts | 1 - .../lambdas/users/getInternalUsersLambda.ts | 5 ++- .../getIrsPractitionersBySearchKeyLambda.ts | 24 ++++++------- .../lambdas/users/getJudgeInSectionLambda.ts | 22 +++++------- .../lambdas/users/getNotificationsLambda.ts | 22 +++++------- ...etPrivatePractitionersBySearchKeyLambda.ts | 17 +++++---- web-api/src/lambdas/users/getUserLambda.ts | 1 - .../users/getUserPendingEmailLambda.ts | 3 +- .../users/getUserPendingEmailStatusLambda.ts | 17 +++++---- .../lambdas/users/getUsersInSectionLambda.ts | 24 ++++++------- .../users/getUsersPendingEmailLambda.ts | 24 ++++++------- .../updateUserContactInformationLambda.ts | 21 ++++++----- .../users/updateUserPendingEmailLambda.ts | 22 +++++------- .../users/verifyUserPendingEmailLambda.ts | 22 +++++------- web-api/src/lambdas/v1/getCaseLambda.ts | 1 - .../v1/getDocumentDownloadUrlLambda.ts | 1 - web-api/src/lambdas/v2/getCaseLambda.ts | 1 - .../v2/getDocumentDownloadUrlLambda.ts | 1 - .../v2/getReconciliationReportLambda.ts | 1 - .../workitems/assignWorkItemsLambda.ts | 22 +++++------- .../workitems/completeWorkItemLambda.ts | 24 ++++++------- .../getDocumentQCInboxForSectionLambda.ts | 26 ++++++-------- .../getDocumentQCInboxForUserLambda.ts | 24 ++++++------- .../getDocumentQCServedForSectionLambda.ts | 24 ++++++------- .../getDocumentQCServedForUserLambda.ts | 24 ++++++------- .../lambdas/workitems/getWorkItemLambda.ts | 22 +++++------- .../workitems/setWorkItemAsReadLambda.ts | 24 ++++++------- web-api/src/users/signUpUserLambda.ts | 9 +++-- 183 files changed, 1225 insertions(+), 1558 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts index 444dabe516c..bb9e7a2c1a8 100644 --- a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts @@ -145,10 +145,14 @@ const batchDownloadTrialSessionInteractorHelper = async ( for (const sessionCase of batchableSessionCases) { const result = await applicationContext .getUseCases() - .generateDocketRecordPdfInteractor(applicationContext, { - docketNumber: sessionCase.docketNumber, - includePartyDetail: true, - }); + .generateDocketRecordPdfInteractor( + applicationContext, + { + docketNumber: sessionCase.docketNumber, + includePartyDetail: true, + }, + authorizedUser, + ); await onDocketRecordCreation({ docketNumber: sessionCase.docketNumber }); diff --git a/web-api/src/lambdas/auth/forgotPasswordLambda.ts b/web-api/src/lambdas/auth/forgotPasswordLambda.ts index 8607772557f..a72595b61f9 100644 --- a/web-api/src/lambdas/auth/forgotPasswordLambda.ts +++ b/web-api/src/lambdas/auth/forgotPasswordLambda.ts @@ -1,11 +1,10 @@ import { APIGatewayProxyEvent } from 'aws-lambda'; +import { forgotPasswordInteractor } from '@web-api/business/useCases/auth/forgotPasswordInteractor'; import { genericHandler } from '../../genericHandler'; export const forgotPasswordLambda = (event: APIGatewayProxyEvent) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .forgotPasswordInteractor(applicationContext, { - ...JSON.parse(event.body!), - }); + return await forgotPasswordInteractor(applicationContext, { + ...JSON.parse(event.body!), + }); }); diff --git a/web-api/src/lambdas/caseAssociations/generateEntryOfAppearancePdfLambda.ts b/web-api/src/lambdas/caseAssociations/generateEntryOfAppearancePdfLambda.ts index c562395920f..c739dfc893d 100644 --- a/web-api/src/lambdas/caseAssociations/generateEntryOfAppearancePdfLambda.ts +++ b/web-api/src/lambdas/caseAssociations/generateEntryOfAppearancePdfLambda.ts @@ -1,23 +1,18 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generateEntryOfAppearancePdfInteractor } from '@web-api/business/useCases/caseAssociationRequest/generateEntryOfAppearancePdfInteractor'; import { genericHandler } from '../../genericHandler'; export const generateEntryOfAppearancePdfLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .generateEntryOfAppearancePdfInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await generateEntryOfAppearancePdfInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseDeadline/getCaseDeadlinesForCaseLambda.ts b/web-api/src/lambdas/caseDeadline/getCaseDeadlinesForCaseLambda.ts index 8105dac5a3a..0ae0f2d30bd 100644 --- a/web-api/src/lambdas/caseDeadline/getCaseDeadlinesForCaseLambda.ts +++ b/web-api/src/lambdas/caseDeadline/getCaseDeadlinesForCaseLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getCaseDeadlinesForCaseInteractor } from '@web-api/business/useCases/caseDeadline/getCaseDeadlinesForCaseInteractor'; /** * get case deadlines for case @@ -8,9 +9,7 @@ import { genericHandler } from '../../genericHandler'; */ export const getCaseDeadlinesForCaseLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCaseDeadlinesForCaseInteractor(applicationContext, { - docketNumber: event.pathParameters.docketNumber, - }); + return await getCaseDeadlinesForCaseInteractor(applicationContext, { + docketNumber: event.pathParameters.docketNumber, + }); }); diff --git a/web-api/src/lambdas/caseDeadline/getCaseDeadlinesLambda.ts b/web-api/src/lambdas/caseDeadline/getCaseDeadlinesLambda.ts index 367e8c8c614..6a740de6e92 100644 --- a/web-api/src/lambdas/caseDeadline/getCaseDeadlinesLambda.ts +++ b/web-api/src/lambdas/caseDeadline/getCaseDeadlinesLambda.ts @@ -12,16 +12,12 @@ export const getCaseDeadlinesLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getCaseDeadlinesInteractor( - applicationContext, - { - ...event.queryStringParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getCaseDeadlinesInteractor( + applicationContext, + { + ...event.queryStringParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts b/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts index 126c3737416..531ad482094 100644 --- a/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts +++ b/web-api/src/lambdas/caseDeadline/updateCaseDeadlineLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateCaseDeadlineInteractor } from '@web-api/business/useCases/caseDeadline/updateCaseDeadlineInteractor'; /** * update case deadline @@ -10,9 +11,9 @@ import { genericHandler } from '../../genericHandler'; export const updateCaseDeadlineLambda = ( event, authorizedUser: UnknownAuthUser, -) => +): Promise => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().updateCaseDeadlineInteractor( + return await updateCaseDeadlineInteractor( applicationContext, { ...JSON.parse(event.body), diff --git a/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts index 02882301b80..80c446126a6 100644 --- a/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/deleteCaseNoteLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { deleteCaseNoteInteractor } from '@web-api/business/useCases/caseNote/deleteCaseNoteInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -9,7 +10,7 @@ import { genericHandler } from '../../genericHandler'; */ export const deleteCaseNoteLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().deleteCaseNoteInteractor( + return await deleteCaseNoteInteractor( applicationContext, { ...event.pathParameters, diff --git a/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts index df961bee972..da88c4e550e 100644 --- a/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/deleteUserCaseNoteLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { deleteUserCaseNoteInteractor } from '@web-api/business/useCases/caseNote/deleteUserCaseNoteInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,7 +13,7 @@ export const deleteUserCaseNoteLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().deleteUserCaseNoteInteractor( + return await deleteUserCaseNoteInteractor( applicationContext, { ...event.pathParameters, diff --git a/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts b/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts index 10a2927d86c..3d535fc9cf0 100644 --- a/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts +++ b/web-api/src/lambdas/caseNote/getUserCaseNoteForCasesLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getUserCaseNoteForCasesInteractor } from '@web-api/business/useCases/caseNote/getUserCaseNoteForCasesInteractor'; /** * used for fetching a judge's case note @@ -12,13 +13,11 @@ export const getUserCaseNoteForCasesLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getUserCaseNoteForCasesInteractor( - applicationContext, - { - docketNumbers: JSON.parse(event.body), - }, - authorizedUser, - ); + return await getUserCaseNoteForCasesInteractor( + applicationContext, + { + docketNumbers: JSON.parse(event.body), + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts index 84deccf1433..2372fddb30d 100644 --- a/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/getUserCaseNoteLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getUserCaseNoteInteractor } from '@web-api/business/useCases/caseNote/getUserCaseNoteInteractor'; /** * used for fetching a judge's case note @@ -9,7 +10,7 @@ import { genericHandler } from '../../genericHandler'; */ export const getUserCaseNoteLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().getUserCaseNoteInteractor( + return await getUserCaseNoteInteractor( applicationContext, { ...event.pathParameters, diff --git a/web-api/src/lambdas/caseNote/saveCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/saveCaseNoteLambda.ts index e4c180083b2..dfb5034b4e0 100644 --- a/web-api/src/lambdas/caseNote/saveCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/saveCaseNoteLambda.ts @@ -9,21 +9,17 @@ import { saveCaseNoteInteractor } from '@web-api/business/useCases/caseNote/save * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const saveCaseNoteLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - const lambdaArguments = { - ...event.pathParameters, - ...JSON.parse(event.body), - }; + genericHandler(event, async ({ applicationContext }) => { + const lambdaArguments = { + ...event.pathParameters, + ...JSON.parse(event.body), + }; - return await saveCaseNoteInteractor( - applicationContext, - { - ...lambdaArguments, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await saveCaseNoteInteractor( + applicationContext, + { + ...lambdaArguments, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts b/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts index 205d45a72ae..6d53bfaffc0 100644 --- a/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts +++ b/web-api/src/lambdas/caseNote/updateUserCaseNoteLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateUserCaseNoteInteractor } from '@web-api/business/useCases/caseNote/updateUserCaseNoteInteractor'; /** * used for updating a judge's case note @@ -17,7 +18,7 @@ export const updateUserCaseNoteLambda = ( ...JSON.parse(event.body), }; - return await applicationContext.getUseCases().updateUserCaseNoteInteractor( + return await updateUserCaseNoteInteractor( applicationContext, { ...lambdaArguments, diff --git a/web-api/src/lambdas/caseWorksheet/updateCaseWorksheetLambda.ts b/web-api/src/lambdas/caseWorksheet/updateCaseWorksheetLambda.ts index 998595f1a5f..6eac6e3aa84 100644 --- a/web-api/src/lambdas/caseWorksheet/updateCaseWorksheetLambda.ts +++ b/web-api/src/lambdas/caseWorksheet/updateCaseWorksheetLambda.ts @@ -1,16 +1,15 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateCaseWorksheetInteractor } from '@web-api/business/useCases/caseWorksheet/updateCaseWorksheetInteractor'; export const updateCaseWorksheetLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCaseWorksheetInteractor( - applicationContext, - JSON.parse(event.body), - authorizedUser, - ); + return await updateCaseWorksheetInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/cases/addConsolidatedCaseLambda.ts b/web-api/src/lambdas/cases/addConsolidatedCaseLambda.ts index 93682974095..e7083a4c647 100644 --- a/web-api/src/lambdas/cases/addConsolidatedCaseLambda.ts +++ b/web-api/src/lambdas/cases/addConsolidatedCaseLambda.ts @@ -12,17 +12,13 @@ export const addConsolidatedCaseLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - await addConsolidatedCaseInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + await addConsolidatedCaseInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/addDeficiencyStatisticLambda.ts b/web-api/src/lambdas/cases/addDeficiencyStatisticLambda.ts index 225f894ffe9..b28c16596d8 100644 --- a/web-api/src/lambdas/cases/addDeficiencyStatisticLambda.ts +++ b/web-api/src/lambdas/cases/addDeficiencyStatisticLambda.ts @@ -12,17 +12,13 @@ export const addDeficiencyStatisticLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await addDeficiencyStatisticInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await addDeficiencyStatisticInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts b/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts index ed15d56b9a5..b0dd30aee8d 100644 --- a/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts +++ b/web-api/src/lambdas/cases/addPetitionerToCaseLambda.ts @@ -12,17 +12,13 @@ export const addPetitionerToCaseLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await addPetitionerToCaseInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await addPetitionerToCaseInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts b/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts index b88e3d88840..eeef043aa19 100644 --- a/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts +++ b/web-api/src/lambdas/cases/blockCaseFromTrialLambda.ts @@ -12,21 +12,17 @@ export const blockCaseFromTrialLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const lambdaArguments = { - ...event.pathParameters, - ...JSON.parse(event.body), - }; + genericHandler(event, async ({ applicationContext }) => { + const lambdaArguments = { + ...event.pathParameters, + ...JSON.parse(event.body), + }; - return await blockCaseFromTrialInteractor( - applicationContext, - { - ...lambdaArguments, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await blockCaseFromTrialInteractor( + applicationContext, + { + ...lambdaArguments, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts b/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts index f74264a56f2..d355ba43abf 100644 --- a/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts +++ b/web-api/src/lambdas/cases/caseAdvancedSearchLambda.ts @@ -12,16 +12,12 @@ export const caseAdvancedSearchLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await caseAdvancedSearchInteractor( - applicationContext, - { - ...event.queryStringParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await caseAdvancedSearchInteractor( + applicationContext, + { + ...event.queryStringParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts b/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts index 3041945fd65..f7756019f19 100644 --- a/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts +++ b/web-api/src/lambdas/cases/checkForReadyForTrialCasesLambda.ts @@ -1,4 +1,3 @@ -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { checkForReadyForTrialCasesInteractor } from '@web-api/business/useCases/checkForReadyForTrialCasesInteractor'; import { genericHandler } from '../../genericHandler'; @@ -8,17 +7,7 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const checkForReadyForTrialCasesLambda = ( - event, - authorizedUser: UnknownAuthUser, -) => - genericHandler( - event, - async ({ applicationContext }) => { - return await checkForReadyForTrialCasesInteractor( - applicationContext, - authorizedUser, - ); - }, - authorizedUser, - ); +export const checkForReadyForTrialCasesLambda = event => + genericHandler(event, async ({ applicationContext }) => { + return await checkForReadyForTrialCasesInteractor(applicationContext); + }); diff --git a/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts b/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts index 627454890e0..40aefdc7ef6 100644 --- a/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts +++ b/web-api/src/lambdas/cases/createCaseFromPaperLambda.ts @@ -12,16 +12,12 @@ export const createCaseFromPaperLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await createCaseFromPaperInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await createCaseFromPaperInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/createCaseLambda.ts b/web-api/src/lambdas/cases/createCaseLambda.ts index 2dcf4814604..d3665029342 100644 --- a/web-api/src/lambdas/cases/createCaseLambda.ts +++ b/web-api/src/lambdas/cases/createCaseLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { createCaseInteractor } from '@web-api/business/useCases/createCaseInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -9,7 +10,7 @@ import { genericHandler } from '../../genericHandler'; */ export const createCaseLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().createCaseInteractor( + return await createCaseInteractor( applicationContext, { ...JSON.parse(event.body), diff --git a/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts b/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts index 22effcd845d..cf61d46309d 100644 --- a/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts +++ b/web-api/src/lambdas/cases/deleteDeficiencyStatisticLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { deleteDeficiencyStatisticInteractor } from '@web-api/business/useCases/caseStatistics/deleteDeficiencyStatisticInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,13 +13,11 @@ export const deleteDeficiencyStatisticLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteDeficiencyStatisticInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); + return await deleteDeficiencyStatisticInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/cases/fileAndServeCourtIssuedDocumentLambda.ts b/web-api/src/lambdas/cases/fileAndServeCourtIssuedDocumentLambda.ts index 608881eb93b..8c23940583b 100644 --- a/web-api/src/lambdas/cases/fileAndServeCourtIssuedDocumentLambda.ts +++ b/web-api/src/lambdas/cases/fileAndServeCourtIssuedDocumentLambda.ts @@ -12,16 +12,12 @@ export const fileAndServeCourtIssuedDocumentLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await fileAndServeCourtIssuedDocumentInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await fileAndServeCourtIssuedDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/generateDocketRecordPdfLambda.ts b/web-api/src/lambdas/cases/generateDocketRecordPdfLambda.ts index 45df95a2947..4f30cca0592 100644 --- a/web-api/src/lambdas/cases/generateDocketRecordPdfLambda.ts +++ b/web-api/src/lambdas/cases/generateDocketRecordPdfLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generateDocketRecordPdfInteractor } from '@web-api/business/useCases/generateDocketRecordPdfInteractor'; import { genericHandler } from '../../genericHandler'; export const generateDocketRecordPdfLambda = ( @@ -8,15 +9,13 @@ export const generateDocketRecordPdfLambda = ( genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .generateDocketRecordPdfInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await generateDocketRecordPdfInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); diff --git a/web-api/src/lambdas/cases/generatePractitionerCaseListPdfLambda.ts b/web-api/src/lambdas/cases/generatePractitionerCaseListPdfLambda.ts index c7c2ce1b730..06444e2daab 100644 --- a/web-api/src/lambdas/cases/generatePractitionerCaseListPdfLambda.ts +++ b/web-api/src/lambdas/cases/generatePractitionerCaseListPdfLambda.ts @@ -25,6 +25,5 @@ export const generatePractitionerCaseListPdfLambda = ( authorizedUser, ); }, - authorizedUser, { logResults: false }, ); diff --git a/web-api/src/lambdas/cases/getCaseExistsLambda.ts b/web-api/src/lambdas/cases/getCaseExistsLambda.ts index 276c7b1ebeb..649587c0a4b 100644 --- a/web-api/src/lambdas/cases/getCaseExistsLambda.ts +++ b/web-api/src/lambdas/cases/getCaseExistsLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getCaseExistsInteractor } from '@shared/business/useCases/getCaseExistsInteractor'; /** * used for fetching existence of a single case @@ -8,9 +9,7 @@ import { genericHandler } from '../../genericHandler'; */ export const getCaseExistsLambda = event => genericHandler(event, ({ applicationContext }) => - applicationContext - .getUseCases() - .getCaseExistsInteractor(applicationContext, { - docketNumber: event.pathParameters.docketNumber, - }), + getCaseExistsInteractor(applicationContext, { + docketNumber: event.pathParameters.docketNumber, + }), ); diff --git a/web-api/src/lambdas/cases/getCaseLambda.ts b/web-api/src/lambdas/cases/getCaseLambda.ts index e95e3191f56..5875e40cf0e 100644 --- a/web-api/src/lambdas/cases/getCaseLambda.ts +++ b/web-api/src/lambdas/cases/getCaseLambda.ts @@ -9,15 +9,12 @@ import { getCaseInteractor } from '@shared/business/useCases/getCaseInteractor'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getCaseLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - ({ applicationContext }) => - getCaseInteractor( - applicationContext, - { - docketNumber: event.pathParameters.docketNumber, - }, - authorizedUser, - ), - authorizedUser, + genericHandler(event, ({ applicationContext }) => + getCaseInteractor( + applicationContext, + { + docketNumber: event.pathParameters.docketNumber, + }, + authorizedUser, + ), ); diff --git a/web-api/src/lambdas/cases/getCasesForUserLambda.ts b/web-api/src/lambdas/cases/getCasesForUserLambda.ts index d7dadf0ba0c..c9ceaedcec3 100644 --- a/web-api/src/lambdas/cases/getCasesForUserLambda.ts +++ b/web-api/src/lambdas/cases/getCasesForUserLambda.ts @@ -9,13 +9,6 @@ import { getCasesForUserInteractor } from '@shared/business/useCases/getCasesFor * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getCasesForUserLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getCasesForUserInteractor( - applicationContext, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getCasesForUserInteractor(applicationContext, authorizedUser); + }); diff --git a/web-api/src/lambdas/cases/prioritizeCaseLambda.ts b/web-api/src/lambdas/cases/prioritizeCaseLambda.ts index 01a34579d2e..67bc946aa71 100644 --- a/web-api/src/lambdas/cases/prioritizeCaseLambda.ts +++ b/web-api/src/lambdas/cases/prioritizeCaseLambda.ts @@ -9,17 +9,13 @@ import { prioritizeCaseInteractor } from '@shared/business/useCases/prioritizeCa * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const prioritizeCaseLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await prioritizeCaseInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await prioritizeCaseInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/privatePractitionerCaseAssociationLambda.ts b/web-api/src/lambdas/cases/privatePractitionerCaseAssociationLambda.ts index f0ab069df86..7f5a71f8d91 100644 --- a/web-api/src/lambdas/cases/privatePractitionerCaseAssociationLambda.ts +++ b/web-api/src/lambdas/cases/privatePractitionerCaseAssociationLambda.ts @@ -12,17 +12,13 @@ export const privatePractitionerCaseAssociationLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await submitCaseAssociationRequestInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await submitCaseAssociationRequestInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/privatePractitionerPendingCaseAssociationLambda.ts b/web-api/src/lambdas/cases/privatePractitionerPendingCaseAssociationLambda.ts index 59ba9a11b17..1fe188df87f 100644 --- a/web-api/src/lambdas/cases/privatePractitionerPendingCaseAssociationLambda.ts +++ b/web-api/src/lambdas/cases/privatePractitionerPendingCaseAssociationLambda.ts @@ -11,18 +11,14 @@ export const privatePractitionerPendingCaseAssociationLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .submitPendingCaseAssociationRequestInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await applicationContext + .getUseCases() + .submitPendingCaseAssociationRequestInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/removeCasePendingItemLambda.ts b/web-api/src/lambdas/cases/removeCasePendingItemLambda.ts index a433ed9e173..b0372be16a2 100644 --- a/web-api/src/lambdas/cases/removeCasePendingItemLambda.ts +++ b/web-api/src/lambdas/cases/removeCasePendingItemLambda.ts @@ -12,16 +12,12 @@ export const removeCasePendingItemLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await removeCasePendingItemInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await removeCasePendingItemInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts b/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts index e9dcc2c935a..88583893f18 100644 --- a/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts +++ b/web-api/src/lambdas/cases/removeConsolidatedCasesLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { removeConsolidatedCasesInteractor } from '@web-api/business/useCases/caseConsolidation/removeConsolidatedCasesInteractor'; /** * used for removing cases from consolidation @@ -16,14 +17,12 @@ export const removeConsolidatedCasesLambda = ( event.queryStringParameters.docketNumbersToRemove || '' ).split(','); - return await applicationContext - .getUseCases() - .removeConsolidatedCasesInteractor( - applicationContext, - { - ...event.pathParameters, - docketNumbersToRemove, - }, - authorizedUser, - ); + return await removeConsolidatedCasesInteractor( + applicationContext, + { + ...event.pathParameters, + docketNumbersToRemove, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/cases/removePetitionerAndUpdateCaptionLambda.ts b/web-api/src/lambdas/cases/removePetitionerAndUpdateCaptionLambda.ts index 990c15bf182..15ed5034326 100644 --- a/web-api/src/lambdas/cases/removePetitionerAndUpdateCaptionLambda.ts +++ b/web-api/src/lambdas/cases/removePetitionerAndUpdateCaptionLambda.ts @@ -12,17 +12,13 @@ export const removePetitionerAndUpdateCaptionLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await removePetitionerAndUpdateCaptionInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await removePetitionerAndUpdateCaptionInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/saveCaseDetailInternalEditLambda.ts b/web-api/src/lambdas/cases/saveCaseDetailInternalEditLambda.ts index 75b8f0b3995..e0741e6bd3d 100644 --- a/web-api/src/lambdas/cases/saveCaseDetailInternalEditLambda.ts +++ b/web-api/src/lambdas/cases/saveCaseDetailInternalEditLambda.ts @@ -12,18 +12,14 @@ export const saveCaseDetailInternalEditLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await saveCaseDetailInternalEditInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - caseToUpdate: JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await saveCaseDetailInternalEditInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + caseToUpdate: JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/sealCaseContactAddressLambda.ts b/web-api/src/lambdas/cases/sealCaseContactAddressLambda.ts index 95613d04a0e..4d4ecd199ed 100644 --- a/web-api/src/lambdas/cases/sealCaseContactAddressLambda.ts +++ b/web-api/src/lambdas/cases/sealCaseContactAddressLambda.ts @@ -12,16 +12,12 @@ export const sealCaseContactAddressLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await sealCaseContactAddressInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await sealCaseContactAddressInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/sealCaseLambda.ts b/web-api/src/lambdas/cases/sealCaseLambda.ts index 666315cadb4..58531d3f3be 100644 --- a/web-api/src/lambdas/cases/sealCaseLambda.ts +++ b/web-api/src/lambdas/cases/sealCaseLambda.ts @@ -9,16 +9,12 @@ import { sealCaseInteractor } from '@shared/business/useCases/sealCaseInteractor * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const sealCaseLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await sealCaseInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await sealCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts b/web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts index d35088e6cc0..13d59401ad4 100644 --- a/web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts +++ b/web-api/src/lambdas/cases/sendMaintenanceNotificationsLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { sendMaintenanceNotificationsInteractor } from '@web-api/business/useCases/maintenance/sendMaintenanceNotificationsInteractor'; /** * lambda which is used to send notifications to all users when maintenance mode is toggled @@ -10,11 +11,9 @@ export const sendMaintenanceNotificationsLambda = event => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .sendMaintenanceNotificationsInteractor(applicationContext, { - maintenanceMode: event.maintenanceMode, - }); + return await sendMaintenanceNotificationsInteractor(applicationContext, { + maintenanceMode: event.maintenanceMode, + }); }, { bypassMaintenanceCheck: true, diff --git a/web-api/src/lambdas/cases/serveCaseToIrsLambda.ts b/web-api/src/lambdas/cases/serveCaseToIrsLambda.ts index d0b918de54b..2eed0082d2c 100644 --- a/web-api/src/lambdas/cases/serveCaseToIrsLambda.ts +++ b/web-api/src/lambdas/cases/serveCaseToIrsLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { serveCaseToIrsInteractor } from '@web-api/business/useCases/serveCaseToIrs/serveCaseToIrsInteractor'; /** * serve case to irs @@ -11,7 +12,7 @@ export const serveCaseToIrsLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().serveCaseToIrsInteractor( + return await serveCaseToIrsInteractor( applicationContext, { ...event.pathParameters, diff --git a/web-api/src/lambdas/cases/serveCourtIssuedDocumentLambda.ts b/web-api/src/lambdas/cases/serveCourtIssuedDocumentLambda.ts index 69d15e0f62e..532d0c88054 100644 --- a/web-api/src/lambdas/cases/serveCourtIssuedDocumentLambda.ts +++ b/web-api/src/lambdas/cases/serveCourtIssuedDocumentLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { serveCourtIssuedDocumentInteractor } from '@web-api/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor'; /** * used for serving a court-issued document on all parties and closing the case for some document types @@ -14,15 +15,13 @@ export const serveCourtIssuedDocumentLambda = ( genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .serveCourtIssuedDocumentInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await serveCourtIssuedDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); diff --git a/web-api/src/lambdas/cases/unblockCaseFromTrialLambda.ts b/web-api/src/lambdas/cases/unblockCaseFromTrialLambda.ts index dec2a18f10a..29280fb965c 100644 --- a/web-api/src/lambdas/cases/unblockCaseFromTrialLambda.ts +++ b/web-api/src/lambdas/cases/unblockCaseFromTrialLambda.ts @@ -12,16 +12,12 @@ export const unblockCaseFromTrialLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await unblockCaseFromTrialInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await unblockCaseFromTrialInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/unprioritizeCaseLambda.ts b/web-api/src/lambdas/cases/unprioritizeCaseLambda.ts index bd9b9bdb258..756b2e424bd 100644 --- a/web-api/src/lambdas/cases/unprioritizeCaseLambda.ts +++ b/web-api/src/lambdas/cases/unprioritizeCaseLambda.ts @@ -12,16 +12,12 @@ export const unprioritizeCaseLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await unprioritizeCaseInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await unprioritizeCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/unsealCaseLambda.ts b/web-api/src/lambdas/cases/unsealCaseLambda.ts index 56afd224a47..6fe48de192b 100644 --- a/web-api/src/lambdas/cases/unsealCaseLambda.ts +++ b/web-api/src/lambdas/cases/unsealCaseLambda.ts @@ -9,16 +9,12 @@ import { unsealCaseInteractor } from '@shared/business/useCases/unsealCaseIntera * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const unsealCaseLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await unsealCaseInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await unsealCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/updateCaseContextLambda.ts b/web-api/src/lambdas/cases/updateCaseContextLambda.ts index a1c5a1592d0..e073f2fec1a 100644 --- a/web-api/src/lambdas/cases/updateCaseContextLambda.ts +++ b/web-api/src/lambdas/cases/updateCaseContextLambda.ts @@ -12,17 +12,13 @@ export const updateCaseContextLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await updateCaseContextInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await updateCaseContextInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/updateCaseDetailsLambda.ts b/web-api/src/lambdas/cases/updateCaseDetailsLambda.ts index 456590e0835..ffc15ef3126 100644 --- a/web-api/src/lambdas/cases/updateCaseDetailsLambda.ts +++ b/web-api/src/lambdas/cases/updateCaseDetailsLambda.ts @@ -13,17 +13,13 @@ export const updateCaseDetailsLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await updateCaseDetailsInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await updateCaseDetailsInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/updateCaseTrialSortTagsLambda.ts b/web-api/src/lambdas/cases/updateCaseTrialSortTagsLambda.ts index 1fd68b2e51f..dabd851d701 100644 --- a/web-api/src/lambdas/cases/updateCaseTrialSortTagsLambda.ts +++ b/web-api/src/lambdas/cases/updateCaseTrialSortTagsLambda.ts @@ -12,16 +12,12 @@ export const updateCaseTrialSortTagsLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await updateCaseTrialSortTagsInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await updateCaseTrialSortTagsInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/updateContactLambda.ts b/web-api/src/lambdas/cases/updateContactLambda.ts index 86fb0bddba7..43a31f7a701 100644 --- a/web-api/src/lambdas/cases/updateContactLambda.ts +++ b/web-api/src/lambdas/cases/updateContactLambda.ts @@ -9,16 +9,12 @@ import { updateContactInteractor } from '@shared/business/useCases/updateContact * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const updateContactLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await updateContactInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await updateContactInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/updateCounselOnCaseLambda.ts b/web-api/src/lambdas/cases/updateCounselOnCaseLambda.ts index 387384bfb5b..aa92afd97fd 100644 --- a/web-api/src/lambdas/cases/updateCounselOnCaseLambda.ts +++ b/web-api/src/lambdas/cases/updateCounselOnCaseLambda.ts @@ -12,17 +12,13 @@ export const updateCounselOnCaseLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await updateCounselOnCaseInteractor( - applicationContext, - { - ...event.pathParameters, - userData: JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await updateCounselOnCaseInteractor( + applicationContext, + { + ...event.pathParameters, + userData: JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts b/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts index ac512fe0082..27e8c846ccd 100644 --- a/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts +++ b/web-api/src/lambdas/cases/updateDeficiencyStatisticLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateDeficiencyStatisticInteractor } from '@web-api/business/useCases/caseStatistics/updateDeficiencyStatisticInteractor'; /** * updates a statistic on the case @@ -12,14 +13,12 @@ export const updateDeficiencyStatisticLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateDeficiencyStatisticInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await updateDeficiencyStatisticInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/cases/updateOtherStatisticsLambda.ts b/web-api/src/lambdas/cases/updateOtherStatisticsLambda.ts index 23ff55b6e98..da463b927ec 100644 --- a/web-api/src/lambdas/cases/updateOtherStatisticsLambda.ts +++ b/web-api/src/lambdas/cases/updateOtherStatisticsLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateOtherStatisticsInteractor } from '@web-api/business/useCases/caseStatistics/updateOtherStatisticsInteractor'; /** * updates other statistics on the case (litigation costs and damages) @@ -12,14 +13,12 @@ export const updateOtherStatisticsLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateOtherStatisticsInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await updateOtherStatisticsInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/cases/updatePetitionerInformationLambda.ts b/web-api/src/lambdas/cases/updatePetitionerInformationLambda.ts index 6f725a4d486..ad296d8b3bb 100644 --- a/web-api/src/lambdas/cases/updatePetitionerInformationLambda.ts +++ b/web-api/src/lambdas/cases/updatePetitionerInformationLambda.ts @@ -12,17 +12,13 @@ export const updatePetitionerInformationLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await updatePetitionerInformationInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await updatePetitionerInformationInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/updateQcCompleteForTrialLambda.ts b/web-api/src/lambdas/cases/updateQcCompleteForTrialLambda.ts index ef179053d86..54bff5b485a 100644 --- a/web-api/src/lambdas/cases/updateQcCompleteForTrialLambda.ts +++ b/web-api/src/lambdas/cases/updateQcCompleteForTrialLambda.ts @@ -12,17 +12,13 @@ export const updateQcCompleteForTrialLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }): Promise => { - return await updateQcCompleteForTrialInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }): Promise => { + return await updateQcCompleteForTrialInteractor( + applicationContext, + { + ...event.pathParameters, + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/cases/verifyPendingCaseForUserLambda.ts b/web-api/src/lambdas/cases/verifyPendingCaseForUserLambda.ts index f5d5c346f22..01b5925a3b6 100644 --- a/web-api/src/lambdas/cases/verifyPendingCaseForUserLambda.ts +++ b/web-api/src/lambdas/cases/verifyPendingCaseForUserLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { verifyPendingCaseForUserInteractor } from '@web-api/business/useCases/caseAssociationRequest/verifyPendingCaseForUserInteractor'; /** * used for determining if a user has pending association with a case or not @@ -8,9 +9,7 @@ import { genericHandler } from '../../genericHandler'; */ export const verifyPendingCaseForUserLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .verifyPendingCaseForUserInteractor(applicationContext, { - ...event.pathParameters, - }); + return await verifyPendingCaseForUserInteractor(applicationContext, { + ...event.pathParameters, + }); }); diff --git a/web-api/src/lambdas/correspondence/archiveCorrespondenceDocumentLambda.ts b/web-api/src/lambdas/correspondence/archiveCorrespondenceDocumentLambda.ts index cb56103c763..589f21f4194 100644 --- a/web-api/src/lambdas/correspondence/archiveCorrespondenceDocumentLambda.ts +++ b/web-api/src/lambdas/correspondence/archiveCorrespondenceDocumentLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { archiveCorrespondenceDocumentInteractor } from '@web-api/business/useCases/correspondence/archiveCorrespondenceDocumentInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,13 +13,11 @@ export const archiveCorrespondenceDocumentLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .archiveCorrespondenceDocumentInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); + return await archiveCorrespondenceDocumentInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/correspondence/fileCorrespondenceDocumentLambda.ts b/web-api/src/lambdas/correspondence/fileCorrespondenceDocumentLambda.ts index 5505d00511f..ec47a29cda1 100644 --- a/web-api/src/lambdas/correspondence/fileCorrespondenceDocumentLambda.ts +++ b/web-api/src/lambdas/correspondence/fileCorrespondenceDocumentLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { fileCorrespondenceDocumentInteractor } from '@web-api/business/useCases/correspondence/fileCorrespondenceDocumentInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,13 +13,11 @@ export const fileCorrespondenceDocumentLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .fileCorrespondenceDocumentInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await fileCorrespondenceDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/correspondence/updateCorrespondenceDocumentLambda.ts b/web-api/src/lambdas/correspondence/updateCorrespondenceDocumentLambda.ts index ef30a16238d..d17cc16a7bd 100644 --- a/web-api/src/lambdas/correspondence/updateCorrespondenceDocumentLambda.ts +++ b/web-api/src/lambdas/correspondence/updateCorrespondenceDocumentLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateCorrespondenceDocumentInteractor } from '@web-api/business/useCases/correspondence/updateCorrespondenceDocumentInteractor'; /** * upload a correspondence document @@ -12,13 +13,11 @@ export const updateCorrespondenceDocumentLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCorrespondenceDocumentInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await updateCorrespondenceDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/courtIssuedOrder/appendAmendedPetitionFormLambda.ts b/web-api/src/lambdas/courtIssuedOrder/appendAmendedPetitionFormLambda.ts index 655571734e8..cdedf391a87 100644 --- a/web-api/src/lambdas/courtIssuedOrder/appendAmendedPetitionFormLambda.ts +++ b/web-api/src/lambdas/courtIssuedOrder/appendAmendedPetitionFormLambda.ts @@ -21,6 +21,5 @@ export const appendAmendedPetitionFormLambda = ( authorizedUser, ); }, - authorizedUser, { logResults: false }, ); diff --git a/web-api/src/lambdas/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlLambda.ts b/web-api/src/lambdas/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlLambda.ts index 34fd5633e4e..7c772088b40 100644 --- a/web-api/src/lambdas/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlLambda.ts +++ b/web-api/src/lambdas/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { createCourtIssuedOrderPdfFromHtmlInteractor } from '@web-api/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -14,15 +15,13 @@ export const createCourtIssuedOrderPdfFromHtmlLambda = ( genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createCourtIssuedOrderPdfFromHtmlInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await createCourtIssuedOrderPdfFromHtmlInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); diff --git a/web-api/src/lambdas/documents/addCoversheetLambda.ts b/web-api/src/lambdas/documents/addCoversheetLambda.ts index a98d28313de..70390310d0c 100644 --- a/web-api/src/lambdas/documents/addCoversheetLambda.ts +++ b/web-api/src/lambdas/documents/addCoversheetLambda.ts @@ -18,6 +18,5 @@ export const addCoversheetLambda = (event, authorizedUser: UnknownAuthUser) => authorizedUser, ); }, - authorizedUser, { logResults: false }, ); diff --git a/web-api/src/lambdas/documents/addPaperFilingLambda.ts b/web-api/src/lambdas/documents/addPaperFilingLambda.ts index 0fa6a9556cf..ec4d94fcfd0 100644 --- a/web-api/src/lambdas/documents/addPaperFilingLambda.ts +++ b/web-api/src/lambdas/documents/addPaperFilingLambda.ts @@ -1,9 +1,10 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { addPaperFilingInteractor } from '@web-api/business/useCases/docketEntry/addPaperFilingInteractor'; import { genericHandler } from '../../genericHandler'; export const addPaperFilingLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().addPaperFilingInteractor( + return await addPaperFilingInteractor( applicationContext, { ...JSON.parse(event.body), diff --git a/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts b/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts index 8adaab4c58b..6a48f2592bc 100644 --- a/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts +++ b/web-api/src/lambdas/documents/archiveDraftDocumentLambda.ts @@ -12,14 +12,10 @@ export const archiveDraftDocumentLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await archiveDraftDocumentInteractor( - applicationContext, - event.pathParameters, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await archiveDraftDocumentInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/batchDownloadDocketEntriesLambda.ts b/web-api/src/lambdas/documents/batchDownloadDocketEntriesLambda.ts index f4027295e3a..5070a096e88 100644 --- a/web-api/src/lambdas/documents/batchDownloadDocketEntriesLambda.ts +++ b/web-api/src/lambdas/documents/batchDownloadDocketEntriesLambda.ts @@ -12,14 +12,10 @@ export const batchDownloadDocketEntriesLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - await batchDownloadDocketEntriesInteractor( - applicationContext, - JSON.parse(event.body), - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + await batchDownloadDocketEntriesInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/completeDocketEntryQCLambda.ts b/web-api/src/lambdas/documents/completeDocketEntryQCLambda.ts index 1ccc39332f4..78d2e680b33 100644 --- a/web-api/src/lambdas/documents/completeDocketEntryQCLambda.ts +++ b/web-api/src/lambdas/documents/completeDocketEntryQCLambda.ts @@ -12,14 +12,10 @@ export const completeDocketEntryQCLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await completeDocketEntryQCInteractor( - applicationContext, - JSON.parse(event.body), - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await completeDocketEntryQCInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts b/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts index 0d2558d13c4..13c761ab63b 100644 --- a/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts +++ b/web-api/src/lambdas/documents/downloadPolicyUrlLambda.ts @@ -12,14 +12,10 @@ export const downloadPolicyUrlLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getDownloadPolicyUrlInteractor( - applicationContext, - event.pathParameters, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getDownloadPolicyUrlInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/fileCourtIssuedDocketEntryLambda.ts b/web-api/src/lambdas/documents/fileCourtIssuedDocketEntryLambda.ts index f9b0768ab92..47e920967b2 100644 --- a/web-api/src/lambdas/documents/fileCourtIssuedDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/fileCourtIssuedDocketEntryLambda.ts @@ -12,16 +12,12 @@ export const fileCourtIssuedDocketEntryLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await fileCourtIssuedDocketEntryInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await fileCourtIssuedDocketEntryInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/fileCourtIssuedOrderToCaseLambda.ts b/web-api/src/lambdas/documents/fileCourtIssuedOrderToCaseLambda.ts index af337032af2..9a8c251c782 100644 --- a/web-api/src/lambdas/documents/fileCourtIssuedOrderToCaseLambda.ts +++ b/web-api/src/lambdas/documents/fileCourtIssuedOrderToCaseLambda.ts @@ -12,14 +12,10 @@ export const fileCourtIssuedOrderToCaseLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await fileCourtIssuedOrderInteractor( - applicationContext, - JSON.parse(event.body), - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await fileCourtIssuedOrderInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/fileExternalDocumentToCaseLambda.ts b/web-api/src/lambdas/documents/fileExternalDocumentToCaseLambda.ts index c72e251fab1..64d87fe8a19 100644 --- a/web-api/src/lambdas/documents/fileExternalDocumentToCaseLambda.ts +++ b/web-api/src/lambdas/documents/fileExternalDocumentToCaseLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { fileExternalDocumentInteractor } from '@web-api/business/useCases/externalDocument/fileExternalDocumentInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,11 +13,9 @@ export const fileExternalDocumentToCaseLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .fileExternalDocumentInteractor( - applicationContext, - JSON.parse(event.body), - authorizedUser, - ); + return await fileExternalDocumentInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/documents/generateDraftStampOrderLambda.ts b/web-api/src/lambdas/documents/generateDraftStampOrderLambda.ts index afe61b6952c..0cc6082e908 100644 --- a/web-api/src/lambdas/documents/generateDraftStampOrderLambda.ts +++ b/web-api/src/lambdas/documents/generateDraftStampOrderLambda.ts @@ -24,6 +24,5 @@ export const generateDraftStampOrderLambda = ( authorizedUser, ); }, - authorizedUser, { logResults: false }, ); diff --git a/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts b/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts index 1d99e408427..e1dbb041529 100644 --- a/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts +++ b/web-api/src/lambdas/documents/generatePrintableFilingReceiptLambda.ts @@ -12,14 +12,10 @@ export const generatePrintableFilingReceiptLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await generatePrintableFilingReceiptInteractor( - applicationContext, - JSON.parse(event.body), - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await generatePrintableFilingReceiptInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/getDocumentContentsForDocketEntryLambda.ts b/web-api/src/lambdas/documents/getDocumentContentsForDocketEntryLambda.ts index 15a00d3a99e..fc24022f5bc 100644 --- a/web-api/src/lambdas/documents/getDocumentContentsForDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/getDocumentContentsForDocketEntryLambda.ts @@ -1,16 +1,15 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getDocumentContentsForDocketEntryInteractor } from '@web-api/business/useCases/document/getDocumentContentsForDocketEntryInteractor'; export const getDocumentContentsForDocketEntryLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getDocumentContentsForDocketEntryInteractor( - applicationContext, - event.pathParameters, - authorizedUser, - ); + return await getDocumentContentsForDocketEntryInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts index e5da4dcc95c..6c9e74849d9 100644 --- a/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/documents/getDocumentDownloadUrlLambda.ts @@ -13,14 +13,10 @@ export const getDocumentDownloadUrlLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getDownloadPolicyUrlInteractor( - applicationContext, - event.pathParameters, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getDownloadPolicyUrlInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/getUploadPolicyLambda.ts b/web-api/src/lambdas/documents/getUploadPolicyLambda.ts index 9865f8b78d5..5c6b32432d4 100644 --- a/web-api/src/lambdas/documents/getUploadPolicyLambda.ts +++ b/web-api/src/lambdas/documents/getUploadPolicyLambda.ts @@ -9,16 +9,12 @@ import { getUploadPolicyInteractor } from '@web-api/business/useCases/document/g * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getUploadPolicyLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getUploadPolicyInteractor( - applicationContext, - { - key: event.pathParameters.key, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getUploadPolicyInteractor( + applicationContext, + { + key: event.pathParameters.key, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/opinionAdvancedSearchLambda.ts b/web-api/src/lambdas/documents/opinionAdvancedSearchLambda.ts index 03974974652..9c0d1efdaa7 100644 --- a/web-api/src/lambdas/documents/opinionAdvancedSearchLambda.ts +++ b/web-api/src/lambdas/documents/opinionAdvancedSearchLambda.ts @@ -12,20 +12,16 @@ export const opinionAdvancedSearchLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const opinionTypes = - event.queryStringParameters.opinionTypes?.split(',') || []; + genericHandler(event, async ({ applicationContext }) => { + const opinionTypes = + event.queryStringParameters.opinionTypes?.split(',') || []; - return await opinionAdvancedSearchInteractor( - applicationContext, - { - ...event.queryStringParameters, - opinionTypes, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await opinionAdvancedSearchInteractor( + applicationContext, + { + ...event.queryStringParameters, + opinionTypes, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/orderAdvancedSearchLambda.ts b/web-api/src/lambdas/documents/orderAdvancedSearchLambda.ts index 99cadfff47a..7be2bd4bd4a 100644 --- a/web-api/src/lambdas/documents/orderAdvancedSearchLambda.ts +++ b/web-api/src/lambdas/documents/orderAdvancedSearchLambda.ts @@ -12,14 +12,10 @@ export const orderAdvancedSearchLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await orderAdvancedSearchInteractor( - applicationContext, - event.queryStringParameters, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await orderAdvancedSearchInteractor( + applicationContext, + event.queryStringParameters, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/removePdfFromDocketEntryLambda.ts b/web-api/src/lambdas/documents/removePdfFromDocketEntryLambda.ts index ce27ba4538c..e851a4220e5 100644 --- a/web-api/src/lambdas/documents/removePdfFromDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/removePdfFromDocketEntryLambda.ts @@ -12,14 +12,10 @@ export const removePdfFromDocketEntryLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await removePdfFromDocketEntryInteractor( - applicationContext, - event.pathParameters, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await removePdfFromDocketEntryInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/removeSignatureFromDocumentLambda.ts b/web-api/src/lambdas/documents/removeSignatureFromDocumentLambda.ts index 1b3e988c022..34d303e73e2 100644 --- a/web-api/src/lambdas/documents/removeSignatureFromDocumentLambda.ts +++ b/web-api/src/lambdas/documents/removeSignatureFromDocumentLambda.ts @@ -12,14 +12,10 @@ export const removeSignatureFromDocumentLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await removeSignatureFromDocumentInteractor( - applicationContext, - event.pathParameters, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await removeSignatureFromDocumentInteractor( + applicationContext, + event.pathParameters, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/saveSignedDocumentLambda.ts b/web-api/src/lambdas/documents/saveSignedDocumentLambda.ts index 8d1176d35ba..94e275e2b50 100644 --- a/web-api/src/lambdas/documents/saveSignedDocumentLambda.ts +++ b/web-api/src/lambdas/documents/saveSignedDocumentLambda.ts @@ -12,23 +12,19 @@ export const saveSignedDocumentLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { - body, - pathParameters: { docketEntryId: originalDocketEntryId, docketNumber }, - } = event; + genericHandler(event, async ({ applicationContext }) => { + const { + body, + pathParameters: { docketEntryId: originalDocketEntryId, docketNumber }, + } = event; - return await saveSignedDocumentInteractor( - applicationContext, - { - ...JSON.parse(body), - docketNumber, - originalDocketEntryId, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await saveSignedDocumentInteractor( + applicationContext, + { + ...JSON.parse(body), + docketNumber, + originalDocketEntryId, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/sealDocketEntryLambda.ts b/web-api/src/lambdas/documents/sealDocketEntryLambda.ts index 8152360121f..f52abcde784 100644 --- a/web-api/src/lambdas/documents/sealDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/sealDocketEntryLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { sealDocketEntryInteractor } from '@web-api/business/useCases/docketEntry/sealDocketEntryInteractor'; /** * used for sealing docket entries @@ -16,7 +17,7 @@ export const sealDocketEntryLambda = (event, authorizedUser: UnknownAuthUser) => const { docketEntrySealedTo } = JSON.parse(event.body); - return await applicationContext.getUseCases().sealDocketEntryInteractor( + return await sealDocketEntryInteractor( applicationContext, { docketEntryId, diff --git a/web-api/src/lambdas/documents/serveExternallyFiledDocumentLambda.ts b/web-api/src/lambdas/documents/serveExternallyFiledDocumentLambda.ts index 8367e554f83..b414f42e46d 100644 --- a/web-api/src/lambdas/documents/serveExternallyFiledDocumentLambda.ts +++ b/web-api/src/lambdas/documents/serveExternallyFiledDocumentLambda.ts @@ -1,18 +1,17 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { serveExternallyFiledDocumentInteractor } from '@web-api/business/useCases/document/serveExternallyFiledDocumentInteractor'; export const serveExternallyFiledDocumentLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .serveExternallyFiledDocumentInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await serveExternallyFiledDocumentInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/documents/strikeDocketEntryLambda.ts b/web-api/src/lambdas/documents/strikeDocketEntryLambda.ts index c54d0c58d9d..21afe92b647 100644 --- a/web-api/src/lambdas/documents/strikeDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/strikeDocketEntryLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { strikeDocketEntryInteractor } from '@web-api/business/useCases/docketEntry/strikeDocketEntryInteractor'; /** * used for striking docket records @@ -17,7 +18,7 @@ export const strikeDocketEntryLambda = ( pathParameters: { docketEntryId, docketNumber }, } = event; - return await applicationContext.getUseCases().strikeDocketEntryInteractor( + return await strikeDocketEntryInteractor( applicationContext, { docketEntryId, diff --git a/web-api/src/lambdas/documents/unsealDocketEntryLambda.ts b/web-api/src/lambdas/documents/unsealDocketEntryLambda.ts index 38b9244a886..681b830f9a7 100644 --- a/web-api/src/lambdas/documents/unsealDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/unsealDocketEntryLambda.ts @@ -12,21 +12,17 @@ export const unsealDocketEntryLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { - pathParameters: { docketEntryId, docketNumber }, - } = event; + genericHandler(event, async ({ applicationContext }) => { + const { + pathParameters: { docketEntryId, docketNumber }, + } = event; - return await unsealDocketEntryInteractor( - applicationContext, - { - docketEntryId, - docketNumber, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await unsealDocketEntryInteractor( + applicationContext, + { + docketEntryId, + docketNumber, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/documents/updateCourtIssuedDocketEntryLambda.ts b/web-api/src/lambdas/documents/updateCourtIssuedDocketEntryLambda.ts index 4c5e7825a75..f55515766b0 100644 --- a/web-api/src/lambdas/documents/updateCourtIssuedDocketEntryLambda.ts +++ b/web-api/src/lambdas/documents/updateCourtIssuedDocketEntryLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateCourtIssuedDocketEntryInteractor } from '@web-api/business/useCases/docketEntry/updateCourtIssuedDocketEntryInteractor'; /** * lambda which is used for updating a court issued docket entry @@ -13,11 +14,9 @@ export const updateCourtIssuedDocketEntryLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCourtIssuedDocketEntryInteractor( - applicationContext, - JSON.parse(event.body), - authorizedUser, - ); + return await updateCourtIssuedDocketEntryInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/documents/updateCourtIssuedOrderToCaseLambda.ts b/web-api/src/lambdas/documents/updateCourtIssuedOrderToCaseLambda.ts index d7047dafc0e..ae94379f12c 100644 --- a/web-api/src/lambdas/documents/updateCourtIssuedOrderToCaseLambda.ts +++ b/web-api/src/lambdas/documents/updateCourtIssuedOrderToCaseLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateCourtIssuedOrderInteractor } from '@web-api/business/useCases/courtIssuedOrder/updateCourtIssuedOrderInteractor'; /** * lambda which is used for updating a draft order @@ -12,14 +13,12 @@ export const updateCourtIssuedOrderToCaseLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateCourtIssuedOrderInteractor( - applicationContext, - { - ...JSON.parse(event.body), - docketEntryIdToEdit: event.pathParameters.docketEntryId, - }, - authorizedUser, - ); + return await updateCourtIssuedOrderInteractor( + applicationContext, + { + ...JSON.parse(event.body), + docketEntryIdToEdit: event.pathParameters.docketEntryId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/documents/updateDocketEntryMetaLambda.ts b/web-api/src/lambdas/documents/updateDocketEntryMetaLambda.ts index e3264759676..e5cd4502557 100644 --- a/web-api/src/lambdas/documents/updateDocketEntryMetaLambda.ts +++ b/web-api/src/lambdas/documents/updateDocketEntryMetaLambda.ts @@ -1,19 +1,18 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateDocketEntryMetaInteractor } from '@web-api/business/useCases/docketEntry/updateDocketEntryMetaInteractor'; export const updateDocketEntryMetaLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateDocketEntryMetaInteractor( - applicationContext, - { - ...JSON.parse(event.body), - ...event.pathParameters, - }, - authorizedUser, - ); + return await updateDocketEntryMetaInteractor( + applicationContext, + { + ...JSON.parse(event.body), + ...event.pathParameters, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/documents/validatePdfLambda.ts b/web-api/src/lambdas/documents/validatePdfLambda.ts index aec1cf2cdc4..c4f724ea2b5 100644 --- a/web-api/src/lambdas/documents/validatePdfLambda.ts +++ b/web-api/src/lambdas/documents/validatePdfLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { validatePdfInteractor } from '@web-api/business/useCases/pdf/validatePdfInteractor'; /** * used for validating PDF documents @@ -10,9 +11,7 @@ export const validatePdfLambda = event => genericHandler(event, async ({ applicationContext }) => { const { key } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .validatePdfInteractor(applicationContext, { - key, - }); + return await validatePdfInteractor(applicationContext, { + key, + }); }); diff --git a/web-api/src/lambdas/email/handleBounceNotificationsLambda.ts b/web-api/src/lambdas/email/handleBounceNotificationsLambda.ts index f1897b622da..05b1d7b2179 100644 --- a/web-api/src/lambdas/email/handleBounceNotificationsLambda.ts +++ b/web-api/src/lambdas/email/handleBounceNotificationsLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { handleBounceNotificationInteractor } from '@web-api/business/useCases/email/handleBounceNotificationInteractor'; /** * This lambda handles SNS notifications that occur whenever a service Email bounces. We @@ -17,9 +18,7 @@ export const handleBounceNotificationsLambda = event => return await Promise.all( records.map(record => - applicationContext - .getUseCases() - .handleBounceNotificationInteractor(applicationContext, record), + handleBounceNotificationInteractor(applicationContext, record), ), ); }, diff --git a/web-api/src/lambdas/featureFlag/getAllFeatureFlagsLambda.ts b/web-api/src/lambdas/featureFlag/getAllFeatureFlagsLambda.ts index 98d647e6bfc..e5c8cc4aba2 100644 --- a/web-api/src/lambdas/featureFlag/getAllFeatureFlagsLambda.ts +++ b/web-api/src/lambdas/featureFlag/getAllFeatureFlagsLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getAllFeatureFlagsInteractor } from '@web-api/business/useCases/featureFlag/getAllFeatureFlagsInteractor'; /** * gets the value of the provided feature flag @@ -10,9 +11,7 @@ export const getAllFeatureFlagsLambda = event => genericHandler( event, ({ applicationContext }) => { - return applicationContext - .getUseCases() - .getAllFeatureFlagsInteractor(applicationContext); + return getAllFeatureFlagsInteractor(applicationContext); }, { bypassMaintenanceCheck: true }, ); diff --git a/web-api/src/lambdas/health/getCachedHealthCheckLambda.ts b/web-api/src/lambdas/health/getCachedHealthCheckLambda.ts index 8d555f403f1..e4626e9c968 100644 --- a/web-api/src/lambdas/health/getCachedHealthCheckLambda.ts +++ b/web-api/src/lambdas/health/getCachedHealthCheckLambda.ts @@ -1,8 +1,7 @@ import { genericHandler } from '@web-api/genericHandler'; +import { getCachedHealthCheckInteractor } from '@web-api/business/useCases/health/getCachedHealthCheckInteractor'; export const getCachedHealthCheckLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCachedHealthCheckInteractor(applicationContext); + return await getCachedHealthCheckInteractor(applicationContext); }); diff --git a/web-api/src/lambdas/health/getHealthCheckLambda.ts b/web-api/src/lambdas/health/getHealthCheckLambda.ts index c20590543e8..2a1ff70ac93 100644 --- a/web-api/src/lambdas/health/getHealthCheckLambda.ts +++ b/web-api/src/lambdas/health/getHealthCheckLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getHealthCheckInteractor } from '@web-api/business/useCases/health/getHealthCheckInteractor'; /** * used for checking status of critical services @@ -8,7 +9,5 @@ import { genericHandler } from '../../genericHandler'; */ export const getHealthCheckLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getHealthCheckInteractor(applicationContext); + return await getHealthCheckInteractor(applicationContext); }); diff --git a/web-api/src/lambdas/health/setHealthCheckCacheLambda.ts b/web-api/src/lambdas/health/setHealthCheckCacheLambda.ts index 034686c8bc1..7baa7a61d97 100644 --- a/web-api/src/lambdas/health/setHealthCheckCacheLambda.ts +++ b/web-api/src/lambdas/health/setHealthCheckCacheLambda.ts @@ -1,8 +1,7 @@ import { genericHandler } from '@web-api/genericHandler'; +import { setHealthCheckCacheInteractor } from '@web-api/business/useCases/health/setHealthCheckCacheInteractor'; export const setHealthCheckCacheLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .setHealthCheckCacheInteractor(applicationContext); + return await setHealthCheckCacheInteractor(applicationContext); }); diff --git a/web-api/src/lambdas/maintenance/getMaintenanceModeLambda.ts b/web-api/src/lambdas/maintenance/getMaintenanceModeLambda.ts index e1ae7c6f7fa..0cd95dd773a 100644 --- a/web-api/src/lambdas/maintenance/getMaintenanceModeLambda.ts +++ b/web-api/src/lambdas/maintenance/getMaintenanceModeLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getMaintenanceModeInteractor } from '@shared/business/useCases/getMaintenanceModeInteractor'; /** * used for fetching the value of maintenance mode @@ -10,9 +11,7 @@ export const getMaintenanceModeLambda = event => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getMaintenanceModeInteractor(applicationContext); + return await getMaintenanceModeInteractor(applicationContext); }, { bypassMaintenanceCheck: true }, ); diff --git a/web-api/src/lambdas/manualAssociation/associateIrsPractitionerWithCaseLambda.ts b/web-api/src/lambdas/manualAssociation/associateIrsPractitionerWithCaseLambda.ts index 56888ae7b04..395281c9b93 100644 --- a/web-api/src/lambdas/manualAssociation/associateIrsPractitionerWithCaseLambda.ts +++ b/web-api/src/lambdas/manualAssociation/associateIrsPractitionerWithCaseLambda.ts @@ -12,16 +12,12 @@ export const associateIrsPractitionerWithCaseLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await associateIrsPractitionerWithCaseInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await associateIrsPractitionerWithCaseInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/manualAssociation/associatePrivatePractitionerWithCaseLambda.ts b/web-api/src/lambdas/manualAssociation/associatePrivatePractitionerWithCaseLambda.ts index f38edd3b897..aa7b04c6f36 100644 --- a/web-api/src/lambdas/manualAssociation/associatePrivatePractitionerWithCaseLambda.ts +++ b/web-api/src/lambdas/manualAssociation/associatePrivatePractitionerWithCaseLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { associatePrivatePractitionerWithCaseInteractor } from '@web-api/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor'; import { genericHandler } from '../../genericHandler'; export const associatePrivatePractitionerWithCaseLambda = ( @@ -6,13 +7,11 @@ export const associatePrivatePractitionerWithCaseLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .associatePrivatePractitionerWithCaseInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await associatePrivatePractitionerWithCaseInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/messages/completeMessageLambda.ts b/web-api/src/lambdas/messages/completeMessageLambda.ts index ec6c98805ef..51fdd6a40bf 100644 --- a/web-api/src/lambdas/messages/completeMessageLambda.ts +++ b/web-api/src/lambdas/messages/completeMessageLambda.ts @@ -1,5 +1,6 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { completeMessageInteractor } from '@web-api/business/useCases/messages/completeMessageInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -16,12 +17,10 @@ export const completeMessageLambda = (event, authorizedUser: UnknownAuthUser) => }: { applicationContext: ServerApplicationContext; }) => { - return await applicationContext - .getUseCases() - .completeMessageInteractor( - applicationContext, - JSON.parse(event.body), - authorizedUser, - ); + return await completeMessageInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); }, ); diff --git a/web-api/src/lambdas/messages/createMessageLambda.ts b/web-api/src/lambdas/messages/createMessageLambda.ts index b7c7a4aa777..4fc93bce9e5 100644 --- a/web-api/src/lambdas/messages/createMessageLambda.ts +++ b/web-api/src/lambdas/messages/createMessageLambda.ts @@ -1,9 +1,10 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { createMessageInteractor } from '@web-api/business/useCases/messages/createMessageInteractor'; import { genericHandler } from '../../genericHandler'; export const createMessageLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().createMessageInteractor( + return await createMessageInteractor( applicationContext, { ...JSON.parse(event.body), diff --git a/web-api/src/lambdas/messages/forwardMessageLambda.ts b/web-api/src/lambdas/messages/forwardMessageLambda.ts index 185dd22d2d9..6e200f14a7b 100644 --- a/web-api/src/lambdas/messages/forwardMessageLambda.ts +++ b/web-api/src/lambdas/messages/forwardMessageLambda.ts @@ -1,3 +1,4 @@ +import { forwardMessageInteractor } from '@web-api/business/useCases/messages/forwardMessageInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -8,10 +9,8 @@ import { genericHandler } from '../../genericHandler'; */ export const forwardMessageLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .forwardMessageInteractor(applicationContext, { - parentMessageId: event.pathParameters.parentMessageId, - ...JSON.parse(event.body), - }); + return await forwardMessageInteractor(applicationContext, { + parentMessageId: event.pathParameters.parentMessageId, + ...JSON.parse(event.body), + }); }); diff --git a/web-api/src/lambdas/messages/getCompletedMessagesForSectionLambda.ts b/web-api/src/lambdas/messages/getCompletedMessagesForSectionLambda.ts index cd836a37a23..4909a7ee9d8 100644 --- a/web-api/src/lambdas/messages/getCompletedMessagesForSectionLambda.ts +++ b/web-api/src/lambdas/messages/getCompletedMessagesForSectionLambda.ts @@ -12,16 +12,12 @@ export const getCompletedMessagesForSectionLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getCompletedMessagesForSectionInteractor( - applicationContext, - { - section: event.pathParameters.section, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getCompletedMessagesForSectionInteractor( + applicationContext, + { + section: event.pathParameters.section, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/messages/getCompletedMessagesForUserLambda.ts b/web-api/src/lambdas/messages/getCompletedMessagesForUserLambda.ts index 3474600460e..42ff75e10b0 100644 --- a/web-api/src/lambdas/messages/getCompletedMessagesForUserLambda.ts +++ b/web-api/src/lambdas/messages/getCompletedMessagesForUserLambda.ts @@ -1,18 +1,17 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCompletedMessagesForUserInteractor } from '@web-api/business/useCases/messages/getCompletedMessagesForUserInteractor'; export const getCompletedMessagesForUserLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCompletedMessagesForUserInteractor( - applicationContext, - { - userId: event.pathParameters.userId, - }, - authorizedUser, - ); + return await getCompletedMessagesForUserInteractor( + applicationContext, + { + userId: event.pathParameters.userId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/messages/getInboxMessagesForSectionLambda.ts b/web-api/src/lambdas/messages/getInboxMessagesForSectionLambda.ts index e13c01efeee..85743453539 100644 --- a/web-api/src/lambdas/messages/getInboxMessagesForSectionLambda.ts +++ b/web-api/src/lambdas/messages/getInboxMessagesForSectionLambda.ts @@ -1,18 +1,17 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getInboxMessagesForSectionInteractor } from '@web-api/business/useCases/messages/getInboxMessagesForSectionInteractor'; export const getInboxMessagesForSectionLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getInboxMessagesForSectionInteractor( - applicationContext, - { - section: event.pathParameters.section, - }, - authorizedUser, - ); + return await getInboxMessagesForSectionInteractor( + applicationContext, + { + section: event.pathParameters.section, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/messages/getInboxMessagesForUserLambda.ts b/web-api/src/lambdas/messages/getInboxMessagesForUserLambda.ts index 8d61dd48ee6..50e51b5eb25 100644 --- a/web-api/src/lambdas/messages/getInboxMessagesForUserLambda.ts +++ b/web-api/src/lambdas/messages/getInboxMessagesForUserLambda.ts @@ -1,18 +1,17 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getInboxMessagesForUserInteractor } from '@web-api/business/useCases/messages/getInboxMessagesForUserInteractor'; export const getInboxMessagesForUserLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getInboxMessagesForUserInteractor( - applicationContext, - { - userId: event.pathParameters.userId, - }, - authorizedUser, - ); + return await getInboxMessagesForUserInteractor( + applicationContext, + { + userId: event.pathParameters.userId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/messages/getMessageThreadLambda.ts b/web-api/src/lambdas/messages/getMessageThreadLambda.ts index c86d608756e..7faa339543a 100644 --- a/web-api/src/lambdas/messages/getMessageThreadLambda.ts +++ b/web-api/src/lambdas/messages/getMessageThreadLambda.ts @@ -1,12 +1,13 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getMessageThreadInteractor } from '@web-api/business/useCases/messages/getMessageThreadInteractor'; export const getMessageThreadLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().getMessageThreadInteractor( + return await getMessageThreadInteractor( applicationContext, { parentMessageId: event.pathParameters.parentMessageId, diff --git a/web-api/src/lambdas/messages/getMessagesForCaseLambda.ts b/web-api/src/lambdas/messages/getMessagesForCaseLambda.ts index 337eec7c549..a351b1e9de3 100644 --- a/web-api/src/lambdas/messages/getMessagesForCaseLambda.ts +++ b/web-api/src/lambdas/messages/getMessagesForCaseLambda.ts @@ -12,16 +12,12 @@ export const getMessagesForCaseLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getMessagesForCaseInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getMessagesForCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/messages/getOutboxMessagesForSectionLambda.ts b/web-api/src/lambdas/messages/getOutboxMessagesForSectionLambda.ts index a1de57152c6..af88876c689 100644 --- a/web-api/src/lambdas/messages/getOutboxMessagesForSectionLambda.ts +++ b/web-api/src/lambdas/messages/getOutboxMessagesForSectionLambda.ts @@ -1,18 +1,17 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getOutboxMessagesForSectionInteractor } from '@web-api/business/useCases/messages/getOutboxMessagesForSectionInteractor'; export const getOutboxMessagesForSectionLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getOutboxMessagesForSectionInteractor( - applicationContext, - { - section: event.pathParameters.section, - }, - authorizedUser, - ); + return await getOutboxMessagesForSectionInteractor( + applicationContext, + { + section: event.pathParameters.section, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/messages/getOutboxMessagesForUserLambda.ts b/web-api/src/lambdas/messages/getOutboxMessagesForUserLambda.ts index 432d0cf209f..a094131d53d 100644 --- a/web-api/src/lambdas/messages/getOutboxMessagesForUserLambda.ts +++ b/web-api/src/lambdas/messages/getOutboxMessagesForUserLambda.ts @@ -12,16 +12,12 @@ export const getOutboxMessagesForUserLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getOutboxMessagesForUserInteractor( - applicationContext, - { - userId: event.pathParameters.userId, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getOutboxMessagesForUserInteractor( + applicationContext, + { + userId: event.pathParameters.userId, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/notifications/connectLambda.ts b/web-api/src/lambdas/notifications/connectLambda.ts index 2bc410a702a..d0661cf3e62 100644 --- a/web-api/src/lambdas/notifications/connectLambda.ts +++ b/web-api/src/lambdas/notifications/connectLambda.ts @@ -30,6 +30,5 @@ export const connectLambda = (event, authorizedUser: UnknownAuthUser) => }, }); }, - authorizedUser, { bypassMaintenanceCheck: true }, ); diff --git a/web-api/src/lambdas/notifications/disconnectLambda.ts b/web-api/src/lambdas/notifications/disconnectLambda.ts index f46a5ff8540..7e6f38a6209 100644 --- a/web-api/src/lambdas/notifications/disconnectLambda.ts +++ b/web-api/src/lambdas/notifications/disconnectLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { onDisconnectInteractor } from '@web-api/business/useCases/notifications/onDisconnectInteractor'; /** * remove the information about an existing websocket connection @@ -10,11 +11,9 @@ export const disconnectLambda = event => genericHandler( event, async ({ applicationContext }) => { - const results = await applicationContext - .getUseCases() - .onDisconnectInteractor(applicationContext, { - connectionId: event.requestContext.connectionId, - }); + const results = await onDisconnectInteractor(applicationContext, { + connectionId: event.requestContext.connectionId, + }); applicationContext.logger.debug('Websocket disconnected', { requestId: { diff --git a/web-api/src/lambdas/practitioners/deletePractitionerDocumentLambda.ts b/web-api/src/lambdas/practitioners/deletePractitionerDocumentLambda.ts index 40a117bbb88..7097bee1d38 100644 --- a/web-api/src/lambdas/practitioners/deletePractitionerDocumentLambda.ts +++ b/web-api/src/lambdas/practitioners/deletePractitionerDocumentLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { deletePractitionerDocumentInteractor } from '@web-api/business/useCases/practitioner/deletePractitionerDocumentInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,15 +13,13 @@ export const deletePractitionerDocumentLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deletePractitionerDocumentInteractor( - applicationContext, - { - barNumber: event.pathParameters.barNumber, - practitionerDocumentFileId: - event.pathParameters.practitionerDocumentFileId, - }, - authorizedUser, - ); + return await deletePractitionerDocumentInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + practitionerDocumentFileId: + event.pathParameters.practitionerDocumentFileId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/practitioners/editPractitionerDocumentLambda.ts b/web-api/src/lambdas/practitioners/editPractitionerDocumentLambda.ts index 288d114e5e1..28a1c0c23c0 100644 --- a/web-api/src/lambdas/practitioners/editPractitionerDocumentLambda.ts +++ b/web-api/src/lambdas/practitioners/editPractitionerDocumentLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { editPractitionerDocumentInteractor } from '@web-api/business/useCases/practitioner/editPractitionerDocumentInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,14 +13,12 @@ export const editPractitionerDocumentLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .editPractitionerDocumentInteractor( - applicationContext, - { - barNumber: event.pathParameters.barNumber, - documentMetadata: JSON.parse(event.body), - }, - authorizedUser, - ); + return await editPractitionerDocumentInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + documentMetadata: JSON.parse(event.body), + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/practitioners/getPractitionerDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/practitioners/getPractitionerDocumentDownloadUrlLambda.ts index ab0014ebe0e..596eddec86f 100644 --- a/web-api/src/lambdas/practitioners/getPractitionerDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/practitioners/getPractitionerDocumentDownloadUrlLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getPractitionerDocumentDownloadUrlInteractor } from '@web-api/business/useCases/practitioner/getPractitionerDocumentDownloadUrlInteractor'; /** * Returns an upload url that allow the client to upload a practitioner document to an s3 bucket. @@ -12,15 +13,13 @@ export const getPractitionerDocumentDownloadUrlLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, ({ applicationContext }) => { - return applicationContext - .getUseCases() - .getPractitionerDocumentDownloadUrlInteractor( - applicationContext, - { - barNumber: event.pathParameters.barNumber, - practitionerDocumentFileId: - event.pathParameters.practitionerDocumentFileId, - }, - authorizedUser, - ); + return getPractitionerDocumentDownloadUrlInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + practitionerDocumentFileId: + event.pathParameters.practitionerDocumentFileId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/practitioners/getPractitionerDocumentLambda.ts b/web-api/src/lambdas/practitioners/getPractitionerDocumentLambda.ts index 57e8d76d619..8c6f2c75256 100644 --- a/web-api/src/lambdas/practitioners/getPractitionerDocumentLambda.ts +++ b/web-api/src/lambdas/practitioners/getPractitionerDocumentLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getPractitionerDocumentInteractor } from '@web-api/business/useCases/practitioner/getPractitionerDocumentInteractor'; /** * Returns a practitioner document @@ -6,9 +8,12 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getPractitionerDocumentLambda = (event, authorizedUser) => +export const getPractitionerDocumentLambda = ( + event, + authorizedUser: UnknownAuthUser, +): Promise => genericHandler(event, ({ applicationContext }) => { - return applicationContext.getUseCases().getPractitionerDocumentInteractor( + return getPractitionerDocumentInteractor( applicationContext, { barNumber: event.pathParameters.barNumber, diff --git a/web-api/src/lambdas/practitioners/getPractitionerDocumentsLambda.ts b/web-api/src/lambdas/practitioners/getPractitionerDocumentsLambda.ts index 3779f536b99..c2d9fc455d0 100644 --- a/web-api/src/lambdas/practitioners/getPractitionerDocumentsLambda.ts +++ b/web-api/src/lambdas/practitioners/getPractitionerDocumentsLambda.ts @@ -12,16 +12,12 @@ export const getPractitionerDocumentsLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getPractitionerDocumentsInteractor( - applicationContext, - { - barNumber: event.pathParameters.barNumber, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getPractitionerDocumentsInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/practitioners/getPractitionersByNameLambda.ts b/web-api/src/lambdas/practitioners/getPractitionersByNameLambda.ts index d5a6dde93f6..d62e227d34d 100644 --- a/web-api/src/lambdas/practitioners/getPractitionersByNameLambda.ts +++ b/web-api/src/lambdas/practitioners/getPractitionersByNameLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getPractitionersByNameInteractor } from '@web-api/business/useCases/practitioner/getPractitionersByNameInteractor'; /** * gets practitioner users by a search string (name or bar number) @@ -14,14 +15,12 @@ export const getPractitionersByNameLambda = ( genericHandler(event, async ({ applicationContext }) => { const { name, searchAfter } = event.queryStringParameters; - return await applicationContext - .getUseCases() - .getPractitionersByNameInteractor( - applicationContext, - { - name, - searchAfter, - }, - authorizedUser, - ); + return await getPractitionersByNameInteractor( + applicationContext, + { + name, + searchAfter, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/practitioners/updatePractitionerUserLambda.ts b/web-api/src/lambdas/practitioners/updatePractitionerUserLambda.ts index 92f93ff2213..9f5bbb91fb8 100644 --- a/web-api/src/lambdas/practitioners/updatePractitionerUserLambda.ts +++ b/web-api/src/lambdas/practitioners/updatePractitionerUserLambda.ts @@ -12,20 +12,16 @@ export const updatePractitionerUserLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { bypassDocketEntry = false, user } = JSON.parse(event.body); + genericHandler(event, async ({ applicationContext }) => { + const { bypassDocketEntry = false, user } = JSON.parse(event.body); - return await updatePractitionerUserInteractor( - applicationContext, - { - barNumber: event.pathParameters.barNumber, - bypassDocketEntry: bypassDocketEntry || false, - user, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await updatePractitionerUserInteractor( + applicationContext, + { + barNumber: event.pathParameters.barNumber, + bypassDocketEntry: bypassDocketEntry || false, + user, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/public-api/casePublicSearchLambda.ts b/web-api/src/lambdas/public-api/casePublicSearchLambda.ts index c95701d4f58..d8b54766004 100644 --- a/web-api/src/lambdas/public-api/casePublicSearchLambda.ts +++ b/web-api/src/lambdas/public-api/casePublicSearchLambda.ts @@ -1,3 +1,4 @@ +import { casePublicSearchInteractor } from '@web-api/business/useCases/public/casePublicSearchInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -8,9 +9,7 @@ import { genericHandler } from '../../genericHandler'; */ export const casePublicSearchLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .casePublicSearchInteractor(applicationContext, { - ...event.queryStringParameters, - }); + return await casePublicSearchInteractor(applicationContext, { + ...event.queryStringParameters, + }); }); diff --git a/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts b/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts index 3a35d56f3af..067259c9752 100644 --- a/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts +++ b/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts @@ -1,3 +1,5 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generateDocketRecordPdfInteractor } from '@web-api/business/useCases/generateDocketRecordPdfInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -6,16 +8,21 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const generatePublicDocketRecordPdfLambda = event => +export const generatePublicDocketRecordPdfLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .generateDocketRecordPdfInteractor(applicationContext, { + return await generateDocketRecordPdfInteractor( + applicationContext, + { ...JSON.parse(event.body), includePartyDetail: false, - }); + }, + authorizedUser, + ); }, { logResults: false }, ); diff --git a/web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts b/web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts index 9d2a6ac5782..d7ce5fada6f 100644 --- a/web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts +++ b/web-api/src/lambdas/public-api/getCaseForPublicDocketSearchLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getCaseForPublicDocketSearchInteractor } from '@web-api/business/useCases/public/getCaseForPublicDocketSearchInteractor'; /** * used for fetching a single case @@ -8,9 +9,7 @@ import { genericHandler } from '../../genericHandler'; */ export const getCaseForPublicDocketSearchLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCaseForPublicDocketSearchInteractor(applicationContext, { - docketNumber: event.pathParameters.docketNumber, - }); + return await getCaseForPublicDocketSearchInteractor(applicationContext, { + docketNumber: event.pathParameters.docketNumber, + }); }); diff --git a/web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts b/web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts index d2d7fa432f3..e340176cde0 100644 --- a/web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts +++ b/web-api/src/lambdas/public-api/getPublicCaseExistsLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getCaseExistsInteractor } from '@shared/business/useCases/getCaseExistsInteractor'; /** * used for fetching existence of a single case @@ -8,9 +9,7 @@ import { genericHandler } from '../../genericHandler'; */ export const getPublicCaseExistsLambda = event => genericHandler(event, ({ applicationContext }) => - applicationContext - .getUseCases() - .getCaseExistsInteractor(applicationContext, { - docketNumber: event.pathParameters.docketNumber, - }), + getCaseExistsInteractor(applicationContext, { + docketNumber: event.pathParameters.docketNumber, + }), ); diff --git a/web-api/src/lambdas/public-api/getPublicCaseLambda.ts b/web-api/src/lambdas/public-api/getPublicCaseLambda.ts index ff70c6981bd..8693a9d438d 100644 --- a/web-api/src/lambdas/public-api/getPublicCaseLambda.ts +++ b/web-api/src/lambdas/public-api/getPublicCaseLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getPublicCaseInteractor } from '@web-api/business/useCases/public/getPublicCaseInteractor'; /** * used for fetching a single case @@ -8,9 +9,7 @@ import { genericHandler } from '../../genericHandler'; */ export const getPublicCaseLambda = event => genericHandler(event, ({ applicationContext }) => - applicationContext - .getUseCases() - .getPublicCaseInteractor(applicationContext, { - docketNumber: event.pathParameters.docketNumber, - }), + getPublicCaseInteractor(applicationContext, { + docketNumber: event.pathParameters.docketNumber, + }), ); diff --git a/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts index 185a7240bf6..bf49c8efae3 100644 --- a/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/public-api/getPublicDocumentDownloadUrlLambda.ts @@ -1,5 +1,6 @@ -import { UnknownUserAuth } from '../../../shared/src/auth/UserAuthType'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getPublicDownloadPolicyUrlInteractor } from '@web-api/business/useCases/public/getPublicDownloadPolicyUrlInteractor'; /** * used for fetching a single case @@ -9,17 +10,15 @@ import { genericHandler } from '../../genericHandler'; */ export const getPublicDocumentDownloadUrlLambda = ( event, - authorizdeUser: UnknownUserAuth, + authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getPublicDownloadPolicyUrlInteractor( - applicationContext, - { - ...event.pathParameters, - isTerminalUser: event.isTerminalUser, - }, - authorizdeUser, - ); + return await getPublicDownloadPolicyUrlInteractor( + applicationContext, + { + ...event.pathParameters, + isTerminalUser: event.isTerminalUser, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts b/web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts index 043895b2a3c..574dac6e6d7 100644 --- a/web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts +++ b/web-api/src/lambdas/public-api/opinionPublicSearchLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { opinionPublicSearchInteractor } from '@web-api/business/useCases/public/opinionPublicSearchInteractor'; /** * used for fetching opinions matching the given filters @@ -11,10 +12,8 @@ export const opinionPublicSearchLambda = event => const opinionTypes = event.queryStringParameters.opinionTypes?.split(',') || []; - return await applicationContext - .getUseCases() - .opinionPublicSearchInteractor(applicationContext, { - ...event.queryStringParameters, - opinionTypes, - }); + return await opinionPublicSearchInteractor(applicationContext, { + ...event.queryStringParameters, + opinionTypes, + }); }); diff --git a/web-api/src/lambdas/public-api/orderPublicSearchLambda.ts b/web-api/src/lambdas/public-api/orderPublicSearchLambda.ts index 32c5983e3a6..d25db34f167 100644 --- a/web-api/src/lambdas/public-api/orderPublicSearchLambda.ts +++ b/web-api/src/lambdas/public-api/orderPublicSearchLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { orderPublicSearchInteractor } from '@web-api/business/useCases/public/orderPublicSearchInteractor'; /** * used for fetching orders matching the given a keyword @@ -8,9 +9,7 @@ import { genericHandler } from '../../genericHandler'; */ export const orderPublicSearchLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .orderPublicSearchInteractor(applicationContext, { - ...event.queryStringParameters, - }); + return await orderPublicSearchInteractor(applicationContext, { + ...event.queryStringParameters, + }); }); diff --git a/web-api/src/lambdas/public-api/todaysOpinionsLambda.ts b/web-api/src/lambdas/public-api/todaysOpinionsLambda.ts index 5b861f4b5d3..74c960f4c8d 100644 --- a/web-api/src/lambdas/public-api/todaysOpinionsLambda.ts +++ b/web-api/src/lambdas/public-api/todaysOpinionsLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getTodaysOpinionsInteractor } from '@web-api/business/useCases/public/getTodaysOpinionsInteractor'; /** * used for fetching opinions created for the current date @@ -8,7 +9,5 @@ import { genericHandler } from '../../genericHandler'; */ export const todaysOpinionsLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getTodaysOpinionsInteractor(applicationContext); + return await getTodaysOpinionsInteractor(applicationContext); }); diff --git a/web-api/src/lambdas/public-api/todaysOrdersLambda.ts b/web-api/src/lambdas/public-api/todaysOrdersLambda.ts index aeb093d36a0..8b36c922c6d 100644 --- a/web-api/src/lambdas/public-api/todaysOrdersLambda.ts +++ b/web-api/src/lambdas/public-api/todaysOrdersLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../../genericHandler'; +import { getTodaysOrdersInteractor } from '@web-api/business/useCases/public/getTodaysOrdersInteractor'; /** * used for fetching orders served on the current date @@ -8,7 +9,8 @@ import { genericHandler } from '../../genericHandler'; */ export const todaysOrdersLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getTodaysOrdersInteractor(applicationContext, event.pathParameters); + return await getTodaysOrdersInteractor( + applicationContext, + event.pathParameters, + ); }); diff --git a/web-api/src/lambdas/reports/coldCaseReportLambda.ts b/web-api/src/lambdas/reports/coldCaseReportLambda.ts index b118a6a93c9..d18a46bb017 100644 --- a/web-api/src/lambdas/reports/coldCaseReportLambda.ts +++ b/web-api/src/lambdas/reports/coldCaseReportLambda.ts @@ -3,10 +3,6 @@ import { coldCaseReportInteractor } from '@web-api/business/useCases/reports/col import { genericHandler } from '../../genericHandler'; export const coldCaseReportLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await coldCaseReportInteractor(applicationContext, authorizedUser); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await coldCaseReportInteractor(applicationContext, authorizedUser); + }); diff --git a/web-api/src/lambdas/reports/createCsvCustomCaseReportFileLambda.ts b/web-api/src/lambdas/reports/createCsvCustomCaseReportFileLambda.ts index eb075a1fc4f..e9037608cb2 100644 --- a/web-api/src/lambdas/reports/createCsvCustomCaseReportFileLambda.ts +++ b/web-api/src/lambdas/reports/createCsvCustomCaseReportFileLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { createCsvCustomCaseReportFileInteractor } from '@web-api/business/useCases/customCaseReport/createCsvCustomCaseReportFileInteractor'; import { genericHandler } from '../../genericHandler'; export const createCsvCustomCaseReportFileLambda = ( @@ -6,11 +7,9 @@ export const createCsvCustomCaseReportFileLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .createCsvCustomCaseReportFileInteractor( - applicationContext, - JSON.parse(event.body), - authorizedUser, - ); + return await createCsvCustomCaseReportFileInteractor( + applicationContext, + JSON.parse(event.body), + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/reports/generatePrintableCaseInventoryReportLambda.ts b/web-api/src/lambdas/reports/generatePrintableCaseInventoryReportLambda.ts index da01072c8e0..824847455b4 100644 --- a/web-api/src/lambdas/reports/generatePrintableCaseInventoryReportLambda.ts +++ b/web-api/src/lambdas/reports/generatePrintableCaseInventoryReportLambda.ts @@ -23,6 +23,5 @@ export const generatePrintableCaseInventoryReportLambda = ( authorizedUser, ); }, - authorizedUser, { logResults: false }, ); diff --git a/web-api/src/lambdas/reports/getBlockedCasesLambda.ts b/web-api/src/lambdas/reports/getBlockedCasesLambda.ts index 2313a1fbe8e..fc20016f80b 100644 --- a/web-api/src/lambdas/reports/getBlockedCasesLambda.ts +++ b/web-api/src/lambdas/reports/getBlockedCasesLambda.ts @@ -9,16 +9,12 @@ import { getBlockedCasesInteractor } from '@shared/business/useCases/getBlockedC * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getBlockedCasesLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getBlockedCasesInteractor( - applicationContext, - { - trialLocation: event.pathParameters.trialLocation, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getBlockedCasesInteractor( + applicationContext, + { + trialLocation: event.pathParameters.trialLocation, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts b/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts index a50a66f80e7..456fea0d8b5 100644 --- a/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts +++ b/web-api/src/lambdas/reports/getCaseInventoryReportLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCaseInventoryReportInteractor } from '@web-api/business/useCases/caseInventoryReport/getCaseInventoryReportInteractor'; /** * used for fetching the case inventory report data @@ -12,13 +13,11 @@ export const getCaseInventoryReportLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCaseInventoryReportInteractor( - applicationContext, - { - ...event.queryStringParameters, - }, - authorizedUser, - ); + return await getCaseInventoryReportInteractor( + applicationContext, + { + ...event.queryStringParameters, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/reports/getCaseWorksheetsByJudgeLambda.ts b/web-api/src/lambdas/reports/getCaseWorksheetsByJudgeLambda.ts index c4801ad2c22..1d3b5c33043 100644 --- a/web-api/src/lambdas/reports/getCaseWorksheetsByJudgeLambda.ts +++ b/web-api/src/lambdas/reports/getCaseWorksheetsByJudgeLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCaseWorksheetsByJudgeInteractor } from '@web-api/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor'; export const getCaseWorksheetsByJudgeLambda = ( event, @@ -9,13 +10,11 @@ export const getCaseWorksheetsByJudgeLambda = ( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCaseWorksheetsByJudgeInteractor( - applicationContext, - event.queryStringParameters, - authorizedUser, - ); + return await getCaseWorksheetsByJudgeInteractor( + applicationContext, + event.queryStringParameters, + authorizedUser, + ); }, { logResults: false }, ); diff --git a/web-api/src/lambdas/reports/getCasesClosedByJudgeLambda.ts b/web-api/src/lambdas/reports/getCasesClosedByJudgeLambda.ts index aeeff0bd5ca..204daab14de 100644 --- a/web-api/src/lambdas/reports/getCasesClosedByJudgeLambda.ts +++ b/web-api/src/lambdas/reports/getCasesClosedByJudgeLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCasesClosedByJudgeInteractor } from '@web-api/business/useCases/judgeActivityReport/getCasesClosedByJudgeInteractor'; export const getCasesClosedByJudgeLambda = ( event, @@ -8,15 +9,13 @@ export const getCasesClosedByJudgeLambda = ( genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCasesClosedByJudgeInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await getCasesClosedByJudgeInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); diff --git a/web-api/src/lambdas/reports/getCountOfCaseDocumentsFiledByJudgesLambda.ts b/web-api/src/lambdas/reports/getCountOfCaseDocumentsFiledByJudgesLambda.ts index 3ea5a3a817e..a466e05747c 100644 --- a/web-api/src/lambdas/reports/getCountOfCaseDocumentsFiledByJudgesLambda.ts +++ b/web-api/src/lambdas/reports/getCountOfCaseDocumentsFiledByJudgesLambda.ts @@ -1,16 +1,15 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCountOfCaseDocumentsFiledByJudgesInteractor } from '@web-api/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor'; export const getCountOfCaseDocumentsFiledByJudgesLambda = ( event, authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getCountOfCaseDocumentsFiledByJudgesInteractor( - applicationContext, - event.queryStringParameters, - authorizedUser, - ); + return await getCountOfCaseDocumentsFiledByJudgesInteractor( + applicationContext, + event.queryStringParameters, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/reports/getTrialSessionsForJudgeActivityReportLambda.ts b/web-api/src/lambdas/reports/getTrialSessionsForJudgeActivityReportLambda.ts index 0c073275544..d3b1491a5f0 100644 --- a/web-api/src/lambdas/reports/getTrialSessionsForJudgeActivityReportLambda.ts +++ b/web-api/src/lambdas/reports/getTrialSessionsForJudgeActivityReportLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getTrialSessionsForJudgeActivityReportInteractor } from '@web-api/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor'; export const getTrialSessionsForJudgeActivityReportLambda = ( event, @@ -8,15 +9,13 @@ export const getTrialSessionsForJudgeActivityReportLambda = ( genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getTrialSessionsForJudgeActivityReportInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await getTrialSessionsForJudgeActivityReportInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); diff --git a/web-api/src/lambdas/trialSessions/batchDownloadTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/batchDownloadTrialSessionLambda.ts index fe9408b39e6..cbdb7317a15 100644 --- a/web-api/src/lambdas/trialSessions/batchDownloadTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/batchDownloadTrialSessionLambda.ts @@ -12,18 +12,14 @@ export const batchDownloadTrialSessionLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { trialSessionId } = event.pathParameters || event.path; + genericHandler(event, async ({ applicationContext }) => { + const { trialSessionId } = event.pathParameters || event.path; - return await batchDownloadTrialSessionInteractor( - applicationContext, - { - trialSessionId, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await batchDownloadTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/trialSessions/closeTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/closeTrialSessionLambda.ts index 182940644cc..51ba0394fd9 100644 --- a/web-api/src/lambdas/trialSessions/closeTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/closeTrialSessionLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { closeTrialSessionInteractor } from '@web-api/business/useCases/trialSessions/closeTrialSessionInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -14,7 +15,7 @@ export const closeTrialSessionLambda = ( genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; - return await applicationContext.getUseCases().closeTrialSessionInteractor( + return await closeTrialSessionInteractor( applicationContext, { trialSessionId, diff --git a/web-api/src/lambdas/trialSessions/createTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/createTrialSessionLambda.ts index 07b36fc2520..ce141309ed0 100644 --- a/web-api/src/lambdas/trialSessions/createTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/createTrialSessionLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { createTrialSessionInteractor } from '@web-api/business/useCases/trialSessions/createTrialSessionInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,7 +13,7 @@ export const createTrialSessionLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().createTrialSessionInteractor( + return await createTrialSessionInteractor( applicationContext, { trialSession: JSON.parse(event.body), diff --git a/web-api/src/lambdas/trialSessions/deleteTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/deleteTrialSessionLambda.ts index af67e0a4caa..02d1433f10c 100644 --- a/web-api/src/lambdas/trialSessions/deleteTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/deleteTrialSessionLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { deleteTrialSessionInteractor } from '@web-api/business/useCases/trialSessions/deleteTrialSessionInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -14,7 +15,7 @@ export const deleteTrialSessionLambda = ( genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; - return await applicationContext.getUseCases().deleteTrialSessionInteractor( + return await deleteTrialSessionInteractor( applicationContext, { trialSessionId, diff --git a/web-api/src/lambdas/trialSessions/generateTrialCalendarPdfLambda.ts b/web-api/src/lambdas/trialSessions/generateTrialCalendarPdfLambda.ts index 18366eb7cef..fa2cb16552f 100644 --- a/web-api/src/lambdas/trialSessions/generateTrialCalendarPdfLambda.ts +++ b/web-api/src/lambdas/trialSessions/generateTrialCalendarPdfLambda.ts @@ -1,3 +1,4 @@ +import { generateTrialCalendarPdfInteractor } from '@web-api/business/useCases/trialSessions/generateTrialCalendarPdfInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,11 +13,9 @@ export const generateTrialCalendarPdfLambda = event => async ({ applicationContext }) => { const { trialSessionId } = JSON.parse(event.body); - return await applicationContext - .getUseCases() - .generateTrialCalendarPdfInteractor(applicationContext, { - trialSessionId, - }); + return await generateTrialCalendarPdfInteractor(applicationContext, { + trialSessionId, + }); }, { logResults: false }, ); diff --git a/web-api/src/lambdas/trialSessions/getCalendaredCasesForTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/getCalendaredCasesForTrialSessionLambda.ts index af93e721ac5..db8286b9218 100644 --- a/web-api/src/lambdas/trialSessions/getCalendaredCasesForTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/getCalendaredCasesForTrialSessionLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getCalendaredCasesForTrialSessionInteractor } from '@web-api/business/useCases/trialSessions/getCalendaredCasesForTrialSessionInteractor'; /** * get cases calendared on a trial session @@ -14,13 +15,11 @@ export const getCalendaredCasesForTrialSessionLambda = ( genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .getCalendaredCasesForTrialSessionInteractor( - applicationContext, - { - trialSessionId, - }, - authorizedUser, - ); + return await getCalendaredCasesForTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/trialSessions/getEligibleCasesForTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/getEligibleCasesForTrialSessionLambda.ts index 85457b0dadb..7730f9edb92 100644 --- a/web-api/src/lambdas/trialSessions/getEligibleCasesForTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/getEligibleCasesForTrialSessionLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getEligibleCasesForTrialSessionInteractor } from '@web-api/business/useCases/trialSessions/getEligibleCasesForTrialSessionInteractor'; /** * get eligible cases for trial session @@ -14,13 +15,11 @@ export const getEligibleCasesForTrialSessionLambda = ( genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .getEligibleCasesForTrialSessionInteractor( - applicationContext, - { - trialSessionId, - }, - authorizedUser, - ); + return await getEligibleCasesForTrialSessionInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/trialSessions/getGeneratePrintableTrialSessionCopyReportLambda.ts b/web-api/src/lambdas/trialSessions/getGeneratePrintableTrialSessionCopyReportLambda.ts index b210e453351..51c07c05c16 100644 --- a/web-api/src/lambdas/trialSessions/getGeneratePrintableTrialSessionCopyReportLambda.ts +++ b/web-api/src/lambdas/trialSessions/getGeneratePrintableTrialSessionCopyReportLambda.ts @@ -12,23 +12,19 @@ export const getGeneratePrintableTrialSessionCopyReportLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const body = JSON.parse(event.body); - return await generatePrintableTrialSessionCopyReportInteractor( - applicationContext, - { - filters: body.filters, - formattedCases: body.formattedCases, - formattedTrialSession: body.formattedTrialSession, - sessionNotes: body.sessionNotes, - showCaseNotes: body.showCaseNotes, - sort: body.sort, - userHeading: body.userHeading, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + const body = JSON.parse(event.body); + return await generatePrintableTrialSessionCopyReportInteractor( + applicationContext, + { + filters: body.filters, + formattedCases: body.formattedCases, + formattedTrialSession: body.formattedTrialSession, + sessionNotes: body.sessionNotes, + showCaseNotes: body.showCaseNotes, + sort: body.sort, + userHeading: body.userHeading, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts b/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts index d5bde74eb13..efd8aed1bc2 100644 --- a/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts +++ b/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts @@ -16,6 +16,5 @@ export const getPaperServicePdfUrlLambda = ( authorizedUser, ); }, - authorizedUser, { logResults: false }, ); diff --git a/web-api/src/lambdas/trialSessions/getTrialSessionDetailsLambda.ts b/web-api/src/lambdas/trialSessions/getTrialSessionDetailsLambda.ts index 7d98ac52fdf..6b92235d009 100644 --- a/web-api/src/lambdas/trialSessions/getTrialSessionDetailsLambda.ts +++ b/web-api/src/lambdas/trialSessions/getTrialSessionDetailsLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getTrialSessionDetailsInteractor } from '@web-api/business/useCases/trialSessions/getTrialSessionDetailsInteractor'; /** * gets trial session details @@ -14,13 +15,11 @@ export const getTrialSessionDetailsLambda = ( genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .getTrialSessionDetailsInteractor( - applicationContext, - { - trialSessionId, - }, - authorizedUser, - ); + return await getTrialSessionDetailsInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/trialSessions/getTrialSessionWorkingCopyLambda.ts b/web-api/src/lambdas/trialSessions/getTrialSessionWorkingCopyLambda.ts index df8f4524ca9..060abc2f821 100644 --- a/web-api/src/lambdas/trialSessions/getTrialSessionWorkingCopyLambda.ts +++ b/web-api/src/lambdas/trialSessions/getTrialSessionWorkingCopyLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getTrialSessionWorkingCopyInteractor } from '@web-api/business/useCases/trialSessions/getTrialSessionWorkingCopyInteractor'; /** * get a judge's working copy of a trial session @@ -14,13 +15,11 @@ export const getTrialSessionWorkingCopyLambda = ( genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .getTrialSessionWorkingCopyInteractor( - applicationContext, - { - trialSessionId, - }, - authorizedUser, - ); + return await getTrialSessionWorkingCopyInteractor( + applicationContext, + { + trialSessionId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/trialSessions/getTrialSessionsForJudgeLambda.ts b/web-api/src/lambdas/trialSessions/getTrialSessionsForJudgeLambda.ts index 69f4d67faed..c48051eea35 100644 --- a/web-api/src/lambdas/trialSessions/getTrialSessionsForJudgeLambda.ts +++ b/web-api/src/lambdas/trialSessions/getTrialSessionsForJudgeLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getTrialSessionsForJudgeInteractor } from '@web-api/business/useCases/trialSessions/getTrialSessionsForJudgeInteractor'; /** * gets all trial sessions for a judge @@ -12,11 +13,9 @@ export const getTrialSessionsForJudgeLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getTrialSessionsForJudgeInteractor( - applicationContext, - event.pathParameters.judgeId, - authorizedUser, - ); + return await getTrialSessionsForJudgeInteractor( + applicationContext, + event.pathParameters.judgeId, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts b/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts index 5c34971e717..c86f6e4e898 100644 --- a/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts +++ b/web-api/src/lambdas/trialSessions/getTrialSessionsLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getTrialSessionsInteractor } from '@web-api/business/useCases/trialSessions/getTrialSessionsInteractor'; /** * gets all trial sessions @@ -13,7 +14,5 @@ export const getTrialSessionsLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getTrialSessionsInteractor(applicationContext, authorizedUser); + return await getTrialSessionsInteractor(applicationContext, authorizedUser); }); diff --git a/web-api/src/lambdas/trialSessions/removeCaseFromTrialLambda.ts b/web-api/src/lambdas/trialSessions/removeCaseFromTrialLambda.ts index cc28b4c0eeb..07895a08989 100644 --- a/web-api/src/lambdas/trialSessions/removeCaseFromTrialLambda.ts +++ b/web-api/src/lambdas/trialSessions/removeCaseFromTrialLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { removeCaseFromTrialInteractor } from '@web-api/business/useCases/trialSessions/removeCaseFromTrialInteractor'; /** * used for setting a case on a trial session to removedFromTrial @@ -6,20 +8,25 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const removeCaseFromTrialLambda = event => +export const removeCaseFromTrialLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { const { docketNumber, trialSessionId } = event.pathParameters || event.path; const { associatedJudge, associatedJudgeId, caseStatus, disposition } = JSON.parse(event.body); - return await applicationContext - .getUseCases() - .removeCaseFromTrialInteractor(applicationContext, { + return await removeCaseFromTrialInteractor( + applicationContext, + { associatedJudge, associatedJudgeId, caseStatus, disposition, docketNumber, trialSessionId, - }); + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/trialSessions/runTrialSessionPlanningReportLambda.ts b/web-api/src/lambdas/trialSessions/runTrialSessionPlanningReportLambda.ts index 7ce22fbe88b..df8a347d28e 100644 --- a/web-api/src/lambdas/trialSessions/runTrialSessionPlanningReportLambda.ts +++ b/web-api/src/lambdas/trialSessions/runTrialSessionPlanningReportLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { runTrialSessionPlanningReportInteractor } from '@web-api/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor'; /** * run the trial session planning report @@ -14,15 +15,13 @@ export const runTrialSessionPlanningReportLambda = ( genericHandler( event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .runTrialSessionPlanningReportInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); + return await runTrialSessionPlanningReportInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); }, { logResults: false }, ); diff --git a/web-api/src/lambdas/trialSessions/saveCalendarNoteLambda.ts b/web-api/src/lambdas/trialSessions/saveCalendarNoteLambda.ts index eef2656dba0..468914a60d3 100644 --- a/web-api/src/lambdas/trialSessions/saveCalendarNoteLambda.ts +++ b/web-api/src/lambdas/trialSessions/saveCalendarNoteLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { saveCalendarNoteInteractor } from '@web-api/business/useCases/trialSessions/saveCalendarNoteInteractor'; /** * used for saving a case's calendar note for a trial session @@ -17,7 +18,7 @@ export const saveCalendarNoteLambda = ( ...JSON.parse(event.body), }; - return await applicationContext.getUseCases().saveCalendarNoteInteractor( + return await saveCalendarNoteInteractor( applicationContext, { ...lambdaArguments, diff --git a/web-api/src/lambdas/trialSessions/serveThirtyDayNoticeLambda.ts b/web-api/src/lambdas/trialSessions/serveThirtyDayNoticeLambda.ts index 9ba8f450705..68d6d304b4f 100644 --- a/web-api/src/lambdas/trialSessions/serveThirtyDayNoticeLambda.ts +++ b/web-api/src/lambdas/trialSessions/serveThirtyDayNoticeLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { serveThirtyDayNoticeInteractor } from '@web-api/business/useCases/trialSessions/serveThirtyDayNoticeInteractor'; export const serveThirtyDayNoticeLambda = ( event, @@ -7,14 +8,12 @@ export const serveThirtyDayNoticeLambda = ( ) => genericHandler(event, async ({ applicationContext }) => { const { clientConnectionId, trialSessionId } = JSON.parse(event.body); - return await applicationContext - .getUseCases() - .serveThirtyDayNoticeInteractor( - applicationContext, - { - clientConnectionId, - trialSessionId, - }, - authorizedUser, - ); + return await serveThirtyDayNoticeInteractor( + applicationContext, + { + clientConnectionId, + trialSessionId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/trialSessions/setForHearingLambda.ts b/web-api/src/lambdas/trialSessions/setForHearingLambda.ts index a0b8801a3a3..37d1fe7951c 100644 --- a/web-api/src/lambdas/trialSessions/setForHearingLambda.ts +++ b/web-api/src/lambdas/trialSessions/setForHearingLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { setForHearingInteractor } from '@web-api/business/useCases/trialSessions/setForHearingInteractor'; /** * creates a new trial session. @@ -13,7 +14,7 @@ export const setForHearingLambda = (event, authorizedUser: UnknownAuthUser) => event.pathParameters || event.path || {}; const { calendarNotes } = JSON.parse(event.body); - return await applicationContext.getUseCases().setForHearingInteractor( + return await setForHearingInteractor( applicationContext, { calendarNotes, diff --git a/web-api/src/lambdas/trialSessions/setNoticesForCalendaredTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/setNoticesForCalendaredTrialSessionLambda.ts index 141d4f29952..147b209e131 100644 --- a/web-api/src/lambdas/trialSessions/setNoticesForCalendaredTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/setNoticesForCalendaredTrialSessionLambda.ts @@ -12,19 +12,15 @@ export const setNoticesForCalendaredTrialSessionLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { trialSessionId } = event.pathParameters || event.path || {}; + genericHandler(event, async ({ applicationContext }) => { + const { trialSessionId } = event.pathParameters || event.path || {}; - return await setNoticesForCalendaredTrialSessionInteractor( - applicationContext, - { - ...JSON.parse(event.body), - trialSessionId, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await setNoticesForCalendaredTrialSessionInteractor( + applicationContext, + { + ...JSON.parse(event.body), + trialSessionId, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/trialSessions/setTrialSessionCalendarLambda.ts b/web-api/src/lambdas/trialSessions/setTrialSessionCalendarLambda.ts index a7400a82044..e50743186e2 100644 --- a/web-api/src/lambdas/trialSessions/setTrialSessionCalendarLambda.ts +++ b/web-api/src/lambdas/trialSessions/setTrialSessionCalendarLambda.ts @@ -1,4 +1,6 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { setTrialSessionCalendarInteractor } from '@web-api/business/useCases/trialSessions/setTrialSessionCalendarInteractor'; /** * set trial session calendar @@ -6,14 +8,19 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const setTrialSessionCalendarLambda = event => +export const setTrialSessionCalendarLambda = ( + event, + authorizedUser: UnknownAuthUser, +): Promise => genericHandler(event, async ({ applicationContext }) => { const { trialSessionId } = event.pathParameters || {}; - return await applicationContext - .getUseCases() - .setTrialSessionCalendarInteractor(applicationContext, { + return await setTrialSessionCalendarInteractor( + applicationContext, + { ...JSON.parse(event.body), trialSessionId, - }); + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/trialSessions/updateTrialSessionLambda.ts b/web-api/src/lambdas/trialSessions/updateTrialSessionLambda.ts index b25af5ffa42..f292cbadc9d 100644 --- a/web-api/src/lambdas/trialSessions/updateTrialSessionLambda.ts +++ b/web-api/src/lambdas/trialSessions/updateTrialSessionLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateTrialSessionInteractor } from '@web-api/business/useCases/trialSessions/updateTrialSessionInteractor'; /** * updates a trial session. @@ -11,7 +12,7 @@ export const updateTrialSessionLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().updateTrialSessionInteractor( + return await updateTrialSessionInteractor( applicationContext, { ...JSON.parse(event.body), diff --git a/web-api/src/lambdas/trialSessions/updateTrialSessionWorkingCopyLambda.ts b/web-api/src/lambdas/trialSessions/updateTrialSessionWorkingCopyLambda.ts index 01386d8f843..712c37f75b7 100644 --- a/web-api/src/lambdas/trialSessions/updateTrialSessionWorkingCopyLambda.ts +++ b/web-api/src/lambdas/trialSessions/updateTrialSessionWorkingCopyLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateTrialSessionWorkingCopyInteractor } from '@web-api/business/useCases/trialSessions/updateTrialSessionWorkingCopyInteractor'; /** * update a judge's working copy of a trial session @@ -12,13 +13,11 @@ export const updateTrialSessionWorkingCopyLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .updateTrialSessionWorkingCopyInteractor( - applicationContext, - { - trialSessionWorkingCopyToUpdate: JSON.parse(event.body), - }, - authorizedUser, - ); + return await updateTrialSessionWorkingCopyInteractor( + applicationContext, + { + trialSessionWorkingCopyToUpdate: JSON.parse(event.body), + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/users/checkEmailAvailabilityLambda.ts b/web-api/src/lambdas/users/checkEmailAvailabilityLambda.ts index 5f202d67111..a288a601b10 100644 --- a/web-api/src/lambdas/users/checkEmailAvailabilityLambda.ts +++ b/web-api/src/lambdas/users/checkEmailAvailabilityLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { checkEmailAvailabilityInteractor } from '@web-api/business/useCases/user/checkEmailAvailabilityInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -14,13 +15,11 @@ export const checkEmailAvailabilityLambda = ( genericHandler(event, async ({ applicationContext }) => { const { email } = event.queryStringParameters; - return await applicationContext - .getUseCases() - .checkEmailAvailabilityInteractor( - applicationContext, - { - email, - }, - authorizedUser, - ); + return await checkEmailAvailabilityInteractor( + applicationContext, + { + email, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/users/getAllUsersByRoleLambda.ts b/web-api/src/lambdas/users/getAllUsersByRoleLambda.ts index 30dafa9c255..4bd8490891f 100644 --- a/web-api/src/lambdas/users/getAllUsersByRoleLambda.ts +++ b/web-api/src/lambdas/users/getAllUsersByRoleLambda.ts @@ -15,7 +15,6 @@ export const getAllUsersByRoleLambda = ( authorizedUser, ); }, - authorizedUser, { bypassMaintenanceCheck: true, }, diff --git a/web-api/src/lambdas/users/getInternalUsersLambda.ts b/web-api/src/lambdas/users/getInternalUsersLambda.ts index 4a077987b37..28fe31ce72d 100644 --- a/web-api/src/lambdas/users/getInternalUsersLambda.ts +++ b/web-api/src/lambdas/users/getInternalUsersLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getInternalUsersInteractor } from '@web-api/business/useCases/user/getInternalUsersInteractor'; /** * creates a new document and attaches it to a case. It also creates a work item on the docket section. @@ -12,7 +13,5 @@ export const getInternalUsersLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getInternalUsersInteractor(applicationContext, authorizedUser); + return await getInternalUsersInteractor(applicationContext, authorizedUser); }); diff --git a/web-api/src/lambdas/users/getIrsPractitionersBySearchKeyLambda.ts b/web-api/src/lambdas/users/getIrsPractitionersBySearchKeyLambda.ts index 371df8a2b61..59b7fdc5cc6 100644 --- a/web-api/src/lambdas/users/getIrsPractitionersBySearchKeyLambda.ts +++ b/web-api/src/lambdas/users/getIrsPractitionersBySearchKeyLambda.ts @@ -12,18 +12,14 @@ export const getIrsPractitionersBySearchKeyLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { searchKey } = event.queryStringParameters; + genericHandler(event, async ({ applicationContext }) => { + const { searchKey } = event.queryStringParameters; - return await getIrsPractitionersBySearchKeyInteractor( - applicationContext, - { - searchKey, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await getIrsPractitionersBySearchKeyInteractor( + applicationContext, + { + searchKey, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/users/getJudgeInSectionLambda.ts b/web-api/src/lambdas/users/getJudgeInSectionLambda.ts index a9242df3f40..cb5a6e5a7bd 100644 --- a/web-api/src/lambdas/users/getJudgeInSectionLambda.ts +++ b/web-api/src/lambdas/users/getJudgeInSectionLambda.ts @@ -6,16 +6,12 @@ export const getJudgeInSectionLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getJudgeInSectionInteractor( - applicationContext, - { - section: event.pathParameters.section, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getJudgeInSectionInteractor( + applicationContext, + { + section: event.pathParameters.section, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/users/getNotificationsLambda.ts b/web-api/src/lambdas/users/getNotificationsLambda.ts index 693a3883ef4..78e1d7b7f86 100644 --- a/web-api/src/lambdas/users/getNotificationsLambda.ts +++ b/web-api/src/lambdas/users/getNotificationsLambda.ts @@ -12,16 +12,12 @@ export const getNotificationsLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getNotificationsInteractor( - applicationContext, - { - ...event.queryStringParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getNotificationsInteractor( + applicationContext, + { + ...event.queryStringParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/users/getPrivatePractitionersBySearchKeyLambda.ts b/web-api/src/lambdas/users/getPrivatePractitionersBySearchKeyLambda.ts index 3514f865fc6..325bace2ce7 100644 --- a/web-api/src/lambdas/users/getPrivatePractitionersBySearchKeyLambda.ts +++ b/web-api/src/lambdas/users/getPrivatePractitionersBySearchKeyLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getPrivatePractitionersBySearchKeyInteractor } from '@web-api/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor'; /** * gets practitioner users by a search string (name or bar number) @@ -14,13 +15,11 @@ export const getPrivatePractitionersBySearchKeyLambda = ( genericHandler(event, async ({ applicationContext }) => { const { searchKey } = event.queryStringParameters; - return await applicationContext - .getUseCases() - .getPrivatePractitionersBySearchKeyInteractor( - applicationContext, - { - searchKey, - }, - authorizedUser, - ); + return await getPrivatePractitionersBySearchKeyInteractor( + applicationContext, + { + searchKey, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/users/getUserLambda.ts b/web-api/src/lambdas/users/getUserLambda.ts index 41324a7d8f3..148f19ba020 100644 --- a/web-api/src/lambdas/users/getUserLambda.ts +++ b/web-api/src/lambdas/users/getUserLambda.ts @@ -14,7 +14,6 @@ export const getUserLambda = (event, authorizedUser: UnknownAuthUser) => async ({ applicationContext }) => { return await getUserInteractor(applicationContext, authorizedUser); }, - authorizedUser, { bypassMaintenanceCheck: true, }, diff --git a/web-api/src/lambdas/users/getUserPendingEmailLambda.ts b/web-api/src/lambdas/users/getUserPendingEmailLambda.ts index f014bfdc447..24568e3741c 100644 --- a/web-api/src/lambdas/users/getUserPendingEmailLambda.ts +++ b/web-api/src/lambdas/users/getUserPendingEmailLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getUserPendingEmailInteractor } from '@web-api/business/useCases/user/getUserPendingEmailInteractor'; /** * gets the user pending email @@ -12,7 +13,7 @@ export const getUserPendingEmailLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().getUserPendingEmailInteractor( + return await getUserPendingEmailInteractor( applicationContext, { userId: event.pathParameters.userId, diff --git a/web-api/src/lambdas/users/getUserPendingEmailStatusLambda.ts b/web-api/src/lambdas/users/getUserPendingEmailStatusLambda.ts index e195196c1ec..7276d89efa4 100644 --- a/web-api/src/lambdas/users/getUserPendingEmailStatusLambda.ts +++ b/web-api/src/lambdas/users/getUserPendingEmailStatusLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getUserPendingEmailStatusInteractor } from '@web-api/business/useCases/user/getUserPendingEmailStatusInteractor'; /** * gets the user pending email @@ -12,13 +13,11 @@ export const getUserPendingEmailStatusLambda = ( authorizedUser: UnknownAuthUser, ) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .getUserPendingEmailStatusInteractor( - applicationContext, - { - userId: event.pathParameters.userId, - }, - authorizedUser, - ); + return await getUserPendingEmailStatusInteractor( + applicationContext, + { + userId: event.pathParameters.userId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/users/getUsersInSectionLambda.ts b/web-api/src/lambdas/users/getUsersInSectionLambda.ts index 92b083e4726..eeab5421042 100644 --- a/web-api/src/lambdas/users/getUsersInSectionLambda.ts +++ b/web-api/src/lambdas/users/getUsersInSectionLambda.ts @@ -12,18 +12,14 @@ export const getUsersInSectionLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { section } = event.pathParameters || {}; + genericHandler(event, async ({ applicationContext }) => { + const { section } = event.pathParameters || {}; - return await getUsersInSectionInteractor( - applicationContext, - { - section, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await getUsersInSectionInteractor( + applicationContext, + { + section, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/users/getUsersPendingEmailLambda.ts b/web-api/src/lambdas/users/getUsersPendingEmailLambda.ts index cd4f3839111..24ed344ff22 100644 --- a/web-api/src/lambdas/users/getUsersPendingEmailLambda.ts +++ b/web-api/src/lambdas/users/getUsersPendingEmailLambda.ts @@ -13,18 +13,14 @@ export const getUsersPendingEmailLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const userIds = event.queryStringParameters.userIds?.split(',') || []; + genericHandler(event, async ({ applicationContext }) => { + const userIds = event.queryStringParameters.userIds?.split(',') || []; - return await getUsersPendingEmailInteractor( - applicationContext, - { - userIds, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await getUsersPendingEmailInteractor( + applicationContext, + { + userIds, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/users/updateUserContactInformationLambda.ts b/web-api/src/lambdas/users/updateUserContactInformationLambda.ts index f2fe62132d6..30c9af574a6 100644 --- a/web-api/src/lambdas/users/updateUserContactInformationLambda.ts +++ b/web-api/src/lambdas/users/updateUserContactInformationLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { updateUserContactInformationInteractor } from '@web-api/business/useCases/user/updateUserContactInformationInteractor'; /** * updates the user contact info (used for a privatePractitioner or irsPractitioner) @@ -13,15 +14,13 @@ export const updateUserContactInformationLambda = ( ) => genericHandler(event, async ({ applicationContext }) => { const { contactInfo, firmName } = JSON.parse(event.body); - return await applicationContext - .getUseCases() - .updateUserContactInformationInteractor( - applicationContext, - { - contactInfo, - firmName, - userId: (event.pathParameters || event.path).userId, - }, - authorizedUser, - ); + return await updateUserContactInformationInteractor( + applicationContext, + { + contactInfo, + firmName, + userId: (event.pathParameters || event.path).userId, + }, + authorizedUser, + ); }); diff --git a/web-api/src/lambdas/users/updateUserPendingEmailLambda.ts b/web-api/src/lambdas/users/updateUserPendingEmailLambda.ts index 2d2c52603ed..f3527edbee9 100644 --- a/web-api/src/lambdas/users/updateUserPendingEmailLambda.ts +++ b/web-api/src/lambdas/users/updateUserPendingEmailLambda.ts @@ -12,16 +12,12 @@ export const updateUserPendingEmailLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await updateUserPendingEmailInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await updateUserPendingEmailInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/users/verifyUserPendingEmailLambda.ts b/web-api/src/lambdas/users/verifyUserPendingEmailLambda.ts index 4806d00fb46..9fd74ae8b9f 100644 --- a/web-api/src/lambdas/users/verifyUserPendingEmailLambda.ts +++ b/web-api/src/lambdas/users/verifyUserPendingEmailLambda.ts @@ -12,16 +12,12 @@ export const verifyUserPendingEmailLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await verifyUserPendingEmailInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await verifyUserPendingEmailInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/v1/getCaseLambda.ts b/web-api/src/lambdas/v1/getCaseLambda.ts index c3a06ba8592..3ef21f65757 100644 --- a/web-api/src/lambdas/v1/getCaseLambda.ts +++ b/web-api/src/lambdas/v1/getCaseLambda.ts @@ -30,6 +30,5 @@ export const getCaseLambda = ( return marshallCase(caseObject); }), - authorizedUser, options, ); diff --git a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts index 14296395b2c..125aa0df7ad 100644 --- a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts @@ -31,6 +31,5 @@ export const getDocumentDownloadUrlLambda = ( return marshallDocumentDownloadUrl(urlObject); }); }, - authorizedUser, options, ); diff --git a/web-api/src/lambdas/v2/getCaseLambda.ts b/web-api/src/lambdas/v2/getCaseLambda.ts index 9670df29113..8ed790ce512 100644 --- a/web-api/src/lambdas/v2/getCaseLambda.ts +++ b/web-api/src/lambdas/v2/getCaseLambda.ts @@ -30,6 +30,5 @@ export const getCaseLambda = ( return marshallCase(caseObject); }), - authorizedUser, options, ); diff --git a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts index 7cef537b032..686eb2951df 100644 --- a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts @@ -31,6 +31,5 @@ export const getDocumentDownloadUrlLambda = ( return marshallDocumentDownloadUrl(urlObject); }); }, - authorizedUser, options, ); diff --git a/web-api/src/lambdas/v2/getReconciliationReportLambda.ts b/web-api/src/lambdas/v2/getReconciliationReportLambda.ts index 4a80cc25114..5c8b71a3f49 100644 --- a/web-api/src/lambdas/v2/getReconciliationReportLambda.ts +++ b/web-api/src/lambdas/v2/getReconciliationReportLambda.ts @@ -33,6 +33,5 @@ export const getReconciliationReportLambda = ( return report; }); }, - authorizedUser, options, ); diff --git a/web-api/src/lambdas/workitems/assignWorkItemsLambda.ts b/web-api/src/lambdas/workitems/assignWorkItemsLambda.ts index ba6672e50bd..2881d284ef2 100644 --- a/web-api/src/lambdas/workitems/assignWorkItemsLambda.ts +++ b/web-api/src/lambdas/workitems/assignWorkItemsLambda.ts @@ -9,16 +9,12 @@ import { genericHandler } from '../../genericHandler'; * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const assignWorkItemsLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await assignWorkItemsInteractor( - applicationContext, - { - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await assignWorkItemsInteractor( + applicationContext, + { + ...JSON.parse(event.body), + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/workitems/completeWorkItemLambda.ts b/web-api/src/lambdas/workitems/completeWorkItemLambda.ts index eb8c8db3d96..a3691543264 100644 --- a/web-api/src/lambdas/workitems/completeWorkItemLambda.ts +++ b/web-api/src/lambdas/workitems/completeWorkItemLambda.ts @@ -12,17 +12,13 @@ export const completeWorkItemLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await completeWorkItemInteractor( - applicationContext, - { - completedMessage: JSON.parse(event.body).completedMessage, - workItemId: event.pathParameters.workItemId, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await completeWorkItemInteractor( + applicationContext, + { + completedMessage: JSON.parse(event.body).completedMessage, + workItemId: event.pathParameters.workItemId, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/workitems/getDocumentQCInboxForSectionLambda.ts b/web-api/src/lambdas/workitems/getDocumentQCInboxForSectionLambda.ts index 36bb773c9ad..668c7719021 100644 --- a/web-api/src/lambdas/workitems/getDocumentQCInboxForSectionLambda.ts +++ b/web-api/src/lambdas/workitems/getDocumentQCInboxForSectionLambda.ts @@ -12,19 +12,15 @@ export const getDocumentQCInboxForSectionLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { section } = event.pathParameters || {}; + genericHandler(event, async ({ applicationContext }) => { + const { section } = event.pathParameters || {}; - return await getDocumentQCInboxForSectionInteractor( - applicationContext, - { - section, - ...event.queryStringParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await getDocumentQCInboxForSectionInteractor( + applicationContext, + { + section, + ...event.queryStringParameters, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/workitems/getDocumentQCInboxForUserLambda.ts b/web-api/src/lambdas/workitems/getDocumentQCInboxForUserLambda.ts index b5e6e175974..31651f93776 100644 --- a/web-api/src/lambdas/workitems/getDocumentQCInboxForUserLambda.ts +++ b/web-api/src/lambdas/workitems/getDocumentQCInboxForUserLambda.ts @@ -12,18 +12,14 @@ export const getDocumentQCInboxForUserLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { userId } = event.pathParameters || {}; + genericHandler(event, async ({ applicationContext }) => { + const { userId } = event.pathParameters || {}; - return await getDocumentQCInboxForUserInteractor( - applicationContext, - { - userId, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await getDocumentQCInboxForUserInteractor( + applicationContext, + { + userId, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/workitems/getDocumentQCServedForSectionLambda.ts b/web-api/src/lambdas/workitems/getDocumentQCServedForSectionLambda.ts index dffaedd0ff6..ed144580a37 100644 --- a/web-api/src/lambdas/workitems/getDocumentQCServedForSectionLambda.ts +++ b/web-api/src/lambdas/workitems/getDocumentQCServedForSectionLambda.ts @@ -12,17 +12,13 @@ export const getDocumentQCServedForSectionLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { section } = event.pathParameters || {}; - return await getDocumentQCServedForSectionInteractor( - applicationContext, - { - section, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + const { section } = event.pathParameters || {}; + return await getDocumentQCServedForSectionInteractor( + applicationContext, + { + section, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/workitems/getDocumentQCServedForUserLambda.ts b/web-api/src/lambdas/workitems/getDocumentQCServedForUserLambda.ts index 3b88d56d889..1e6f12b2433 100644 --- a/web-api/src/lambdas/workitems/getDocumentQCServedForUserLambda.ts +++ b/web-api/src/lambdas/workitems/getDocumentQCServedForUserLambda.ts @@ -12,18 +12,14 @@ export const getDocumentQCServedForUserLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { userId } = event.pathParameters || {}; + genericHandler(event, async ({ applicationContext }) => { + const { userId } = event.pathParameters || {}; - return await getDocumentQCServedForUserInteractor( - applicationContext, - { - userId, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await getDocumentQCServedForUserInteractor( + applicationContext, + { + userId, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/workitems/getWorkItemLambda.ts b/web-api/src/lambdas/workitems/getWorkItemLambda.ts index 96e1d10465c..766a17109d5 100644 --- a/web-api/src/lambdas/workitems/getWorkItemLambda.ts +++ b/web-api/src/lambdas/workitems/getWorkItemLambda.ts @@ -9,16 +9,12 @@ import { getWorkItemInteractor } from '@web-api/business/useCases/workItems/getW * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getWorkItemLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( - event, - async ({ applicationContext }) => { - return await getWorkItemInteractor( - applicationContext, - { - workItemId: event.pathParameters.workItemId, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await getWorkItemInteractor( + applicationContext, + { + workItemId: event.pathParameters.workItemId, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/lambdas/workitems/setWorkItemAsReadLambda.ts b/web-api/src/lambdas/workitems/setWorkItemAsReadLambda.ts index 5a922d4e847..1a9a1bbd177 100644 --- a/web-api/src/lambdas/workitems/setWorkItemAsReadLambda.ts +++ b/web-api/src/lambdas/workitems/setWorkItemAsReadLambda.ts @@ -12,18 +12,14 @@ export const setWorkItemAsReadLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - const { workItemId } = event.pathParameters || {}; + genericHandler(event, async ({ applicationContext }) => { + const { workItemId } = event.pathParameters || {}; - return await setWorkItemAsReadInteractor( - applicationContext, - { - workItemId, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + return await setWorkItemAsReadInteractor( + applicationContext, + { + workItemId, + }, + authorizedUser, + ); + }); diff --git a/web-api/src/users/signUpUserLambda.ts b/web-api/src/users/signUpUserLambda.ts index 471bf13eabe..afd63568fcf 100644 --- a/web-api/src/users/signUpUserLambda.ts +++ b/web-api/src/users/signUpUserLambda.ts @@ -1,4 +1,5 @@ import { genericHandler } from '../genericHandler'; +import { signUpUserInteractor } from '@web-api/business/useCases/auth/signUpUserInteractor'; /** * creates a new user locally @@ -7,9 +8,7 @@ import { genericHandler } from '../genericHandler'; */ export const signUpUserLambda = event => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .signUpUserInteractor(applicationContext, { - user: JSON.parse(event.body), - }); + return await signUpUserInteractor(applicationContext, { + user: JSON.parse(event.body), + }); }); From 364e7e8d76386bb7fabafcd0c8f18bc5ffa956fe Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 24 Jul 2024 11:02:37 -0700 Subject: [PATCH 377/523] 10417: rm options as an argument from lambdas as it is unused except for in tests. --- docs/remove-get-current-user.md | 1 - web-api/src/lambdas/v1/getCaseLambda.ts | 32 +++++++------------ .../v1/getDocumentDownloadUrlLambda.ts | 30 +++++++---------- web-api/src/lambdas/v2/getCaseLambda.ts | 32 +++++++------------ .../v2/getDocumentDownloadUrlLambda.ts | 30 +++++++---------- .../v2/getReconciliationReportLambda.ts | 32 ++++++++----------- 6 files changed, 61 insertions(+), 96 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index b10741d88f5..9af9b478bdf 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -5,7 +5,6 @@ # TODO - Go back to all // TODO 10417 - Look at validateRawCollection() -- Look at all references of genericHandler to make sure authorizedUser is being passed in. - check instances of `handleLockError` (or `OnLockError`) - Look at all new Case and new DocketEntry diff --git a/web-api/src/lambdas/v1/getCaseLambda.ts b/web-api/src/lambdas/v1/getCaseLambda.ts index 3ef21f65757..40f23e03b6f 100644 --- a/web-api/src/lambdas/v1/getCaseLambda.ts +++ b/web-api/src/lambdas/v1/getCaseLambda.ts @@ -8,27 +8,19 @@ import { v1ApiWrapper } from './v1ApiWrapper'; * used for fetching a single case and returning it in v1 api format * * @param {object} event the AWS event object - * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCaseLambda = ( - event, - authorizedUser: UnknownAuthUser, - options, -) => - genericHandler( - event, - ({ applicationContext }) => - v1ApiWrapper(async () => { - const caseObject = await getCaseInteractor( - applicationContext, - { - docketNumber: event.pathParameters.docketNumber, - }, - authorizedUser, - ); +export const getCaseLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler(event, ({ applicationContext }) => + v1ApiWrapper(async () => { + const caseObject = await getCaseInteractor( + applicationContext, + { + docketNumber: event.pathParameters.docketNumber, + }, + authorizedUser, + ); - return marshallCase(caseObject); - }), - options, + return marshallCase(caseObject); + }), ); diff --git a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts index 125aa0df7ad..7599daf9e95 100644 --- a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.ts @@ -8,28 +8,22 @@ import { v1ApiWrapper } from './v1ApiWrapper'; * used for getting the download policy which is needed for consumers to download files directly from S3 * * @param {object} event the AWS event object - * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getDocumentDownloadUrlLambda = ( event, authorizedUser: UnknownAuthUser, - options = {}, ) => - genericHandler( - event, - ({ applicationContext }) => { - return v1ApiWrapper(async () => { - const urlObject = await getDownloadPolicyUrlInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); + genericHandler(event, ({ applicationContext }) => { + return v1ApiWrapper(async () => { + const urlObject = await getDownloadPolicyUrlInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); - return marshallDocumentDownloadUrl(urlObject); - }); - }, - options, - ); + return marshallDocumentDownloadUrl(urlObject); + }); + }); diff --git a/web-api/src/lambdas/v2/getCaseLambda.ts b/web-api/src/lambdas/v2/getCaseLambda.ts index 8ed790ce512..8040bd54d28 100644 --- a/web-api/src/lambdas/v2/getCaseLambda.ts +++ b/web-api/src/lambdas/v2/getCaseLambda.ts @@ -8,27 +8,19 @@ import { v2ApiWrapper } from './v2ApiWrapper'; * used for fetching a single case and returning it in v1 api format * * @param {object} event the AWS event object - * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const getCaseLambda = ( - event, - authorizedUser: UnknownAuthUser, - options, // TODO 10417 Remove all instances of passing in options via lambda params -) => - genericHandler( - event, - ({ applicationContext }) => - v2ApiWrapper(async () => { - const caseObject = await getCaseInteractor( - applicationContext, - { - docketNumber: event.pathParameters.docketNumber, - }, - authorizedUser, - ); +export const getCaseLambda = (event, authorizedUser: UnknownAuthUser) => + genericHandler(event, ({ applicationContext }) => + v2ApiWrapper(async () => { + const caseObject = await getCaseInteractor( + applicationContext, + { + docketNumber: event.pathParameters.docketNumber, + }, + authorizedUser, + ); - return marshallCase(caseObject); - }), - options, + return marshallCase(caseObject); + }), ); diff --git a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts index 686eb2951df..687b2244a8d 100644 --- a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts +++ b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.ts @@ -8,28 +8,22 @@ import { v2ApiWrapper } from './v2ApiWrapper'; * used for getting the download policy which is needed for consumers to download files directly from S3 * * @param {object} event the AWS event object - * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ export const getDocumentDownloadUrlLambda = ( event, authorizedUser: UnknownAuthUser, - options = {}, ) => - genericHandler( - event, - ({ applicationContext }) => { - return v2ApiWrapper(async () => { - const urlObject = await getDownloadPolicyUrlInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); + genericHandler(event, ({ applicationContext }) => { + return v2ApiWrapper(async () => { + const urlObject = await getDownloadPolicyUrlInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); - return marshallDocumentDownloadUrl(urlObject); - }); - }, - options, - ); + return marshallDocumentDownloadUrl(urlObject); + }); + }); diff --git a/web-api/src/lambdas/v2/getReconciliationReportLambda.ts b/web-api/src/lambdas/v2/getReconciliationReportLambda.ts index 5c8b71a3f49..4a48ec36a13 100644 --- a/web-api/src/lambdas/v2/getReconciliationReportLambda.ts +++ b/web-api/src/lambdas/v2/getReconciliationReportLambda.ts @@ -9,29 +9,23 @@ import { v2ApiWrapper } from './v2ApiWrapper'; * day (12:00am-11:59:59pm ET) * * @param {object} event the AWS event object - * @param {object} options options to optionally pass to the genericHandler * @returns {Promise<*|undefined>} the api gateway response object containing the reconciliation report */ export const getReconciliationReportLambda = ( event, authorizedUser: UnknownAuthUser, - options = {}, ) => - genericHandler( - event, - ({ applicationContext }) => { - return v2ApiWrapper(async () => { - const { end, start } = event.queryStringParameters; - //url will contain the reconciliation date in path parameters, and times in the query string - const parms = { ...event.pathParameters, end, start }; - const report = await getReconciliationReportInteractor( - applicationContext, - parms, - authorizedUser, - ); + genericHandler(event, ({ applicationContext }) => { + return v2ApiWrapper(async () => { + const { end, start } = event.queryStringParameters; + //url will contain the reconciliation date in path parameters, and times in the query string + const parms = { ...event.pathParameters, end, start }; + const report = await getReconciliationReportInteractor( + applicationContext, + parms, + authorizedUser, + ); - return report; - }); - }, - options, - ); + return report; + }); + }); From b7c6743a33ac103128f765720f199c4519e46b4b Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 24 Jul 2024 16:09:56 -0500 Subject: [PATCH 378/523] 10417: connectLambda gets its own user --- web-api/src/lambdas/notifications/connectLambda.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web-api/src/lambdas/notifications/connectLambda.ts b/web-api/src/lambdas/notifications/connectLambda.ts index d0661cf3e62..de304c11eaa 100644 --- a/web-api/src/lambdas/notifications/connectLambda.ts +++ b/web-api/src/lambdas/notifications/connectLambda.ts @@ -1,5 +1,6 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; +import { getUserFromAuthHeader } from '@web-api/middleware/apiGatewayHelper'; import { onConnectInteractor } from '@web-api/business/useCases/notifications/onConnectInteractor'; /** @@ -8,8 +9,11 @@ import { onConnectInteractor } from '@web-api/business/useCases/notifications/on * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const connectLambda = (event, authorizedUser: UnknownAuthUser) => - genericHandler( +// TODO 10417 This lambda was causing issues locally (and presumably also would deployed, given how it's a standalone lambda). +// Current approach solves it, but is this what we want to do? +export const connectLambda = event => { + const authorizedUser: UnknownAuthUser = getUserFromAuthHeader(event); + return genericHandler( event, async ({ applicationContext, clientConnectionId }) => { const endpoint = event.requestContext.domainName; @@ -32,3 +36,4 @@ export const connectLambda = (event, authorizedUser: UnknownAuthUser) => }, { bypassMaintenanceCheck: true }, ); +}; From 6c1e90c80a39c28f6b024ed3967a1ebe593c640c Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 24 Jul 2024 15:29:04 -0700 Subject: [PATCH 379/523] 10417: rm getCurrentUser --- .../validateDocumentInteractor.test.ts | 38 +++++++++++-------- .../useCases/validateDocumentInteractor.ts | 5 ++- .../validateDocumentAction.ts | 10 +++-- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/shared/src/business/useCases/validateDocumentInteractor.test.ts b/shared/src/business/useCases/validateDocumentInteractor.test.ts index e83d5927889..c002f02ec57 100644 --- a/shared/src/business/useCases/validateDocumentInteractor.test.ts +++ b/shared/src/business/useCases/validateDocumentInteractor.test.ts @@ -1,30 +1,36 @@ import { ROLES } from '../entities/EntityConstants'; -import { applicationContext } from '../test/createTestApplicationContext'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { validateDocumentInteractor } from './validateDocumentInteractor'; describe('validateDocumentInteractor', () => { it('returns the expected errors object on an empty docket record', () => { - const errors = validateDocumentInteractor(applicationContext, { - document: {}, - }); + const errors = validateDocumentInteractor( + { + document: {}, + }, + mockDocketClerkUser, + ); expect(Object.keys(errors!).length).toBeGreaterThan(0); }); it('returns null when there are no errors', () => { - const result = validateDocumentInteractor(applicationContext, { - document: { - docketNumber: '101-21', - documentTitle: 'Administrative Record', - documentType: 'Administrative Record', - eventCode: 'ADMR', - filedBy: 'Test User', - filedByRole: ROLES.docketClerk, - filingDate: '2020-01-01T02:04:06.007Z', - index: '1', - userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', + const result = validateDocumentInteractor( + { + document: { + docketNumber: '101-21', + documentTitle: 'Administrative Record', + documentType: 'Administrative Record', + eventCode: 'ADMR', + filedBy: 'Test User', + filedByRole: ROLES.docketClerk, + filingDate: '2020-01-01T02:04:06.007Z', + index: '1', + userId: '3ab77c88-1dd0-4adb-a03c-c466ad72d417', + }, }, - }); + mockDocketClerkUser, + ); expect(result).toEqual(null); }); diff --git a/shared/src/business/useCases/validateDocumentInteractor.ts b/shared/src/business/useCases/validateDocumentInteractor.ts index 19bf5233e43..7b3d7ca12f1 100644 --- a/shared/src/business/useCases/validateDocumentInteractor.ts +++ b/shared/src/business/useCases/validateDocumentInteractor.ts @@ -1,4 +1,5 @@ import { DocketEntry } from '../entities/DocketEntry'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; /** * validateDocumentInteractor @@ -9,11 +10,11 @@ import { DocketEntry } from '../entities/DocketEntry'; * @returns {object} the validation errors or null */ export const validateDocumentInteractor = ( - applicationContext: IApplicationContext, { document }: { document: any }, + authorizedUser: UnknownAuthUser, ) => { const errors = new DocketEntry(document, { - authorizedUser: applicationContext.getCurrentser(), + authorizedUser, }).getFormattedValidationErrors(); return errors || null; diff --git a/web-client/src/presenter/actions/EditDocketRecordEntry/validateDocumentAction.ts b/web-client/src/presenter/actions/EditDocketRecordEntry/validateDocumentAction.ts index 74b5d39af13..2e0e5912e05 100644 --- a/web-client/src/presenter/actions/EditDocketRecordEntry/validateDocumentAction.ts +++ b/web-client/src/presenter/actions/EditDocketRecordEntry/validateDocumentAction.ts @@ -16,12 +16,14 @@ export const validateDocumentAction = ({ }: ActionProps) => { const formMetadata = get(state.form); const editType = get(state.screenMetadata.editType); // Document, CourtIssued, NoDocument + const authorizedUser = get(state.user); - let errors = applicationContext - .getUseCases() - .validateDocumentInteractor(applicationContext, { + let errors = applicationContext.getUseCases().validateDocumentInteractor( + { document: formMetadata, - }); + }, + authorizedUser, + ); let errorDisplayOrder = ['description', 'eventCode', 'filingDate', 'index']; From faa9b7a1df87b42feb7d416e4873bfdc9b0c93ce Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 24 Jul 2024 15:57:41 -0700 Subject: [PATCH 380/523] 10417: Update failing test to look at full authorized user --- .../authorizationClientService.test.ts | 115 +++++------------- .../src/business/utilities/caseFilter.test.ts | 39 +++--- shared/src/business/utilities/caseFilter.ts | 3 +- 3 files changed, 54 insertions(+), 103 deletions(-) diff --git a/shared/src/authorization/authorizationClientService.test.ts b/shared/src/authorization/authorizationClientService.test.ts index f4a1f12c677..c0abcc6fd31 100644 --- a/shared/src/authorization/authorizationClientService.test.ts +++ b/shared/src/authorization/authorizationClientService.test.ts @@ -3,30 +3,32 @@ import { ROLE_PERMISSIONS, isAuthorized, } from './authorizationClientService'; -import { ROLES } from '../business/entities/EntityConstants'; +import { + mockAdcUser, + mockCaseServicesSupervisorUser, + mockChambersUser, + mockDocketClerkUser, + mockIrsPractitionerUser, + mockJudgeUser, + mockPetitionerUser, + mockPetitionsClerkUser, +} from '@shared/test/mockAuthUsers'; describe('Authorization client service', () => { it('should return false when the user is undefined', () => { - expect(isAuthorized(undefined, 'unknown action', 'someUser')).toBeFalsy(); + expect( + isAuthorized(undefined, 'unknown action' as any, 'someUser'), + ).toBeFalsy(); }); it('should return true for any user whose userId matches the 3rd owner argument, in this case "someUser" === "someUser"', () => { expect( - isAuthorized( - { role: ROLES.petitioner, userId: 'someUser' }, - 'unknown action', - 'someUser', - ), + isAuthorized(mockPetitionerUser, 'unknown action' as any, 'someUser'), ).toBeTruthy(); }); it('should return false when the role provided is not found in the AUTHORIZATION_MAP', () => { - expect( - isAuthorized( - { role: 'NOT_A_ROLE', userId: 'judgebuch' }, - ROLE_PERMISSIONS.WORKITEM, - ), - ).toBe(false); + expect(isAuthorized(mockJudgeUser, ROLE_PERMISSIONS.WORKITEM)).toBe(false); }); it('should contain NO falsy values in the AUTHORIZATION_MAP', () => { @@ -39,20 +41,12 @@ describe('Authorization client service', () => { describe('adc role', () => { it('should be authorized for the WORK_ITEM permission', () => { - expect( - isAuthorized( - { role: ROLES.adc, userId: 'adc' }, - ROLE_PERMISSIONS.WORKITEM, - ), - ).toBeTruthy(); + expect(isAuthorized(mockAdcUser, ROLE_PERMISSIONS.WORKITEM)).toBeTruthy(); }); it('should be authorized to stamp a motion', () => { expect( - isAuthorized( - { role: ROLES.adc, userId: 'adc' }, - ROLE_PERMISSIONS.STAMP_MOTION, - ), + isAuthorized(mockAdcUser, ROLE_PERMISSIONS.STAMP_MOTION), ).toBeTruthy(); }); }); @@ -60,10 +54,7 @@ describe('Authorization client service', () => { describe('chambers role', () => { it('should be authorized to stamp a motion', () => { expect( - isAuthorized( - { role: ROLES.chambers, userId: 'chambers1' }, - ROLE_PERMISSIONS.STAMP_MOTION, - ), + isAuthorized(mockChambersUser, ROLE_PERMISSIONS.STAMP_MOTION), ).toBeTruthy(); }); }); @@ -72,19 +63,13 @@ describe('Authorization client service', () => { it('should be authorized to perform both docket clerk and petitions clerk specific actions', () => { expect( isAuthorized( - { - role: ROLES.caseServicesSupervisor, - userId: 'caseServicesSupervisor1', - }, + mockCaseServicesSupervisorUser, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS, ), ).toBeTruthy(); expect( isAuthorized( - { - role: ROLES.caseServicesSupervisor, - userId: 'caseServicesSupervisor1', - }, + mockCaseServicesSupervisorUser, ROLE_PERMISSIONS.QC_PETITION, ), ).toBeTruthy(); @@ -94,37 +79,25 @@ describe('Authorization client service', () => { describe('docketClerk role', () => { it('should be authorized for the WORK_ITEM permission', () => { expect( - isAuthorized( - { role: ROLES.docketClerk, userId: 'docketclerk' }, - ROLE_PERMISSIONS.WORKITEM, - ), + isAuthorized(mockDocketClerkUser, ROLE_PERMISSIONS.WORKITEM), ).toBeTruthy(); }); it('should be authorized to seal an address', () => { expect( - isAuthorized( - { role: ROLES.docketClerk, userId: 'docketclerk' }, - ROLE_PERMISSIONS.SEAL_ADDRESS, - ), + isAuthorized(mockDocketClerkUser, ROLE_PERMISSIONS.SEAL_ADDRESS), ).toBeTruthy(); }); it('should be authorized to perform track items operations', () => { expect( - isAuthorized( - { role: ROLES.docketClerk, userId: 'docketclerk' }, - ROLE_PERMISSIONS.TRACKED_ITEMS, - ), + isAuthorized(mockDocketClerkUser, ROLE_PERMISSIONS.TRACKED_ITEMS), ).toBeTruthy(); }); it('should be authorized to update a case', () => { expect( - isAuthorized( - { role: ROLES.docketClerk, userId: 'docketclerk' }, - ROLE_PERMISSIONS.UPDATE_CASE, - ), + isAuthorized(mockDocketClerkUser, ROLE_PERMISSIONS.UPDATE_CASE), ).toBeTruthy(); }); }); @@ -132,10 +105,7 @@ describe('Authorization client service', () => { describe('irsPractitioner', () => { it('should be authorized to get a case', () => { expect( - isAuthorized( - { role: ROLES.irsPractitioner, userId: 'irsPractitioner' }, - ROLE_PERMISSIONS.GET_CASE, - ), + isAuthorized(mockIrsPractitionerUser, ROLE_PERMISSIONS.GET_CASE), ).toBeTruthy(); }); }); @@ -143,10 +113,7 @@ describe('Authorization client service', () => { describe('judge role', () => { it('should be authorized to stamp a motion', () => { expect( - isAuthorized( - { role: ROLES.judge, userId: 'judgebuch' }, - ROLE_PERMISSIONS.STAMP_MOTION, - ), + isAuthorized(mockJudgeUser, ROLE_PERMISSIONS.STAMP_MOTION), ).toBeTruthy(); }); }); @@ -154,55 +121,37 @@ describe('Authorization client service', () => { describe('petitionsClerk role', () => { it('should be authorized to get a case', () => { expect( - isAuthorized( - { role: ROLES.petitionsClerk, userId: 'petitionsclerk' }, - ROLE_PERMISSIONS.GET_CASE, - ), + isAuthorized(mockPetitionsClerkUser, ROLE_PERMISSIONS.GET_CASE), ).toBeTruthy(); }); it('should be authorized to perform track items operations', () => { expect( - isAuthorized( - { role: ROLES.docketClerk, userId: 'docketclerk' }, - ROLE_PERMISSIONS.TRACKED_ITEMS, - ), + isAuthorized(mockDocketClerkUser, ROLE_PERMISSIONS.TRACKED_ITEMS), ).toBeTruthy(); }); it('should be authorized for the WORK_ITEM permission', () => { expect( - isAuthorized( - { role: ROLES.petitionsClerk, userId: 'petitionsclerk' }, - ROLE_PERMISSIONS.WORKITEM, - ), + isAuthorized(mockPetitionsClerkUser, ROLE_PERMISSIONS.WORKITEM), ).toBeTruthy(); }); it('should be authorized to start a case from paper', () => { expect( - isAuthorized( - { role: ROLES.petitionsClerk, userId: 'petitionsclerk' }, - ROLE_PERMISSIONS.START_PAPER_CASE, - ), + isAuthorized(mockPetitionsClerkUser, ROLE_PERMISSIONS.START_PAPER_CASE), ).toBeTruthy(); }); it('should be authorized to serve a petition', () => { expect( - isAuthorized( - { role: ROLES.petitionsClerk, userId: 'petitionsclerk' }, - ROLE_PERMISSIONS.SERVE_PETITION, - ), + isAuthorized(mockPetitionsClerkUser, ROLE_PERMISSIONS.SERVE_PETITION), ).toBeTruthy(); }); it('should be authorized to seal a docket entry', () => { expect( - isAuthorized( - { role: ROLES.docketClerk, userId: 'docketclerk' }, - ROLE_PERMISSIONS.SEAL_DOCKET_ENTRY, - ), + isAuthorized(mockDocketClerkUser, ROLE_PERMISSIONS.SEAL_DOCKET_ENTRY), ).toBeTruthy(); }); }); diff --git a/shared/src/business/utilities/caseFilter.test.ts b/shared/src/business/utilities/caseFilter.test.ts index 23e6e3734de..8e659bbadbf 100644 --- a/shared/src/business/utilities/caseFilter.test.ts +++ b/shared/src/business/utilities/caseFilter.test.ts @@ -8,6 +8,12 @@ import { caseSealedFormatter, caseSearchFilter, } from './caseFilter'; +import { + mockIrsPractitionerUser, + mockIrsSuperuser, + mockPetitionsClerkUser, + mockPrivatePractitionerUser, +} from '@shared/test/mockAuthUsers'; describe('caseFilter', () => { it('should format sealed cases to preserve ONLY attributes appearing in a whitelist', () => { @@ -167,10 +173,10 @@ describe('caseFilter', () => { ]; it('should remove sealed cases from a set of advanced search results', () => { - const result = caseSearchFilter(caseSearchResults, { - role: ROLES.irsPractitioner, - userId: '0e69052d-b59d-496e-ba2a-39af3a9535dc', - }); + const result = caseSearchFilter( + caseSearchResults, + mockIrsPractitionerUser, + ); expect(result).toMatchObject([ { @@ -184,10 +190,7 @@ describe('caseFilter', () => { }); it('should format sealed addresses in search results if user does not have permission to see sealed contact addresses', () => { - let result = caseSearchFilter(caseSearchResults, { - role: ROLES.petitionsClerk, - userId: 'petitionsClerk', - }); + let result = caseSearchFilter(caseSearchResults, mockPetitionsClerkUser); expect(result.length).toEqual(4); expect(result[2].petitioners[0]).toMatchObject({ @@ -198,31 +201,27 @@ describe('caseFilter', () => { }); it('should keep sealed cases in search results if user is an internal user with permission to see sealed cases', () => { - let result = caseSearchFilter(caseSearchResults, { - role: ROLES.petitionsClerk, - userId: 'petitionsClerk', - }); + let result = caseSearchFilter(caseSearchResults, mockPetitionsClerkUser); expect(result.length).toEqual(4); }); it('should keep sealed cases in search results if user is an IRS superuser with permission to see sealed cases', () => { - let result = caseSearchFilter(caseSearchResults, { - role: ROLES.irsSuperuser, - userId: 'irsSuperuser', - }); + let result = caseSearchFilter(caseSearchResults, mockIrsSuperuser); expect(result.length).toEqual(4); }); it('should keep sealed cases in search results if user is associated as practitioner or respondent', () => { let result = caseSearchFilter(caseSearchResults, { + ...mockPrivatePractitionerUser, userId: 'authPractitioner', }); expect(result.length).toEqual(4); result = caseSearchFilter(caseSearchResults, { + ...mockPrivatePractitionerUser, userId: 'authRespondent', }); @@ -230,9 +229,10 @@ describe('caseFilter', () => { }); it('should filter out sealed documents in search results when the user is not associated with the case', () => { - const result = caseSearchFilter(documentSearchResults, { - userId: 'unassociatedPractitioner', - }); + const result = caseSearchFilter( + documentSearchResults, + mockPrivatePractitionerUser, + ); expect(result.length).toEqual(1); expect(result[0].docketEntryId).toEqual(unsealedDocketEntryId); @@ -240,6 +240,7 @@ describe('caseFilter', () => { it('should NOT filter out sealed documents in search results when the user is associated with the case', () => { const result = caseSearchFilter(documentSearchResults, { + ...mockPrivatePractitionerUser, userId: 'associatedPractitioner', }); diff --git a/shared/src/business/utilities/caseFilter.ts b/shared/src/business/utilities/caseFilter.ts index 7772f2bdb19..7037669d23f 100644 --- a/shared/src/business/utilities/caseFilter.ts +++ b/shared/src/business/utilities/caseFilter.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { ROLE_PERMISSIONS, isAuthorized, @@ -75,7 +76,7 @@ export const caseContactAddressSealedFormatter = (caseRaw, currentUser) => { return formattedCase; }; -export const caseSearchFilter = (searchResults, currentUser) => { +export const caseSearchFilter = (searchResults, currentUser: AuthUser) => { return searchResults .filter( searchResult => From 99d1a8c4a006c7a69ea6e55da3be8d54ecbe67a0 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 25 Jul 2024 13:50:49 -0500 Subject: [PATCH 381/523] 10417: wip: WorkItem constructor needs a second param --- shared/src/business/entities/WorkItem.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/business/entities/WorkItem.ts b/shared/src/business/entities/WorkItem.ts index e38935bcca1..6820bc2e7fe 100644 --- a/shared/src/business/entities/WorkItem.ts +++ b/shared/src/business/entities/WorkItem.ts @@ -37,7 +37,7 @@ export class WorkItem extends JoiValidationEntity { public updatedAt: string; public workItemId: string; - constructor(rawWorkItem, caseEntity?: Case) { + constructor(rawWorkItem, secondParam: {}, caseEntity?: Case) { super('WorkItem'); this.assigneeId = rawWorkItem.assigneeId; From a03b9fbc4541627e6caf964f05728180d0f32a71 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 25 Jul 2024 14:57:08 -0500 Subject: [PATCH 382/523] 10417: fix WorkItem constructor differently --- shared/src/business/entities/WorkItem.test.ts | 2 +- shared/src/business/entities/WorkItem.ts | 2 +- .../business/useCases/saveCaseDetailInternalEditInteractor.ts | 2 +- shared/src/business/useCases/updateContactInteractor.ts | 2 +- .../docketEntry/fileAndServeDocumentOnOneCase.ts | 2 +- .../src/business/useCaseHelper/service/createChangeItems.ts | 2 +- .../src/business/useCases/createCaseFromPaperInteractor.ts | 2 +- web-api/src/business/useCases/createCaseInteractor.ts | 2 +- .../business/useCases/docketEntry/addPaperFilingInteractor.ts | 2 +- .../docketEntry/fileCourtIssuedDocketEntryInteractor.ts | 2 +- .../workItems/getDocumentQCInboxForSectionInteractor.ts | 4 +--- .../useCases/workItems/getDocumentQCInboxForUserInteractor.ts | 4 +--- 12 files changed, 12 insertions(+), 16 deletions(-) diff --git a/shared/src/business/entities/WorkItem.test.ts b/shared/src/business/entities/WorkItem.test.ts index 095cfff1354..997178f08ff 100644 --- a/shared/src/business/entities/WorkItem.test.ts +++ b/shared/src/business/entities/WorkItem.test.ts @@ -115,7 +115,7 @@ describe('WorkItem', () => { mockCase.trialDate = '2018-11-21T20:49:28.192Z'; mockCase.trialLocation = 'Seattle, WA'; - const workItem = new WorkItem(aValidWorkItem, mockCase); + const workItem = new WorkItem(aValidWorkItem, { caseEntity: mockCase }); expect(workItem.isValid()).toBeTruthy(); expect(workItem.associatedJudge).toBe(mockCase.associatedJudge); diff --git a/shared/src/business/entities/WorkItem.ts b/shared/src/business/entities/WorkItem.ts index 6820bc2e7fe..56340631067 100644 --- a/shared/src/business/entities/WorkItem.ts +++ b/shared/src/business/entities/WorkItem.ts @@ -37,7 +37,7 @@ export class WorkItem extends JoiValidationEntity { public updatedAt: string; public workItemId: string; - constructor(rawWorkItem, secondParam: {}, caseEntity?: Case) { + constructor(rawWorkItem, { caseEntity }: { caseEntity?: Case } = {}) { super('WorkItem'); this.assigneeId = rawWorkItem.assigneeId; diff --git a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts index 880ee55df1e..432593943d4 100644 --- a/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts +++ b/shared/src/business/useCases/saveCaseDetailInternalEditInteractor.ts @@ -151,7 +151,7 @@ export const saveCaseDetailInternalEdit = async ( trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - caseEntity, + { caseEntity }, ); await applicationContext.getPersistenceGateway().saveWorkItem({ diff --git a/shared/src/business/useCases/updateContactInteractor.ts b/shared/src/business/useCases/updateContactInteractor.ts index 5d11ba72779..0eef844e7e3 100644 --- a/shared/src/business/useCases/updateContactInteractor.ts +++ b/shared/src/business/useCases/updateContactInteractor.ts @@ -189,7 +189,7 @@ export const updateContact = async ( trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - caseEntity, + { caseEntity }, ); changeOfAddressDocketEntry.setWorkItem(workItem); diff --git a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts index b6b63bf22f5..1f0019ca659 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.ts @@ -47,7 +47,7 @@ export const fileAndServeDocumentOnOneCase = async ({ trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - caseEntity, + { caseEntity }, ); } diff --git a/web-api/src/business/useCaseHelper/service/createChangeItems.ts b/web-api/src/business/useCaseHelper/service/createChangeItems.ts index 7bccda65c0c..abc5f29b86d 100644 --- a/web-api/src/business/useCaseHelper/service/createChangeItems.ts +++ b/web-api/src/business/useCaseHelper/service/createChangeItems.ts @@ -160,7 +160,7 @@ const createWorkItemForChange = async ({ trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - caseEntity, + { caseEntity }, ); changeOfAddressDocketEntry.setWorkItem(workItem); diff --git a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts index 613f0b2cd68..ac579205f1f 100644 --- a/web-api/src/business/useCases/createCaseFromPaperInteractor.ts +++ b/web-api/src/business/useCases/createCaseFromPaperInteractor.ts @@ -50,7 +50,7 @@ const addPetitionDocketEntryWithWorkItemToCase = ({ trialDate: caseToAdd.trialDate, trialLocation: caseToAdd.trialLocation, }, - caseToAdd, + { caseEntity: caseToAdd }, ); docketEntryEntity.setWorkItem(workItemEntity); diff --git a/web-api/src/business/useCases/createCaseInteractor.ts b/web-api/src/business/useCases/createCaseInteractor.ts index 5b5928630f3..5c66a7ee2f2 100644 --- a/web-api/src/business/useCases/createCaseInteractor.ts +++ b/web-api/src/business/useCases/createCaseInteractor.ts @@ -47,7 +47,7 @@ const addPetitionDocketEntryToCase = ({ trialDate: caseToAdd.trialDate, trialLocation: caseToAdd.trialLocation, }, - caseToAdd, + { caseEntity: caseToAdd }, ); docketEntryEntity.setWorkItem(workItemEntity); diff --git a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts index 7baa50829fd..cfe1686cbf6 100644 --- a/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/addPaperFilingInteractor.ts @@ -133,7 +133,7 @@ export const addPaperFiling = async ( trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - caseEntity, + { caseEntity }, ); if (isReadyForService) { diff --git a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts index 91059ffe4f7..225809039cb 100644 --- a/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/fileCourtIssuedDocketEntryInteractor.ts @@ -135,7 +135,7 @@ export const fileCourtIssuedDocketEntry = async ( trialDate: caseEntity.trialDate, trialLocation: caseEntity.trialLocation, }, - caseEntity, + { caseEntity }, ); if (isUnservable) { diff --git a/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.ts b/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.ts index d8912c6fba6..2d001b54ea5 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCInboxForSectionInteractor.ts @@ -48,7 +48,5 @@ export const getDocumentQCInboxForSectionInteractor = async ( section: sectionToShow, }); - return WorkItem.validateRawCollection(workItems, { - applicationContext, - }); + return WorkItem.validateRawCollection(workItems); }; diff --git a/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.ts b/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.ts index 80a23e11ba3..0e80335f04b 100644 --- a/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.ts +++ b/web-api/src/business/useCases/workItems/getDocumentQCInboxForUserInteractor.ts @@ -40,7 +40,5 @@ export const getDocumentQCInboxForUserInteractor = async ( workItem.assigneeId === user.userId && workItem.section === user.section, ); - return WorkItem.validateRawCollection(filteredWorkItems, { - applicationContext, - }); + return WorkItem.validateRawCollection(filteredWorkItems); }; From 8d06e129ade162ff08de1476c74e2a5ddaac95e6 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 25 Jul 2024 15:22:43 -0500 Subject: [PATCH 383/523] 10417 add authorizedUser to forwardMessageLambda --- .../messages/forwardMessageInteractor.ts | 24 ++++++++++++------- .../lambdas/messages/forwardMessageLambda.ts | 15 ++++++++---- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/web-api/src/business/useCases/messages/forwardMessageInteractor.ts b/web-api/src/business/useCases/messages/forwardMessageInteractor.ts index 6be7b0e8d88..45e85f8802e 100644 --- a/web-api/src/business/useCases/messages/forwardMessageInteractor.ts +++ b/web-api/src/business/useCases/messages/forwardMessageInteractor.ts @@ -1,6 +1,7 @@ import { RawMessage } from '@shared/business/entities/Message'; import { ReplyMessageType } from '@web-api/business/useCases/messages/createMessageInteractor'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { replyToMessage } from './replyToMessageInteractor'; export const forwardMessageInteractor = async ( @@ -14,14 +15,19 @@ export const forwardMessageInteractor = async ( toSection, toUserId, }: ReplyMessageType, + authorizedUser: UnknownAuthUser, ): Promise => { - return await replyToMessage(applicationContext, { - attachments, - docketNumber, - message, - parentMessageId, - subject, - toSection, - toUserId, - }); + return await replyToMessage( + applicationContext, + { + attachments, + docketNumber, + message, + parentMessageId, + subject, + toSection, + toUserId, + }, + authorizedUser, + ); }; diff --git a/web-api/src/lambdas/messages/forwardMessageLambda.ts b/web-api/src/lambdas/messages/forwardMessageLambda.ts index 6e200f14a7b..973b3fe88ab 100644 --- a/web-api/src/lambdas/messages/forwardMessageLambda.ts +++ b/web-api/src/lambdas/messages/forwardMessageLambda.ts @@ -1,3 +1,4 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { forwardMessageInteractor } from '@web-api/business/useCases/messages/forwardMessageInteractor'; import { genericHandler } from '../../genericHandler'; @@ -7,10 +8,14 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const forwardMessageLambda = event => +export const forwardMessageLambda = (event, authorizedUser: UnknownAuthUser) => genericHandler(event, async ({ applicationContext }) => { - return await forwardMessageInteractor(applicationContext, { - parentMessageId: event.pathParameters.parentMessageId, - ...JSON.parse(event.body), - }); + return await forwardMessageInteractor( + applicationContext, + { + parentMessageId: event.pathParameters.parentMessageId, + ...JSON.parse(event.body), + }, + authorizedUser, + ); }); From d38b8106d97cb6ca00558238bd5a956edfe6fd5e Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 26 Jul 2024 10:02:06 -0500 Subject: [PATCH 384/523] 10417 add custom:userId to auth token --- .../docketClerkStandaloneRemoteTrialSession.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-client/integration-tests/docketClerkStandaloneRemoteTrialSession.test.ts b/web-client/integration-tests/docketClerkStandaloneRemoteTrialSession.test.ts index 0f631ab43c8..7dd65dab96d 100644 --- a/web-client/integration-tests/docketClerkStandaloneRemoteTrialSession.test.ts +++ b/web-client/integration-tests/docketClerkStandaloneRemoteTrialSession.test.ts @@ -23,7 +23,7 @@ describe('Docket clerk standalone remote trial session journey', () => { headers: { Authorization: // mocked admissions clerk user - 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFkbWlzc2lvbnNjbGVya0BleGFtcGxlLmNvbSIsIm5hbWUiOiJUZXN0IEFkbWlzc2lvbnMgQ2xlcmsiLCJyb2xlIjoiYWRtaXNzaW9uc2NsZXJrIiwic2VjdGlvbiI6ImFkbWlzc2lvbnMiLCJ1c2VySWQiOiI5ZDdkNjNiNy1kN2E1LTQ5MDUtYmE4OS1lZjcxYmYzMDA1N2YiLCJjdXN0b206cm9sZSI6ImFkbWlzc2lvbnNjbGVyayIsInN1YiI6IjlkN2Q2M2I3LWQ3YTUtNDkwNS1iYTg5LWVmNzFiZjMwMDU3ZiIsImlhdCI6MTYwOTQ0NTUyNn0.kow3pAUloDseD3isrxgtKBpcKsjMktbRBzY41c1NRqA', + 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFkbWlzc2lvbnNjbGVya0BleGFtcGxlLmNvbSIsIm5hbWUiOiJUZXN0IEFkbWlzc2lvbnMgQ2xlcmsiLCJyb2xlIjoiYWRtaXNzaW9uc2NsZXJrIiwic2VjdGlvbiI6ImFkbWlzc2lvbnMiLCJjdXN0b206dXNlcklkIjoiOWQ3ZDYzYjctZDdhNS00OTA1LWJhODktZWY3MWJmMzAwNTdmIiwiY3VzdG9tOnJvbGUiOiJhZG1pc3Npb25zY2xlcmsiLCJzdWIiOiI5ZDdkNjNiNy1kN2E1LTQ5MDUtYmE4OS1lZjcxYmYzMDA1N2YiLCJpYXQiOjE2MDk0NDU1MjZ9.0SHlDNenfsLo4GJ6aC6Utwxh6ec0NCYDG0fLhcqhYAs', 'Content-Type': 'application/json', }, timeout: 2000, From 8463c2bb914473ff5691761babf6900532d5d9c6 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 26 Jul 2024 10:05:48 -0500 Subject: [PATCH 385/523] 10417 add custom:userId to auth token --- .../journey/admissionsClerkMigratesPractitionerWithoutEmail.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-client/integration-tests/journey/admissionsClerkMigratesPractitionerWithoutEmail.ts b/web-client/integration-tests/journey/admissionsClerkMigratesPractitionerWithoutEmail.ts index 74b3f9d69cd..42805924f67 100644 --- a/web-client/integration-tests/journey/admissionsClerkMigratesPractitionerWithoutEmail.ts +++ b/web-client/integration-tests/journey/admissionsClerkMigratesPractitionerWithoutEmail.ts @@ -12,7 +12,7 @@ const axiosInstance = axios.create({ headers: { Authorization: // mocked admissions clerk user - 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFkbWlzc2lvbnNjbGVya0BleGFtcGxlLmNvbSIsIm5hbWUiOiJUZXN0IEFkbWlzc2lvbnMgQ2xlcmsiLCJyb2xlIjoiYWRtaXNzaW9uc2NsZXJrIiwic2VjdGlvbiI6ImFkbWlzc2lvbnMiLCJ1c2VySWQiOiI5ZDdkNjNiNy1kN2E1LTQ5MDUtYmE4OS1lZjcxYmYzMDA1N2YiLCJjdXN0b206cm9sZSI6ImFkbWlzc2lvbnNjbGVyayIsInN1YiI6IjlkN2Q2M2I3LWQ3YTUtNDkwNS1iYTg5LWVmNzFiZjMwMDU3ZiIsImlhdCI6MTYwOTQ0NTUyNn0.kow3pAUloDseD3isrxgtKBpcKsjMktbRBzY41c1NRqA', + 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFkbWlzc2lvbnNjbGVya0BleGFtcGxlLmNvbSIsIm5hbWUiOiJUZXN0IEFkbWlzc2lvbnMgQ2xlcmsiLCJyb2xlIjoiYWRtaXNzaW9uc2NsZXJrIiwic2VjdGlvbiI6ImFkbWlzc2lvbnMiLCJjdXN0b206dXNlcklkIjoiOWQ3ZDYzYjctZDdhNS00OTA1LWJhODktZWY3MWJmMzAwNTdmIiwiY3VzdG9tOnJvbGUiOiJhZG1pc3Npb25zY2xlcmsiLCJzdWIiOiI5ZDdkNjNiNy1kN2E1LTQ5MDUtYmE4OS1lZjcxYmYzMDA1N2YiLCJpYXQiOjE2MDk0NDU1MjZ9.0SHlDNenfsLo4GJ6aC6Utwxh6ec0NCYDG0fLhcqhYAs', 'Content-Type': 'application/json', }, timeout: 2000, From 1130fce13333a15499f24bf5ad2b590002c494a3 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 26 Jul 2024 10:29:44 -0500 Subject: [PATCH 386/523] 10417: remove authorizedUser from public endpoint --- .../useCases/generateDocketRecordPdfInteractor.ts | 7 ++----- .../public-api/generatePublicDocketRecordPdfLambda.ts | 8 ++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts index c2638e6b603..15035e72d05 100644 --- a/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts +++ b/web-api/src/business/useCases/generateDocketRecordPdfInteractor.ts @@ -26,15 +26,12 @@ export const generateDocketRecordPdfInteractor = async ( }, authorizedUser: UnknownAuthUser, ) => { - if (!authorizedUser) { - throw new UnauthorizedError('Unauthorized to generate docket record.'); - } const isDirectlyAssociated = await applicationContext .getPersistenceGateway() .verifyCaseForUser({ applicationContext, docketNumber, - userId: authorizedUser.userId, + userId: authorizedUser?.userId, }); const caseSource = await applicationContext @@ -51,7 +48,7 @@ export const generateDocketRecordPdfInteractor = async ( .isSealedCase(caseSource); if (isSealedCase) { - if (authorizedUser.userId) { + if (authorizedUser?.userId) { const isAuthorizedToViewSealedCase = isAuthorized( authorizedUser, ROLE_PERMISSIONS.VIEW_SEALED_CASE, diff --git a/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts b/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts index 067259c9752..cfa1db87358 100644 --- a/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts +++ b/web-api/src/lambdas/public-api/generatePublicDocketRecordPdfLambda.ts @@ -1,4 +1,3 @@ -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { generateDocketRecordPdfInteractor } from '@web-api/business/useCases/generateDocketRecordPdfInteractor'; import { genericHandler } from '../../genericHandler'; @@ -8,10 +7,7 @@ import { genericHandler } from '../../genericHandler'; * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -export const generatePublicDocketRecordPdfLambda = ( - event, - authorizedUser: UnknownAuthUser, -) => +export const generatePublicDocketRecordPdfLambda = event => genericHandler( event, async ({ applicationContext }) => { @@ -21,7 +17,7 @@ export const generatePublicDocketRecordPdfLambda = ( ...JSON.parse(event.body), includePartyDetail: false, }, - authorizedUser, + undefined, ); }, { logResults: false }, From 80f1abd3ea884b3493f35b56cf50fde3e8027dff Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 26 Jul 2024 12:22:05 -0500 Subject: [PATCH 387/523] 10417 fix authorizationClientService tests --- .../authorization/authorizationClientService.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/shared/src/authorization/authorizationClientService.test.ts b/shared/src/authorization/authorizationClientService.test.ts index c0abcc6fd31..30d25235369 100644 --- a/shared/src/authorization/authorizationClientService.test.ts +++ b/shared/src/authorization/authorizationClientService.test.ts @@ -23,12 +23,18 @@ describe('Authorization client service', () => { it('should return true for any user whose userId matches the 3rd owner argument, in this case "someUser" === "someUser"', () => { expect( - isAuthorized(mockPetitionerUser, 'unknown action' as any, 'someUser'), + isAuthorized( + mockPetitionerUser, + 'unknown action' as any, + mockPetitionerUser.userId, + ), ).toBeTruthy(); }); it('should return false when the role provided is not found in the AUTHORIZATION_MAP', () => { - expect(isAuthorized(mockJudgeUser, ROLE_PERMISSIONS.WORKITEM)).toBe(false); + expect(isAuthorized(mockPetitionerUser, ROLE_PERMISSIONS.WORKITEM)).toBe( + false, + ); }); it('should contain NO falsy values in the AUTHORIZATION_MAP', () => { From 0acf675db5641abaf4e60e16b540ed8bc25fc12b Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 26 Jul 2024 13:01:13 -0500 Subject: [PATCH 388/523] 10417 revert back to applicationContext for useCases --- ...icesForCalendaredTrialSessionInteractor.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts index 3e9fcb8a1f9..22838d2ddb4 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts @@ -7,7 +7,6 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { generateTrialSessionPaperServicePdfInteractor } from '@web-api/business/useCases/trialSessions/generateTrialSessionPaperServicePdfInteractor'; import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; const setNoticesForCalendaredTrialSession = async ( @@ -165,15 +164,19 @@ const setNoticesForCalendaredTrialSession = async ( }); if (trialNoticePdfsKeys.length) { - await generateTrialSessionPaperServicePdfInteractor( - applicationContext, - { - clientConnectionId, - trialNoticePdfsKeys, - trialSessionId, - }, - authorizedUser, - ); + // TODO 10417 should we do direct import here as part of this story? + // if so, we need to change how we're mocking in the tests. + await applicationContext + .getUseCases() + .generateTrialSessionPaperServicePdfInteractor( + applicationContext, + { + clientConnectionId, + trialNoticePdfsKeys, + trialSessionId, + }, + authorizedUser, + ); } }; From b7f67eedca851fdc4d1d98eb8b8e1b356a47db35 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 26 Jul 2024 14:37:08 -0700 Subject: [PATCH 389/523] 10417: Remove getCurrentUser --- .../generatePetitionPdfInteractor.test.ts | 82 ++++++++++--------- .../useCases/generatePetitionPdfInteractor.ts | 8 +- .../cases/generatePetitionPdfLambda.ts | 17 ++-- 3 files changed, 58 insertions(+), 49 deletions(-) diff --git a/shared/src/business/useCases/generatePetitionPdfInteractor.test.ts b/shared/src/business/useCases/generatePetitionPdfInteractor.test.ts index d1eb74e1304..451d904709b 100644 --- a/shared/src/business/useCases/generatePetitionPdfInteractor.test.ts +++ b/shared/src/business/useCases/generatePetitionPdfInteractor.test.ts @@ -1,14 +1,12 @@ import { CASE_TYPES_MAP } from '@shared/business/entities/EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; import { generatePetitionPdfInteractor } from '@shared/business/useCases/generatePetitionPdfInteractor'; -import { petitionerUser } from '@shared/test/mockUsers'; +import { mockPetitionerUser } from '@shared/test/mockAuthUsers'; describe('generatePetitionPdfInteractor', () => { const mockFileId = '9085265b-e8ad-4bab-9e7c-f82e847b41f9'; beforeEach(() => { - applicationContext.getCurrentUser.mockImplementation(() => petitionerUser); - applicationContext .getDocumentGenerators() .petition.mockImplementation( @@ -28,31 +26,33 @@ describe('generatePetitionPdfInteractor', () => { }); it('should throw an Unauthorized user error when user does not have the correct permissions', async () => { - applicationContext.getCurrentUser.mockImplementation(() => ({})); - await expect( - generatePetitionPdfInteractor(applicationContext, {}), + generatePetitionPdfInteractor(applicationContext, {}, undefined), ).rejects.toThrow('Unauthorized'); }); it('should generate petition and call save document', async () => { - const results = await generatePetitionPdfInteractor(applicationContext, { - caseCaptionExtension: 'TEST_caseCaptionExtension', - caseDescription: 'Deficiency', - caseTitle: 'TEST_caseTitle', - caseType: CASE_TYPES_MAP.deficiency, - contactPrimary: 'TEST_contactPrimary', - contactSecondary: 'TEST_contactSecondary', - hasIrsNotice: false, - hasUploadedIrsNotice: 'TEST_hasUploadedIrsNotice', - irsNotices: [], - partyType: 'TEST_partyType', - petitionFacts: 'TEST_petitionFacts', - petitionReasons: 'TEST_petitionReasons', - preferredTrialCity: 'TEST_preferredTrialCity', - procedureType: 'TEST_procedureType', - taxYear: 'TEST_taxYear', - }); + const results = await generatePetitionPdfInteractor( + applicationContext, + { + caseCaptionExtension: 'TEST_caseCaptionExtension', + caseDescription: 'Deficiency', + caseTitle: 'TEST_caseTitle', + caseType: CASE_TYPES_MAP.deficiency, + contactPrimary: 'TEST_contactPrimary', + contactSecondary: 'TEST_contactSecondary', + hasIrsNotice: false, + hasUploadedIrsNotice: 'TEST_hasUploadedIrsNotice', + irsNotices: [], + partyType: 'TEST_partyType', + petitionFacts: 'TEST_petitionFacts', + petitionReasons: 'TEST_petitionReasons', + preferredTrialCity: 'TEST_preferredTrialCity', + procedureType: 'TEST_procedureType', + taxYear: 'TEST_taxYear', + }, + mockPetitionerUser, + ); const petitionCalls = applicationContext.getDocumentGenerators().petition.mock.calls; @@ -94,22 +94,26 @@ describe('generatePetitionPdfInteractor', () => { }, ]; - const results = await generatePetitionPdfInteractor(applicationContext, { - caseCaptionExtension: 'TEST_caseCaptionExtension', - caseTitle: 'TEST_caseTitle', - caseType: CASE_TYPES_MAP.deficiency, - contactPrimary: 'TEST_contactPrimary', - contactSecondary: 'TEST_contactSecondary', - hasIrsNotice: true, - hasUploadedIrsNotice: 'TEST_hasUploadedIrsNotice', - irsNotices, - partyType: 'TEST_partyType', - petitionFacts: 'TEST_petitionFacts', - petitionReasons: 'TEST_petitionReasons', - preferredTrialCity: 'TEST_preferredTrialCity', - procedureType: 'TEST_procedureType', - taxYear: 'TEST_taxYear', - }); + const results = await generatePetitionPdfInteractor( + applicationContext, + { + caseCaptionExtension: 'TEST_caseCaptionExtension', + caseTitle: 'TEST_caseTitle', + caseType: CASE_TYPES_MAP.deficiency, + contactPrimary: 'TEST_contactPrimary', + contactSecondary: 'TEST_contactSecondary', + hasIrsNotice: true, + hasUploadedIrsNotice: 'TEST_hasUploadedIrsNotice', + irsNotices, + partyType: 'TEST_partyType', + petitionFacts: 'TEST_petitionFacts', + petitionReasons: 'TEST_petitionReasons', + preferredTrialCity: 'TEST_preferredTrialCity', + procedureType: 'TEST_procedureType', + taxYear: 'TEST_taxYear', + }, + mockPetitionerUser, + ); const petitionCalls = applicationContext.getDocumentGenerators().petition.mock.calls; diff --git a/shared/src/business/useCases/generatePetitionPdfInteractor.ts b/shared/src/business/useCases/generatePetitionPdfInteractor.ts index 3fd6e679584..d226c278077 100644 --- a/shared/src/business/useCases/generatePetitionPdfInteractor.ts +++ b/shared/src/business/useCases/generatePetitionPdfInteractor.ts @@ -9,8 +9,7 @@ import { } from '@shared/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; - -// TODO type for props +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const generatePetitionPdfInteractor = async ( applicationContext: ServerApplicationContext, @@ -30,10 +29,9 @@ export const generatePetitionPdfInteractor = async ( procedureType, taxYear, }: any, + authorizedUser: UnknownAuthUser, ): Promise<{ fileId: string }> => { - const user = applicationContext.getCurrentUser(); - - if (!isAuthorized(user, ROLE_PERMISSIONS.PETITION)) { + if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.PETITION)) { throw new UnauthorizedError('Unauthorized'); } diff --git a/web-api/src/lambdas/cases/generatePetitionPdfLambda.ts b/web-api/src/lambdas/cases/generatePetitionPdfLambda.ts index 1302df816d2..3a57d36cfcb 100644 --- a/web-api/src/lambdas/cases/generatePetitionPdfLambda.ts +++ b/web-api/src/lambdas/cases/generatePetitionPdfLambda.ts @@ -1,11 +1,18 @@ +import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { generatePetitionPdfInteractor } from '@shared/business/useCases/generatePetitionPdfInteractor'; import { genericHandler } from '../../genericHandler'; -export const generatePetitionPdfLambda = event => +export const generatePetitionPdfLambda = ( + event, + authorizedUser: UnknownAuthUser, +) => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .generatePetitionPdfInteractor(applicationContext, { + return await generatePetitionPdfInteractor( + applicationContext, + { ...event.pathParameters, ...JSON.parse(event.body), - }); + }, + authorizedUser, + ); }); From 12b77139306162f7bf137c41d011781cb6364dc3 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 26 Jul 2024 14:40:31 -0700 Subject: [PATCH 390/523] 10417: Remove getCurrentUser --- .../actions/formatPetitionAction.test.ts | 21 +++++++++++++++---- .../presenter/actions/formatPetitionAction.ts | 3 ++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/web-client/src/presenter/actions/formatPetitionAction.test.ts b/web-client/src/presenter/actions/formatPetitionAction.test.ts index 26491da04bf..f1cccb53428 100644 --- a/web-client/src/presenter/actions/formatPetitionAction.test.ts +++ b/web-client/src/presenter/actions/formatPetitionAction.test.ts @@ -1,6 +1,7 @@ import { CASE_TYPES_MAP } from '@shared/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { formatPetitionAction } from '@web-client/presenter/actions/formatPetitionAction'; +import { mockPetitionerUser } from '@shared/test/mockAuthUsers'; import { presenter } from '../presenter-mock'; import { runAction } from '@web-client/presenter/test.cerebral'; @@ -31,10 +32,6 @@ describe('formatPetitionAction', () => { .getUtilities() .getCaseCaption.mockImplementation(() => TEST_CASE_CAPTION); - applicationContext.getCurrentUser.mockImplementation(() => ({ - email: TEST_EMAIL, - })); - presenter.providers.applicationContext = applicationContext; }); @@ -46,6 +43,10 @@ describe('formatPetitionAction', () => { props: PROPS, state: { petitionFormatted: undefined, + user: { + ...mockPetitionerUser, + email: TEST_EMAIL, + }, }, }); @@ -81,6 +82,10 @@ describe('formatPetitionAction', () => { props: PROPS, state: { petitionFormatted: undefined, + user: { + ...mockPetitionerUser, + email: TEST_EMAIL, + }, }, }); @@ -124,6 +129,10 @@ describe('formatPetitionAction', () => { props: propsWithDisclosure, state: { petitionFormatted: undefined, + user: { + ...mockPetitionerUser, + email: TEST_EMAIL, + }, }, }); @@ -161,6 +170,10 @@ describe('formatPetitionAction', () => { props: propsWithoutIrsNotice, state: { petitionFormatted: undefined, + user: { + ...mockPetitionerUser, + email: TEST_EMAIL, + }, }, }); diff --git a/web-client/src/presenter/actions/formatPetitionAction.ts b/web-client/src/presenter/actions/formatPetitionAction.ts index 6da456f301b..9dade04b3ae 100644 --- a/web-client/src/presenter/actions/formatPetitionAction.ts +++ b/web-client/src/presenter/actions/formatPetitionAction.ts @@ -7,6 +7,7 @@ import { state } from '@web-client/presenter/app.cerebral'; export const formatPetitionAction = ({ applicationContext, + get, props, store, }: ActionProps) => { @@ -40,7 +41,7 @@ export const formatPetitionAction = ({ const { contactPrimary, irsNotices } = petitionInfo; - const user = applicationContext.getCurrentUser(); + const user = get(state.user); contactPrimary.email = user.email; let noticeIssuedDate; From a3883f71442c01732793e68c327f33dc46d7df29 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 26 Jul 2024 14:44:52 -0700 Subject: [PATCH 391/523] 10417: Remove getCurrentUser --- .../updatedFilePetitionHelper.test.ts | 26 ++++++++++++------- .../computeds/updatedFilePetitionHelper.ts | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/web-client/src/presenter/computeds/updatedFilePetitionHelper.test.ts b/web-client/src/presenter/computeds/updatedFilePetitionHelper.test.ts index e83f89cefcc..9aff632750a 100644 --- a/web-client/src/presenter/computeds/updatedFilePetitionHelper.test.ts +++ b/web-client/src/presenter/computeds/updatedFilePetitionHelper.test.ts @@ -9,7 +9,6 @@ import { updatedFilePetitionHelper as updatedFilePetitionHelperComputed } from ' import { withAppContextDecorator } from '../../withAppContext'; describe('updatedFilePetitionHelper', () => { - let user; const updatedFilePetitionHelper = withAppContextDecorator( updatedFilePetitionHelperComputed, { @@ -17,16 +16,9 @@ describe('updatedFilePetitionHelper', () => { getConstants: () => { return { FILING_TYPES, PARTY_TYPES }; }, - getCurrentUser: () => { - return user; - }, }, ); - beforeEach(() => { - user = petitionerUser; - }); - describe('businessFieldNames', () => { it('should return business field names for the Corporation business type', () => { const result = runCompute(updatedFilePetitionHelper, { @@ -34,6 +26,7 @@ describe('updatedFilePetitionHelper', () => { form: { businessType: 'Corporation', }, + user: petitionerUser, }, }); expect(result.businessFieldNames).toEqual({ @@ -49,6 +42,7 @@ describe('updatedFilePetitionHelper', () => { form: { businessType: 'Partnership (as the Tax Matters Partner)', }, + user: petitionerUser, }, }); expect(result.businessFieldNames).toEqual({ @@ -64,6 +58,7 @@ describe('updatedFilePetitionHelper', () => { businessType: 'Partnership (as a partner other than Tax Matters Partner)', }, + user: petitionerUser, }, }); expect(result.businessFieldNames).toEqual({ @@ -79,6 +74,7 @@ describe('updatedFilePetitionHelper', () => { businessType: 'Partnership (as a partnership representative under BBA)', }, + user: petitionerUser, }, }); expect(result.businessFieldNames).toEqual({ @@ -90,7 +86,7 @@ describe('updatedFilePetitionHelper', () => { describe('filingOptions', () => { it('should return the filing options for petitioner', () => { const result = runCompute(updatedFilePetitionHelper, { - state: { form: {} }, + state: { form: {}, user: petitionerUser }, }); expect(result.filingOptions).toEqual([ 'Myself', @@ -123,6 +119,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType, }, + user: petitionerUser, }, }); expect(result.showContactInformationForOtherPartyType).toBeTruthy(); @@ -135,6 +132,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.petitioner, }, + user: petitionerUser, }, }); expect(result.showContactInformationForOtherPartyType).toBeFalsy(); @@ -148,6 +146,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.survivingSpouse, }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ @@ -162,6 +161,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.estate, }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ @@ -178,6 +178,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.estateWithoutExecutor, }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ @@ -193,6 +194,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.trust, }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ @@ -207,6 +209,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.conservator, }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ @@ -221,6 +224,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.guardian, }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ @@ -235,6 +239,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.custodian, }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ @@ -249,6 +254,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.nextFriendForMinor, }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ @@ -263,6 +269,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: PARTY_TYPES.nextFriendForIncompetentPerson, }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ @@ -277,6 +284,7 @@ describe('updatedFilePetitionHelper', () => { form: { partyType: 'unknown party', }, + user: petitionerUser, }, }); expect(result.otherContactNameLabel).toEqual({ diff --git a/web-client/src/presenter/computeds/updatedFilePetitionHelper.ts b/web-client/src/presenter/computeds/updatedFilePetitionHelper.ts index 81851ab66ae..bfb1abe3d43 100644 --- a/web-client/src/presenter/computeds/updatedFilePetitionHelper.ts +++ b/web-client/src/presenter/computeds/updatedFilePetitionHelper.ts @@ -30,7 +30,7 @@ export const updatedFilePetitionHelper = ( get: Get, applicationContext: ClientApplicationContext, ): UpdatedFilePetitionHelper => { - const user = applicationContext.getCurrentUser(); + const user = get(state.user); const { FILING_TYPES, PARTY_TYPES } = applicationContext.getConstants(); const businessType = get(state.form.businessType); From 6fa8632f23144d24eb975a4ed8f3594355a8219f Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 26 Jul 2024 14:50:35 -0700 Subject: [PATCH 392/523] 10417: Remove getCurrentUser --- shared/src/business/entities/cases/PaperPetition.test.ts | 2 +- web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/src/business/entities/cases/PaperPetition.test.ts b/shared/src/business/entities/cases/PaperPetition.test.ts index 6feaeaeeb4f..b76a46fad92 100644 --- a/shared/src/business/entities/cases/PaperPetition.test.ts +++ b/shared/src/business/entities/cases/PaperPetition.test.ts @@ -487,7 +487,7 @@ describe('paperPetition entity', () => { contactSecondary: {}, partyType: PARTY_TYPES.petitionerDeceasedSpouse, }, - { applicationContext }, + { authorizedUser: mockPetitionsClerkUser }, ); expect(paperPetition.petitioners[1].phone).toEqual('N/A'); }); diff --git a/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts b/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts index d2b82d7d6cd..df7d5bcf26b 100644 --- a/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts +++ b/web-api/src/lambdas/caseDeadline/createCaseDeadlineLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { createCaseDeadlineInteractor } from '@web-api/business/useCases/caseDeadline/createCaseDeadlineInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -12,7 +13,7 @@ export const createCaseDeadlineLambda = ( authorizedUser: UnknownAuthUser, ): Promise => genericHandler(event, async ({ applicationContext }) => { - return await applicationContext.getUseCases().createCaseDeadlineInteractor( + return await createCaseDeadlineInteractor( applicationContext, { ...JSON.parse(event.body), From 5ef285b3be3bc2ff6179769431de5ab76c53a2b2 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 26 Jul 2024 15:12:51 -0700 Subject: [PATCH 393/523] 10417: Default the user as an empty object so that state can understand the shape of the currentUser --- shared/src/business/useCases/getUserInteractor.ts | 13 +++++++++++-- shared/src/proxies/users/getUserProxy.ts | 5 ++++- web-client/src/presenter/state.ts | 14 +++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/shared/src/business/useCases/getUserInteractor.ts b/shared/src/business/useCases/getUserInteractor.ts index b4505dd479e..89b061a1838 100644 --- a/shared/src/business/useCases/getUserInteractor.ts +++ b/shared/src/business/useCases/getUserInteractor.ts @@ -4,17 +4,26 @@ import { } from '../entities/IrsPractitioner'; import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors'; import { Practitioner, RawPractitioner } from '../entities/Practitioner'; -import { PrivatePractitioner } from '../entities/PrivatePractitioner'; +import { + PrivatePractitioner, + RawPrivatePractitioner, +} from '../entities/PrivatePractitioner'; import { RawUser, User } from '../entities/User'; import { UnknownAuthUser, isAuthUser, } from '@shared/business/entities/authUser/AuthUser'; +export type GetUserResponse = + | RawUser + | RawPractitioner + | RawIrsPractitioner + | RawPrivatePractitioner; + export const getUserInteractor = async ( applicationContext: IApplicationContext, authorizedUser: UnknownAuthUser, -): Promise => { +): Promise => { if (!isAuthUser(authorizedUser)) { throw new UnauthorizedError('Not authorized to get user'); } diff --git a/shared/src/proxies/users/getUserProxy.ts b/shared/src/proxies/users/getUserProxy.ts index c84743368f4..33bb46f4ede 100644 --- a/shared/src/proxies/users/getUserProxy.ts +++ b/shared/src/proxies/users/getUserProxy.ts @@ -1,3 +1,4 @@ +import { GetUserResponse } from '@shared/business/useCases/getUserInteractor'; import { get } from '../requests'; /** @@ -7,7 +8,9 @@ import { get } from '../requests'; * @param {object} providers the providers object * @returns {Promise<*>} the promise of the api call */ -export const getUserInteractor = applicationContext => { +export const getUserInteractor = ( + applicationContext, +): Promise => { return get({ applicationContext, endpoint: '/users', diff --git a/web-client/src/presenter/state.ts b/web-client/src/presenter/state.ts index 6c121f7ab67..a309988a338 100644 --- a/web-client/src/presenter/state.ts +++ b/web-client/src/presenter/state.ts @@ -1,13 +1,13 @@ /* eslint-disable max-lines */ import { FormattedPendingMotionWithWorksheet } from '@web-api/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor'; import { GetCasesByStatusAndByJudgeResponse } from '@web-api/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor'; +import { GetUserResponse } from '@shared/business/useCases/getUserInteractor'; import { IrsNoticeForm } from '@shared/business/entities/startCase/IrsNoticeForm'; import { JudgeActivityReportState } from '@web-client/ustc-ui/Utils/types'; import { RawCaseDeadline } from '@shared/business/entities/CaseDeadline'; -import { RawIrsPractitioner } from '@shared/business/entities/IrsPractitioner'; import { RawMessage } from '@shared/business/entities/Message'; -import { RawPractitioner } from '@shared/business/entities/Practitioner'; import { RawUser } from '@shared/business/entities/User'; +import { Role } from '@shared/business/entities/EntityConstants'; import { TAssociatedCase } from '@shared/business/useCases/getCasesForUserInteractor'; import { addCourtIssuedDocketEntryHelper } from './computeds/addCourtIssuedDocketEntryHelper'; import { addCourtIssuedDocketEntryNonstandardHelper } from './computeds/addCourtIssuedDocketEntryNonstandardHelper'; @@ -828,7 +828,15 @@ export const baseState = { } as { selectedFilingOption?: string; }, - user: null as unknown as RawUser | RawPractitioner | RawIrsPractitioner, // TODO 10417 initialize to the correct shape after verifying no where in the application is doing a null check for state.user. + user: { + email: '', + name: '', + role: '' as Role, + section: '', + userId: '', + } as GetUserResponse & { + email: string; + }, // We know that the logged in user has an email otherwise they could not login. userContactEditProgress: {} as { inProgress?: boolean }, users: [] as RawUser[], validationErrors: {} as Record, From 66c4b0a9a666e0d5cf08db6813e490eeb3350569 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 26 Jul 2024 15:29:02 -0700 Subject: [PATCH 394/523] 10417: Update to use authorizedUser --- docs/remove-get-current-user.md | 2 +- .../useCases/document/batchDownloadDocketEntriesInteractor.ts | 2 +- .../generatePrintableTrialSessionCopyReportInteractor.test.ts | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index 9af9b478bdf..fe17ff16a96 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -6,7 +6,7 @@ - Go back to all // TODO 10417 - Look at validateRawCollection() - check instances of `handleLockError` (or `OnLockError`) -- Look at all new Case and new DocketEntry +- Look at all new DocketEntry # Problems we see with the app that are unrelated to changes - generateStampedCoversheetInteractor does not have any authorization diff --git a/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts b/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts index 5c6d61d620f..74b4f06fd91 100644 --- a/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts +++ b/web-api/src/business/useCases/document/batchDownloadDocketEntriesInteractor.ts @@ -100,7 +100,7 @@ const batchDownloadDocketEntriesHelper = async ( useTempBucket: boolean; }[] = []; - const caseEntity = new Case(caseToBatch, { applicationContext }); + const caseEntity = new Case(caseToBatch, { authorizedUser }); documentsSelectedForDownload.forEach(docketEntryId => { const docInfo = caseEntity.getDocketEntryById({ diff --git a/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.test.ts b/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.test.ts index 5b1d91010ea..1cce24a3e13 100644 --- a/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.test.ts +++ b/web-api/src/business/useCases/trialSession/generatePrintableTrialSessionCopyReportInteractor.test.ts @@ -130,7 +130,9 @@ describe('generatePrintableTrialSessionCopyReportInteractor', () => { statusUnassigned: true, takenUnderAdvisement: true, }, - formattedCases: [new Case(MOCK_CASE, { mockTrialClerkUser })], + formattedCases: [ + new Case(MOCK_CASE, { authorizedUser: mockTrialClerkUser }), + ], formattedTrialSession: mockTrialSession, sessionNotes: 'session notes', showCaseNotes: true, From 0c55b41742a87a0b30bdea099bf56a786049c65e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 26 Jul 2024 15:32:08 -0700 Subject: [PATCH 395/523] 10417: docs --- docs/remove-get-current-user.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index fe17ff16a96..5b995974757 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -6,7 +6,6 @@ - Go back to all // TODO 10417 - Look at validateRawCollection() - check instances of `handleLockError` (or `OnLockError`) -- Look at all new DocketEntry # Problems we see with the app that are unrelated to changes - generateStampedCoversheetInteractor does not have any authorization From 346c5aea4c1ce469d909ba6ed0e7a59a08423afa Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 26 Jul 2024 15:47:14 -0700 Subject: [PATCH 396/523] 10417: Update passing in authorizedUser --- web-api/src/lambdas/notifications/connectLambda.ts | 2 -- .../presenter/actions/saveAndSubmitCaseAction.ts | 14 +++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/web-api/src/lambdas/notifications/connectLambda.ts b/web-api/src/lambdas/notifications/connectLambda.ts index de304c11eaa..6288355a90a 100644 --- a/web-api/src/lambdas/notifications/connectLambda.ts +++ b/web-api/src/lambdas/notifications/connectLambda.ts @@ -9,8 +9,6 @@ import { onConnectInteractor } from '@web-api/business/useCases/notifications/on * @param {object} event the AWS event object * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers */ -// TODO 10417 This lambda was causing issues locally (and presumably also would deployed, given how it's a standalone lambda). -// Current approach solves it, but is this what we want to do? export const connectLambda = event => { const authorizedUser: UnknownAuthUser = getUserFromAuthHeader(event); return genericHandler( diff --git a/web-client/src/presenter/actions/saveAndSubmitCaseAction.ts b/web-client/src/presenter/actions/saveAndSubmitCaseAction.ts index 710de9c7ec4..ed0a9f379dd 100644 --- a/web-client/src/presenter/actions/saveAndSubmitCaseAction.ts +++ b/web-client/src/presenter/actions/saveAndSubmitCaseAction.ts @@ -1,4 +1,4 @@ -import { ElectronicCreatedCaseType } from '@shared/business/useCases/createCaseInteractor'; +import { ElectronicCreatedCaseType } from '@web-api/business/useCases/createCaseInteractor'; import { FileUploadProgressType, FileUploadProgressValueType, @@ -20,6 +20,8 @@ export const saveAndSubmitCaseAction = async ({ state.petitionFormatted, ); + const user = get(state.user); + let caseDetail; let stinFile; @@ -29,9 +31,9 @@ export const saveAndSubmitCaseAction = async ({ corporateDisclosureFileId, petitionFileId, stinFileId, - } = await applicationContext - .getUseCases() - .generateDocumentIds(applicationContext, { + } = await applicationContext.getUseCases().generateDocumentIds( + applicationContext, + { attachmentToPetitionUploadProgress: fileUploadProgressMap.attachmentToPetition as FileUploadProgressType[], corporateDisclosureUploadProgress: @@ -40,7 +42,9 @@ export const saveAndSubmitCaseAction = async ({ fileUploadProgressMap.petition as FileUploadProgressType, stinUploadProgress: fileUploadProgressMap.stin as FileUploadProgressType, - }); + }, + user, + ); stinFile = stinFileId; From 05d289cebb2d0e1cd239459daceff7ca56d6f0f4 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 10:28:44 -0700 Subject: [PATCH 397/523] 10417: fix unit tests --- shared/src/business/entities/cases/Case.ts | 1 - .../useCases/createCaseInteractor.test.ts | 11 +++++ .../getDownloadPolicyUrlInteractor.test.ts | 16 +++---- ...icesForCalendaredTrialSessionInteractor.ts | 2 - .../actions/createCaseAction.test.ts | 42 ++++++++++++------- .../computeds/startCaseHelper.test.ts | 2 + 6 files changed, 47 insertions(+), 27 deletions(-) diff --git a/shared/src/business/entities/cases/Case.ts b/shared/src/business/entities/cases/Case.ts index 6bedf71b78c..635f4d9e7f0 100644 --- a/shared/src/business/entities/cases/Case.ts +++ b/shared/src/business/entities/cases/Case.ts @@ -68,7 +68,6 @@ import { PrivatePractitioner } from '../PrivatePractitioner'; import { PublicCase } from '@shared/business/entities/cases/PublicCase'; import { Statistic } from '../Statistic'; import { TrialSession } from '../trialSessions/TrialSession'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { UnprocessableEntityError } from '../../../../../web-api/src/errors/errors'; import { User } from '../User'; import { clone, compact, includes, isEmpty, startCase } from 'lodash'; diff --git a/web-api/src/business/useCases/createCaseInteractor.test.ts b/web-api/src/business/useCases/createCaseInteractor.test.ts index 363c92d476a..1ccd9e0c555 100644 --- a/web-api/src/business/useCases/createCaseInteractor.test.ts +++ b/web-api/src/business/useCases/createCaseInteractor.test.ts @@ -318,6 +318,17 @@ describe('createCaseInteractor', () => { postalCode: '69580', state: 'AR', }, + contactSecondary: {}, + filingType: 'Myself', + hasIrsNotice: true, + partyType: PARTY_TYPES.petitioner, + petitionFile: new File([], 'test.pdf'), + petitionFileSize: 1, + preferredTrialCity: 'Fresno, California', + procedureType: 'Small', + signature: true, + stinFile: new File([], 'test.pdf'), + stinFileSize: 1, }, stinFileId: '96759830-8970-486f-916b-23439a8ebb70', }, diff --git a/web-api/src/business/useCases/document/getDownloadPolicyUrlInteractor.test.ts b/web-api/src/business/useCases/document/getDownloadPolicyUrlInteractor.test.ts index 1ba8d04519f..a346157f5ac 100644 --- a/web-api/src/business/useCases/document/getDownloadPolicyUrlInteractor.test.ts +++ b/web-api/src/business/useCases/document/getDownloadPolicyUrlInteractor.test.ts @@ -74,10 +74,6 @@ describe('getDownloadPolicyUrlInteractor', () => { }); it('should throw and error when requested document is a correspondence but the user is not internal', async () => { - applicationContext.getCurrentUser.mockReturnValueOnce({ - role: ROLES.petitioner, - userId: 'b5724655-1791-4a99-b0f6-f9bbe99c1db5', - }); const mockCorrespondenceId = applicationContext.getUniqueId(); mockCase.correspondence = [ { @@ -86,10 +82,14 @@ describe('getDownloadPolicyUrlInteractor', () => { ]; await expect( - getDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: MOCK_CASE.docketNumber, - key: mockCorrespondenceId, - }), + getDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: MOCK_CASE.docketNumber, + key: mockCorrespondenceId, + }, + mockPetitionerUser, + ), ).rejects.toThrow('Unauthorized'); }); diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts index 22838d2ddb4..6e93674eba8 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.ts @@ -164,8 +164,6 @@ const setNoticesForCalendaredTrialSession = async ( }); if (trialNoticePdfsKeys.length) { - // TODO 10417 should we do direct import here as part of this story? - // if so, we need to change how we're mocking in the tests. await applicationContext .getUseCases() .generateTrialSessionPaperServicePdfInteractor( diff --git a/web-client/src/presenter/actions/createCaseAction.test.ts b/web-client/src/presenter/actions/createCaseAction.test.ts index 120d918c5fb..05947c3121a 100644 --- a/web-client/src/presenter/actions/createCaseAction.test.ts +++ b/web-client/src/presenter/actions/createCaseAction.test.ts @@ -85,15 +85,19 @@ describe('createCaseAction', () => { }); expect(generateDocumentIds).toHaveBeenCalled(); - expect(generateDocumentIds).toHaveBeenCalledWith(expect.anything(), { - attachmentToPetitionUploadProgress: [ - fileUploadProgressMap.attachmentToPetition, - ], - corporateDisclosureUploadProgress: - fileUploadProgressMap.corporateDisclosure, - petitionUploadProgress: fileUploadProgressMap.petition, - stinUploadProgress: fileUploadProgressMap.stin, - }); + expect(generateDocumentIds).toHaveBeenCalledWith( + expect.anything(), + { + attachmentToPetitionUploadProgress: [ + fileUploadProgressMap.attachmentToPetition, + ], + corporateDisclosureUploadProgress: + fileUploadProgressMap.corporateDisclosure, + petitionUploadProgress: fileUploadProgressMap.petition, + stinUploadProgress: fileUploadProgressMap.stin, + }, + { email: 'petitioner1@example.com' }, + ); expect(createCaseInteractor).toHaveBeenCalled(); @@ -126,18 +130,24 @@ describe('createCaseAction', () => { ...fileUploadProgressMap, attachmentToPetition: undefined, }, + }, + state: { + form: mockPetitionMetadata, user: { email: 'petitioner1@example.com' }, }, - state: { form: mockPetitionMetadata }, }); expect(generateDocumentIds).toHaveBeenCalled(); - expect(generateDocumentIds).toHaveBeenCalledWith(expect.anything(), { - corporateDisclosureUploadProgress: - fileUploadProgressMap.corporateDisclosure, - petitionUploadProgress: fileUploadProgressMap.petition, - stinUploadProgress: fileUploadProgressMap.stin, - }); + expect(generateDocumentIds).toHaveBeenCalledWith( + expect.anything(), + { + corporateDisclosureUploadProgress: + fileUploadProgressMap.corporateDisclosure, + petitionUploadProgress: fileUploadProgressMap.petition, + stinUploadProgress: fileUploadProgressMap.stin, + }, + { email: 'petitioner1@example.com' }, + ); expect(createCaseInteractor).toHaveBeenCalled(); expect(createCaseInteractor).toHaveBeenCalledWith(expect.anything(), { diff --git a/web-client/src/presenter/computeds/startCaseHelper.test.ts b/web-client/src/presenter/computeds/startCaseHelper.test.ts index 49eb2d09de1..28e2ccbae5b 100644 --- a/web-client/src/presenter/computeds/startCaseHelper.test.ts +++ b/web-client/src/presenter/computeds/startCaseHelper.test.ts @@ -350,6 +350,7 @@ describe('startCaseHelper', () => { }, {}, ], + user: petitionerUser, }, }); @@ -361,6 +362,7 @@ describe('startCaseHelper', () => { state: { form: {}, irsNoticeUploadFormInfo: [{}, {}], + user: petitionerUser, }, }); From f3757cddf8d47824d37f9540bfad2035b043b183 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 11:03:27 -0700 Subject: [PATCH 398/523] 10417: fix type errors for appContext --- .../documentGenerators/caseInventoryReport.ts | 3 ++- .../noticeOfChangeOfTrialJudge.ts | 3 ++- .../noticeOfChangeToInPersonProceeding.ts | 3 ++- .../noticeOfChangeToRemoteProceeding.ts | 3 ++- .../noticeOfDocketChange.ts | 3 ++- .../noticeOfReceiptOfPetition.ts | 3 ++- .../documentGenerators/noticeOfTrialIssued.ts | 3 ++- .../noticeOfTrialIssuedInPerson.ts | 3 ++- .../utilities/documentGenerators/order.ts | 3 ++- .../documentGenerators/pendingReport.ts | 3 ++- .../documentGenerators/trialCalendar.ts | 3 ++- .../trialSessionPlanningReport.ts | 3 ++- .../getJudgeForUserHelper.test.ts | 25 ++++++++++--------- .../messages/forwardMessageInteractor.test.ts | 3 ++- .../generateNoticeOfTrialIssuedInteractor.ts | 2 +- web-client/integration-tests/helpers.ts | 3 +-- 16 files changed, 41 insertions(+), 28 deletions(-) diff --git a/shared/src/business/utilities/documentGenerators/caseInventoryReport.ts b/shared/src/business/utilities/documentGenerators/caseInventoryReport.ts index 71b15c0d458..824436773f0 100644 --- a/shared/src/business/utilities/documentGenerators/caseInventoryReport.ts +++ b/shared/src/business/utilities/documentGenerators/caseInventoryReport.ts @@ -1,6 +1,7 @@ import { CaseInventoryReport } from '@shared/business/utilities/pdfGenerator/documentTemplates/CaseInventoryReport'; import { DatePrintedFooter } from '@shared/business/utilities/pdfGenerator/components/DatePrintedFooter'; import { ReportsMetaHeader } from '@shared/business/utilities/pdfGenerator/components/ReportsMetaHeader'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -9,7 +10,7 @@ export const caseInventoryReport = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { formattedCases: { isLeadCase: boolean; diff --git a/shared/src/business/utilities/documentGenerators/noticeOfChangeOfTrialJudge.ts b/shared/src/business/utilities/documentGenerators/noticeOfChangeOfTrialJudge.ts index de45ad090e0..b20021c4556 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfChangeOfTrialJudge.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfChangeOfTrialJudge.ts @@ -1,6 +1,7 @@ import { DateServedFooter } from '@shared/business/utilities/pdfGenerator/components/DateServedFooter'; import { FormattedTrialInfoType } from '@web-api/business/useCases/trialSessions/generateNoticeOfTrialIssuedInteractor'; import { NoticeOfChangeOfTrialJudge } from '@shared/business/utilities/pdfGenerator/documentTemplates/NoticeOfChangeOfTrialJudge'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -9,7 +10,7 @@ export const noticeOfChangeOfTrialJudge = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { caseCaptionExtension: string; caseTitle: string; diff --git a/shared/src/business/utilities/documentGenerators/noticeOfChangeToInPersonProceeding.ts b/shared/src/business/utilities/documentGenerators/noticeOfChangeToInPersonProceeding.ts index 265fbc3c2b4..498988cdc00 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfChangeToInPersonProceeding.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfChangeToInPersonProceeding.ts @@ -1,6 +1,7 @@ import { DateServedFooter } from '@shared/business/utilities/pdfGenerator/components/DateServedFooter'; import { FormattedTrialInfo } from '@web-api/business/useCases/trialSessions/generateNoticeOfChangeOfTrialJudgeInteractor'; import { NoticeOfChangeToInPersonProceeding } from '@shared/business/utilities/pdfGenerator/documentTemplates/NoticeOfChangeToInPersonProceeding'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -9,7 +10,7 @@ export const noticeOfChangeToInPersonProceeding = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { caseCaptionExtension: string; caseTitle: string; diff --git a/shared/src/business/utilities/documentGenerators/noticeOfChangeToRemoteProceeding.ts b/shared/src/business/utilities/documentGenerators/noticeOfChangeToRemoteProceeding.ts index 192fd9452ca..d307a98296b 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfChangeToRemoteProceeding.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfChangeToRemoteProceeding.ts @@ -1,5 +1,6 @@ import { DateServedFooter } from '@shared/business/utilities/pdfGenerator/components/DateServedFooter'; import { NoticeOfChangeToRemoteProceeding } from '@shared/business/utilities/pdfGenerator/documentTemplates/NoticeOfChangeToRemoteProceeding'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialInfoType } from '@web-api/business/useCases/trialSessions/generateNoticeOfChangeToRemoteProceedingInteractor'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; @@ -9,7 +10,7 @@ export const noticeOfChangeToRemoteProceeding = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { nameOfClerk: string; titleOfClerk: string; diff --git a/shared/src/business/utilities/documentGenerators/noticeOfDocketChange.ts b/shared/src/business/utilities/documentGenerators/noticeOfDocketChange.ts index d07cd7002ed..033bd5c3eb2 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfDocketChange.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfDocketChange.ts @@ -1,4 +1,5 @@ import { NoticeOfDocketChange } from '@shared/business/utilities/pdfGenerator/documentTemplates/NoticeOfDocketChange'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -7,7 +8,7 @@ export const noticeOfDocketChange = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { nameOfClerk: string; titleOfClerk: string; diff --git a/shared/src/business/utilities/documentGenerators/noticeOfReceiptOfPetition.ts b/shared/src/business/utilities/documentGenerators/noticeOfReceiptOfPetition.ts index 16787e548e5..88e00ed25b0 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfReceiptOfPetition.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfReceiptOfPetition.ts @@ -1,5 +1,6 @@ import { NoticeOfReceiptOfPetition } from '@shared/business/utilities/pdfGenerator/documentTemplates/NoticeOfReceiptOfPetition'; import { RawContact } from '@shared/business/entities/contacts/Contact'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -8,7 +9,7 @@ export const noticeOfReceiptOfPetition = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { accessCode?: string; caseCaptionExtension: string; diff --git a/shared/src/business/utilities/documentGenerators/noticeOfTrialIssued.ts b/shared/src/business/utilities/documentGenerators/noticeOfTrialIssued.ts index cc89bb1f468..eac8c66cb02 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfTrialIssued.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfTrialIssued.ts @@ -1,5 +1,6 @@ import { DateServedFooter } from '@shared/business/utilities/pdfGenerator/components/DateServedFooter'; import { NoticeOfTrialIssued } from '@shared/business/utilities/pdfGenerator/documentTemplates/NoticeOfTrialIssued'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialInfoType } from '@web-api/business/useCases/trialSessions/generateNoticeOfChangeToRemoteProceedingInteractor'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; @@ -9,7 +10,7 @@ export const noticeOfTrialIssued = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { nameOfClerk: string; titleOfClerk: string; diff --git a/shared/src/business/utilities/documentGenerators/noticeOfTrialIssuedInPerson.ts b/shared/src/business/utilities/documentGenerators/noticeOfTrialIssuedInPerson.ts index 478cca32570..23f9c7ac146 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfTrialIssuedInPerson.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfTrialIssuedInPerson.ts @@ -1,6 +1,7 @@ import { DateServedFooter } from '@shared/business/utilities/pdfGenerator/components/DateServedFooter'; import { FormattedTrialInfoType } from '@web-api/business/useCases/trialSessions/generateNoticeOfTrialIssuedInteractor'; import { NoticeOfTrialIssuedInPerson } from '@shared/business/utilities/pdfGenerator/documentTemplates/NoticeOfTrialIssuedInPerson'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -9,7 +10,7 @@ export const noticeOfTrialIssuedInPerson = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { nameOfClerk: string; titleOfClerk: string; diff --git a/shared/src/business/utilities/documentGenerators/order.ts b/shared/src/business/utilities/documentGenerators/order.ts index 80d006ea99c..c74db18c9d0 100644 --- a/shared/src/business/utilities/documentGenerators/order.ts +++ b/shared/src/business/utilities/documentGenerators/order.ts @@ -1,5 +1,6 @@ import { Order } from '@shared/business/utilities/pdfGenerator/documentTemplates/Order'; import { PageMetaHeaderDocket } from '@shared/business/utilities/pdfGenerator/components/PageMetaHeaderDocket'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -8,7 +9,7 @@ export const order = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { caseCaptionExtension: string; caseTitle: string; diff --git a/shared/src/business/utilities/documentGenerators/pendingReport.ts b/shared/src/business/utilities/documentGenerators/pendingReport.ts index 633874a2ce8..323f063a863 100644 --- a/shared/src/business/utilities/documentGenerators/pendingReport.ts +++ b/shared/src/business/utilities/documentGenerators/pendingReport.ts @@ -2,6 +2,7 @@ import { DatePrintedFooter } from '@shared/business/utilities/pdfGenerator/compo import { PendingItemFormatted } from '@shared/business/utilities/formatPendingItem'; import { PendingReport } from '@shared/business/utilities/pdfGenerator/documentTemplates/PendingReport'; import { ReportsMetaHeader } from '@shared/business/utilities/pdfGenerator/components/ReportsMetaHeader'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -10,7 +11,7 @@ export const pendingReport = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { pendingItems: PendingItemFormatted[]; subtitle: string; diff --git a/shared/src/business/utilities/documentGenerators/trialCalendar.ts b/shared/src/business/utilities/documentGenerators/trialCalendar.ts index f38c6e89bfa..bc6fddb594f 100644 --- a/shared/src/business/utilities/documentGenerators/trialCalendar.ts +++ b/shared/src/business/utilities/documentGenerators/trialCalendar.ts @@ -1,6 +1,7 @@ import { DatePrintedFooter } from '@shared/business/utilities/pdfGenerator/components/DatePrintedFooter'; import { RawIrsCalendarAdministratorInfo } from '@shared/business/entities/trialSessions/IrsCalendarAdministratorInfo'; import { ReportsMetaHeader } from '@shared/business/utilities/pdfGenerator/components/ReportsMetaHeader'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialCalendar } from '@shared/business/utilities/pdfGenerator/documentTemplates/TrialCalendar'; import { TrialSessionProceedingType } from '@shared/business/entities/EntityConstants'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; @@ -46,7 +47,7 @@ export const trialCalendar = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: TrialCalendarType; }): Promise => { const { cases, sessionDetail } = data; diff --git a/shared/src/business/utilities/documentGenerators/trialSessionPlanningReport.ts b/shared/src/business/utilities/documentGenerators/trialSessionPlanningReport.ts index f3e70c7be87..fe30b926420 100644 --- a/shared/src/business/utilities/documentGenerators/trialSessionPlanningReport.ts +++ b/shared/src/business/utilities/documentGenerators/trialSessionPlanningReport.ts @@ -4,6 +4,7 @@ import { TrialLocationData, } from '@web-api/business/useCases/trialSessions/runTrialSessionPlanningReportInteractor'; import { ReportsMetaHeader } from '@shared/business/utilities/pdfGenerator/components/ReportsMetaHeader'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { TrialSessionPlanningReport } from '@shared/business/utilities/pdfGenerator/documentTemplates/TrialSessionPlanningReport'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; @@ -13,7 +14,7 @@ export const trialSessionPlanningReport = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: { locationData: TrialLocationData[]; previousTerms: PreviousTerm[]; diff --git a/web-api/src/business/useCaseHelper/getJudgeForUserHelper.test.ts b/web-api/src/business/useCaseHelper/getJudgeForUserHelper.test.ts index 15fc2c65038..3c14e71bc81 100644 --- a/web-api/src/business/useCaseHelper/getJudgeForUserHelper.test.ts +++ b/web-api/src/business/useCaseHelper/getJudgeForUserHelper.test.ts @@ -1,6 +1,11 @@ import { ROLES } from '@shared/business/entities/EntityConstants'; import { applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext'; import { getJudgeForUserHelper } from './getJudgeForUserHelper'; +import { + mockChambersUser, + mockDocketClerkUser, + mockJudgeUser, +} from '@shared/test/mockAuthUsers'; import { validUser } from '@shared/test/mockUsers'; describe('getJudgeForUserHelper', () => { @@ -32,11 +37,11 @@ describe('getJudgeForUserHelper', () => { describe('Judge User', () => { beforeAll(() => { - mockFoundUser = judgeUser; + mockFoundUser = mockJudgeUser; }); it('retrieves the specified user from the database by its userId', async () => { - await getJudgeForUserHelper(applicationContext, { user: judgeUser }); + await getJudgeForUserHelper(applicationContext, { user: mockJudgeUser }); expect( applicationContext.getPersistenceGateway().getUserById, @@ -48,9 +53,9 @@ describe('getJudgeForUserHelper', () => { it('returns the retrieved from the database', async () => { const result = await getJudgeForUserHelper(applicationContext, { - user: judgeUser, + user: mockJudgeUser, }); - expect(result).toMatchObject(judgeUser); + expect(result).toMatchObject(mockJudgeUser); }); }); @@ -64,7 +69,7 @@ describe('getJudgeForUserHelper', () => { it('calls getJudgeInSectionHelper with the retrieved user`s section if they are a chambers user', async () => { await getJudgeForUserHelper(applicationContext, { - user: chambersUser, + user: mockChambersUser, }); expect( @@ -75,12 +80,8 @@ describe('getJudgeForUserHelper', () => { }); it('returns the user that getJudgeInSectionHelper found', async () => { - await getJudgeForUserHelper(applicationContext, { - user: chambersUser, - }); - const result = await getJudgeForUserHelper(applicationContext, { - user: judgeUser, + user: mockJudgeUser, }); expect(result).toMatchObject(judgeUser); }); @@ -92,7 +93,7 @@ describe('getJudgeForUserHelper', () => { await expect( getJudgeForUserHelper(applicationContext, { - user: docketClerkUser, + user: mockDocketClerkUser, }), ).rejects.toThrow( `Could not find Judge for Chambers Section ${chambersUser.section}`, @@ -105,7 +106,7 @@ describe('getJudgeForUserHelper', () => { mockFoundUser = docketClerkUser; await expect( getJudgeForUserHelper(applicationContext, { - user: docketClerkUser, + user: mockDocketClerkUser, }), ).rejects.toThrow( 'Could not get Judge User ID for non Judge or Chambers User', diff --git a/web-api/src/business/useCases/messages/forwardMessageInteractor.test.ts b/web-api/src/business/useCases/messages/forwardMessageInteractor.test.ts index b44bf1dd0d2..a1b30268ca7 100644 --- a/web-api/src/business/useCases/messages/forwardMessageInteractor.test.ts +++ b/web-api/src/business/useCases/messages/forwardMessageInteractor.test.ts @@ -1,10 +1,11 @@ jest.mock('./replyToMessageInteractor'); import { forwardMessageInteractor } from './forwardMessageInteractor'; +import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { replyToMessage } from './replyToMessageInteractor'; describe('forwardMessageInteractor', () => { it('should call the replyToMessageInteractor with the given params', async () => { - await forwardMessageInteractor({} as any, {} as any); + await forwardMessageInteractor({} as any, {} as any, mockDocketClerkUser); expect(replyToMessage).toHaveBeenCalled(); }); diff --git a/web-api/src/business/useCases/trialSessions/generateNoticeOfTrialIssuedInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticeOfTrialIssuedInteractor.ts index 363c0d92f24..45470dc97bc 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticeOfTrialIssuedInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticeOfTrialIssuedInteractor.ts @@ -22,7 +22,7 @@ export const generateNoticeOfTrialIssuedInteractor = async ( docketNumber, trialSessionId, }: { docketNumber: string; trialSessionId: string }, -): Promise => { +): Promise => { const trialSession = await applicationContext .getPersistenceGateway() .getTrialSessionById({ diff --git a/web-client/integration-tests/helpers.ts b/web-client/integration-tests/helpers.ts index 616d67aa7e1..87f9111ee56 100644 --- a/web-client/integration-tests/helpers.ts +++ b/web-client/integration-tests/helpers.ts @@ -41,8 +41,7 @@ import jwt from 'jsonwebtoken'; import qs from 'qs'; import riotRoute from 'riot-route'; -const applicationContext = - clientApplicationContext as unknown as IApplicationContext; +const applicationContext = clientApplicationContext as any; const { CASE_TYPES_MAP, PARTY_TYPES, SERVICE_INDICATOR_TYPES } = applicationContext.getConstants(); From 019e57afc37ac301029d81a11dda8d3b0ffd2559 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 12:17:43 -0700 Subject: [PATCH 399/523] 10417: fix tests --- shared/src/business/entities/cases/Case.test.ts | 1 - shared/src/business/entities/cases/PublicCase.test.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/shared/src/business/entities/cases/Case.test.ts b/shared/src/business/entities/cases/Case.test.ts index 6a7568f0474..c595c9c4eca 100644 --- a/shared/src/business/entities/cases/Case.test.ts +++ b/shared/src/business/entities/cases/Case.test.ts @@ -92,7 +92,6 @@ describe('Case entity', () => { const myCase = new Case( { ...MOCK_CASE, isPaper: false, status: undefined }, { - applicationContext, authorizedUser: mockPetitionerUser, isNewCase: true, }, diff --git a/shared/src/business/entities/cases/PublicCase.test.ts b/shared/src/business/entities/cases/PublicCase.test.ts index f8b30d93835..4b68d732ddd 100644 --- a/shared/src/business/entities/cases/PublicCase.test.ts +++ b/shared/src/business/entities/cases/PublicCase.test.ts @@ -370,7 +370,6 @@ describe('PublicCase', () => { ], }; const entity = new PublicCase(rawCase, { - applicationContext, authorizedUser: mockPrivatePractitionerUser, }); From d7d75cb418a87e742f1ed51b706f397576090303 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 12:33:05 -0700 Subject: [PATCH 400/523] 10417 fix type errors --- .../utilities/documentGenerators/thirtyDayNoticeOfTrial.ts | 5 +++-- .../presenter/actions/countryTypeUserContactChangeAction.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/shared/src/business/utilities/documentGenerators/thirtyDayNoticeOfTrial.ts b/shared/src/business/utilities/documentGenerators/thirtyDayNoticeOfTrial.ts index 74f23697629..2b585b75913 100644 --- a/shared/src/business/utilities/documentGenerators/thirtyDayNoticeOfTrial.ts +++ b/shared/src/business/utilities/documentGenerators/thirtyDayNoticeOfTrial.ts @@ -1,4 +1,5 @@ import { DateServedFooter } from '@shared/business/utilities/pdfGenerator/components/DateServedFooter'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { ThirtyDayNoticeOfTrial, ThirtyDayNoticeOfTrialRequiredInfo, @@ -11,9 +12,9 @@ export const thirtyDayNoticeOfTrial = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: ThirtyDayNoticeOfTrialRequiredInfo; -}): Promise => { +}): Promise => { const thirtyDayNoticeOfTrialTemplate = ReactDOM.renderToString( React.createElement(ThirtyDayNoticeOfTrial, data), ); diff --git a/web-client/src/presenter/actions/countryTypeUserContactChangeAction.ts b/web-client/src/presenter/actions/countryTypeUserContactChangeAction.ts index 63541d8d72f..aedd3e29e2d 100644 --- a/web-client/src/presenter/actions/countryTypeUserContactChangeAction.ts +++ b/web-client/src/presenter/actions/countryTypeUserContactChangeAction.ts @@ -16,7 +16,7 @@ export const countryTypeUserContactChangeAction = ({ store }: ActionProps) => { 'state', 'city', ].forEach(field => { - store.unset(state.user.contact[field]); + store.unset((state.user as any).contact[field]); }); store.set(state.validationErrors.contact, {}); From d1a75f6af29ce1f85cc48c071893a897e8568831 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 13:15:46 -0700 Subject: [PATCH 401/523] 10417: WIP adding --- .../integration/advancedSearch/search.cy.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cypress/deployed-and-local/integration/advancedSearch/search.cy.ts b/cypress/deployed-and-local/integration/advancedSearch/search.cy.ts index 816cd85a671..1df0b19a62f 100644 --- a/cypress/deployed-and-local/integration/advancedSearch/search.cy.ts +++ b/cypress/deployed-and-local/integration/advancedSearch/search.cy.ts @@ -10,9 +10,12 @@ import { } from '../../../helpers/authentication/login-as-helpers'; describe('Advanced Search', () => { - it('should find a served paper case when the user searches by party name or docket number', () => { + beforeEach(() => { + Cypress.session.clearCurrentSessionData(); + }); + + it.only('should find a served paper case when the user searches by party name or docket number', () => { /** Arrange */ - loginAsPetitionsClerk1(); createAndServePaperPetition().then(({ docketNumber, name }) => { /** Act */ cy.get('[data-testid="search-link"]').click(); From 51bf10a1b57f47720d44a1a8e3de2dc991d9cf2f Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 14:19:01 -0700 Subject: [PATCH 402/523] 10417: Update login when creating and serving paper petitions --- .../integration/advancedSearch/search.cy.ts | 2 +- .../helpers/fileAPetition/create-and-serve-paper-petition.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cypress/deployed-and-local/integration/advancedSearch/search.cy.ts b/cypress/deployed-and-local/integration/advancedSearch/search.cy.ts index 1df0b19a62f..e75979b072c 100644 --- a/cypress/deployed-and-local/integration/advancedSearch/search.cy.ts +++ b/cypress/deployed-and-local/integration/advancedSearch/search.cy.ts @@ -14,7 +14,7 @@ describe('Advanced Search', () => { Cypress.session.clearCurrentSessionData(); }); - it.only('should find a served paper case when the user searches by party name or docket number', () => { + it('should find a served paper case when the user searches by party name or docket number', () => { /** Arrange */ createAndServePaperPetition().then(({ docketNumber, name }) => { /** Act */ diff --git a/cypress/helpers/fileAPetition/create-and-serve-paper-petition.ts b/cypress/helpers/fileAPetition/create-and-serve-paper-petition.ts index 1f71df09beb..9780a655748 100644 --- a/cypress/helpers/fileAPetition/create-and-serve-paper-petition.ts +++ b/cypress/helpers/fileAPetition/create-and-serve-paper-petition.ts @@ -1,8 +1,10 @@ +import { loginAsPetitionsClerk1 } from '../authentication/login-as-helpers'; + export function createAndServePaperPetition( options = { yearReceived: '2020' }, ) { const name = 'rick james ' + Date.now(); - cy.login('petitionsclerk1'); + loginAsPetitionsClerk1(); cy.get('[data-testid="inbox-tab-content"]').should('exist'); cy.get('[data-testid="document-qc-nav-item"]').click(); cy.get('[data-testid="start-a-petition"]').click(); From 95b546e4db5f3e4e153de70898c0f3697ab348bb Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 29 Jul 2024 17:09:50 -0500 Subject: [PATCH 403/523] 10417 fix type errors, add auth user check to start polling interactor --- .../authorizationClientService.ts | 34 +++++++++---------- .../src/business/entities/DocketEntry.test.ts | 4 +-- shared/src/business/entities/User.ts | 2 +- ...neratePractitionerCaseListPdfInteractor.ts | 3 +- .../noticeOfChangeOfTrialJudge.ts | 2 +- .../noticeOfChangeToRemoteProceeding.ts | 2 +- .../documentGenerators/pendingReport.ts | 2 +- .../documentGenerators/trialCalendar.ts | 2 +- .../trialSessionPlanningReport.ts | 2 +- .../utilities/serveCaseDocument.test.ts | 2 +- .../useCases/auth/changePasswordInteractor.ts | 3 +- .../startPollingForResultsInteractor.test.ts | 21 ++++++++++++ .../startPollingForResultsInteractor.ts | 12 ++++++- 13 files changed, 61 insertions(+), 30 deletions(-) diff --git a/shared/src/authorization/authorizationClientService.ts b/shared/src/authorization/authorizationClientService.ts index 19c5136bbbc..b88f40ce9e1 100644 --- a/shared/src/authorization/authorizationClientService.ts +++ b/shared/src/authorization/authorizationClientService.ts @@ -91,7 +91,7 @@ export const ROLE_PERMISSIONS = { export type RolePermission = (typeof ROLE_PERMISSIONS)[keyof typeof ROLE_PERMISSIONS]; -const allInternalUserPermissions = [ +const allInternalUserPermissions: RolePermission[] = [ ROLE_PERMISSIONS.ADD_CASE_TO_TRIAL_SESSION, ROLE_PERMISSIONS.ADVANCED_SEARCH, ROLE_PERMISSIONS.ARCHIVE_DOCUMENT, @@ -124,21 +124,21 @@ const allInternalUserPermissions = [ ROLE_PERMISSIONS.COLD_CASE_REPORT, ]; -const adcPermissions = [ +const adcPermissions: RolePermission[] = [ ...allInternalUserPermissions, ROLE_PERMISSIONS.CREATE_TRIAL_SESSION, ROLE_PERMISSIONS.SEND_RECEIVE_MESSAGES, ROLE_PERMISSIONS.STAMP_MOTION, ]; -const adminPermissions = [ +const adminPermissions: RolePermission[] = [ ROLE_PERMISSIONS.ADD_EDIT_JUDGE_USER, ROLE_PERMISSIONS.ADD_EDIT_PRACTITIONER_USER, ROLE_PERMISSIONS.CREATE_USER, ROLE_PERMISSIONS.MANAGE_PRACTITIONER_USERS, ]; -const admissionsClerkPermissions = [ +const admissionsClerkPermissions: RolePermission[] = [ ...allInternalUserPermissions, ROLE_PERMISSIONS.ADD_EDIT_PRACTITIONER_USER, ROLE_PERMISSIONS.ADD_USER_TO_CASE, @@ -153,7 +153,7 @@ const admissionsClerkPermissions = [ ROLE_PERMISSIONS.VIEW_SEALED_ADDRESS, ]; -const chambersPermissions = [ +const chambersPermissions: RolePermission[] = [ ...allInternalUserPermissions, ROLE_PERMISSIONS.BATCH_DOWNLOAD_TRIAL_SESSION, ROLE_PERMISSIONS.PENDING_MOTIONS_TABLE, @@ -166,7 +166,7 @@ const chambersPermissions = [ ROLE_PERMISSIONS.SEND_RECEIVE_MESSAGES, ]; -const docketClerkPermissions = [ +const docketClerkPermissions: RolePermission[] = [ ...allInternalUserPermissions, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS, ROLE_PERMISSIONS.ADD_PETITIONER_TO_CASE, @@ -194,13 +194,13 @@ const docketClerkPermissions = [ ROLE_PERMISSIONS.VIEW_SEALED_ADDRESS, ]; -const generalUserPermissions = [ +const generalUserPermissions: RolePermission[] = [ ...allInternalUserPermissions, ROLE_PERMISSIONS.CASE_CORRESPONDENCE, ROLE_PERMISSIONS.CREATE_TRIAL_SESSION, ]; -const petitionsClerkPermissions = [ +const petitionsClerkPermissions: RolePermission[] = [ ...allInternalUserPermissions, ROLE_PERMISSIONS.ADD_EDIT_STATISTICS, ROLE_PERMISSIONS.ASSIGN_WORK_ITEM, @@ -221,7 +221,7 @@ const petitionsClerkPermissions = [ ROLE_PERMISSIONS.DISMISS_NOTT_REMINDER, ]; -const irsPractitionerPermissions = [ +const irsPractitionerPermissions: RolePermission[] = [ ROLE_PERMISSIONS.ADVANCED_SEARCH, ROLE_PERMISSIONS.ASSOCIATE_SELF_WITH_CASE, ROLE_PERMISSIONS.EMAIL_MANAGEMENT, @@ -235,7 +235,7 @@ const irsPractitionerPermissions = [ ROLE_PERMISSIONS.VIEW_DOCUMENTS, ]; -const irsSuperuserPermissions = [ +const irsSuperuserPermissions: RolePermission[] = [ ROLE_PERMISSIONS.ADVANCED_SEARCH, ROLE_PERMISSIONS.GET_CASE, ROLE_PERMISSIONS.GET_JUDGES, @@ -245,7 +245,7 @@ const irsSuperuserPermissions = [ ROLE_PERMISSIONS.VIEW_SEALED_CASE, ]; -const judgePermissions = [ +const judgePermissions: RolePermission[] = [ ...allInternalUserPermissions, ROLE_PERMISSIONS.BATCH_DOWNLOAD_TRIAL_SESSION, ROLE_PERMISSIONS.JUDGES_NOTES, @@ -258,7 +258,7 @@ const judgePermissions = [ ROLE_PERMISSIONS.DOCKET_ENTRY_WORKSHEET, ]; -const petitionerPermissions = [ +const petitionerPermissions: RolePermission[] = [ ROLE_PERMISSIONS.EMAIL_MANAGEMENT, ROLE_PERMISSIONS.FILE_EXTERNAL_DOCUMENT, ROLE_PERMISSIONS.GET_USER_PENDING_EMAIL_STATUS, @@ -269,7 +269,7 @@ const petitionerPermissions = [ ROLE_PERMISSIONS.VIEW_CONSOLIDATED_CASES_CARD, ]; -const privatePractitionerPermissions = [ +const privatePractitionerPermissions: RolePermission[] = [ ROLE_PERMISSIONS.GET_USER_PENDING_EMAIL_STATUS, ROLE_PERMISSIONS.ADVANCED_SEARCH, ROLE_PERMISSIONS.ASSOCIATE_SELF_WITH_CASE, @@ -284,7 +284,7 @@ const privatePractitionerPermissions = [ ROLE_PERMISSIONS.VIEW_DOCUMENTS, ]; -const trialClerkPermissions = [ +const trialClerkPermissions: RolePermission[] = [ ...allInternalUserPermissions, ROLE_PERMISSIONS.BATCH_DOWNLOAD_TRIAL_SESSION, ROLE_PERMISSIONS.CREATE_TRIAL_SESSION, @@ -313,11 +313,11 @@ export const AUTHORIZATION_MAP = { ROLE_PERMISSIONS.SEND_RECEIVE_MESSAGES, ], general: generalUserPermissions, - inactivePractitioner: [], + inactivePractitioner: [] as RolePermission[], irsPractitioner: irsPractitionerPermissions, irsSuperuser: irsSuperuserPermissions, judge: judgePermissions, - legacyJudge: [], + legacyJudge: [] as RolePermission[], petitioner: petitionerPermissions, petitionsclerk: petitionsClerkPermissions, privatePractitioner: privatePractitionerPermissions, @@ -326,7 +326,7 @@ export const AUTHORIZATION_MAP = { ROLE_PERMISSIONS.SEND_RECEIVE_MESSAGES, ], trialclerk: trialClerkPermissions, -} as const; +}; export const isAuthorized = ( user: UnknownAuthUser, diff --git a/shared/src/business/entities/DocketEntry.test.ts b/shared/src/business/entities/DocketEntry.test.ts index ac1f4522c75..d88ad6c5d0f 100644 --- a/shared/src/business/entities/DocketEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.test.ts @@ -548,7 +548,6 @@ describe('DocketEntry entity', () => { }; const docketEntryEntity = new DocketEntry(docketEntry, { - applicationContext, authorizedUser: mockDocketClerkUser, filtered: true, petitioners: MOCK_PETITIONERS, @@ -584,7 +583,7 @@ describe('DocketEntry entity', () => { ); expect(docketEntryEntity.userId).toEqual(docketEntry.userId); expect(docketEntryEntity.workItem).toEqual( - new WorkItem(docketEntry.workItem, { applicationContext }), + new WorkItem(docketEntry.workItem), ); }); @@ -616,7 +615,6 @@ describe('DocketEntry entity', () => { }; const docketEntryEntity = new DocketEntry(docketEntry, { - applicationContext, authorizedUser: mockPetitionerUser, filtered: true, petitioners: MOCK_PETITIONERS, diff --git a/shared/src/business/entities/User.ts b/shared/src/business/entities/User.ts index 91da0353c7a..689aa0e01e2 100644 --- a/shared/src/business/entities/User.ts +++ b/shared/src/business/entities/User.ts @@ -177,7 +177,7 @@ export class User extends JoiValidationEntity { } static isInternalUser(role?: Role): boolean { - const internalRoles: Role[] = [ + const internalRoles: (Role | undefined)[] = [ ROLES.adc, ROLES.admissionsClerk, ROLES.chambers, diff --git a/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.ts b/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.ts index 64f356881eb..c264925efe5 100644 --- a/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.ts +++ b/shared/src/business/useCases/generatePractitionerCaseListPdfInteractor.ts @@ -3,6 +3,7 @@ import { ROLE_PERMISSIONS, isAuthorized, } from '../../authorization/authorizationClientService'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { partition } from 'lodash'; @@ -16,7 +17,7 @@ import { partition } from 'lodash'; * @returns {Object} returns an object of the PDF's fileId and url */ export const generatePractitionerCaseListPdfInteractor = async ( - applicationContext: IApplicationContext, + applicationContext: ServerApplicationContext, { userId }: { userId: string }, authorizedUser: UnknownAuthUser, ) => { diff --git a/shared/src/business/utilities/documentGenerators/noticeOfChangeOfTrialJudge.ts b/shared/src/business/utilities/documentGenerators/noticeOfChangeOfTrialJudge.ts index b20021c4556..b204a9e39f2 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfChangeOfTrialJudge.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfChangeOfTrialJudge.ts @@ -19,7 +19,7 @@ export const noticeOfChangeOfTrialJudge = async ({ titleOfClerk: string; trialInfo: FormattedTrialInfoType; }; -}): Promise => { +}): Promise => { const { docketNumberWithSuffix } = data; const noticeOfChangeOfTrialJudgeTemplate = ReactDOM.renderToString( diff --git a/shared/src/business/utilities/documentGenerators/noticeOfChangeToRemoteProceeding.ts b/shared/src/business/utilities/documentGenerators/noticeOfChangeToRemoteProceeding.ts index d307a98296b..eb11e92a5ed 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfChangeToRemoteProceeding.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfChangeToRemoteProceeding.ts @@ -19,7 +19,7 @@ export const noticeOfChangeToRemoteProceeding = async ({ docketNumberWithSuffix: string; trialInfo: TrialInfoType; }; -}): Promise => { +}): Promise => { const { docketNumberWithSuffix } = data; const noticeOfChangeToRemoteProceedingTemplate = ReactDOM.renderToString( diff --git a/shared/src/business/utilities/documentGenerators/pendingReport.ts b/shared/src/business/utilities/documentGenerators/pendingReport.ts index 323f063a863..637d30f4b83 100644 --- a/shared/src/business/utilities/documentGenerators/pendingReport.ts +++ b/shared/src/business/utilities/documentGenerators/pendingReport.ts @@ -16,7 +16,7 @@ export const pendingReport = async ({ pendingItems: PendingItemFormatted[]; subtitle: string; }; -}): Promise => { +}): Promise => { const { pendingItems, subtitle } = data; const pendingReportTemplate = ReactDOM.renderToString( diff --git a/shared/src/business/utilities/documentGenerators/trialCalendar.ts b/shared/src/business/utilities/documentGenerators/trialCalendar.ts index bc6fddb594f..f3ccfb608b5 100644 --- a/shared/src/business/utilities/documentGenerators/trialCalendar.ts +++ b/shared/src/business/utilities/documentGenerators/trialCalendar.ts @@ -49,7 +49,7 @@ export const trialCalendar = async ({ }: { applicationContext: ServerApplicationContext; data: TrialCalendarType; -}): Promise => { +}): Promise => { const { cases, sessionDetail } = data; const trialCalendarTemplate = ReactDOM.renderToString( diff --git a/shared/src/business/utilities/documentGenerators/trialSessionPlanningReport.ts b/shared/src/business/utilities/documentGenerators/trialSessionPlanningReport.ts index fe30b926420..57192b348ca 100644 --- a/shared/src/business/utilities/documentGenerators/trialSessionPlanningReport.ts +++ b/shared/src/business/utilities/documentGenerators/trialSessionPlanningReport.ts @@ -20,7 +20,7 @@ export const trialSessionPlanningReport = async ({ previousTerms: PreviousTerm[]; term: string; }; -}): Promise => { +}): Promise => { const { locationData, previousTerms, term } = data; const trialSessionPlanningReportTemplate = ReactDOM.renderToString( diff --git a/shared/src/business/utilities/serveCaseDocument.test.ts b/shared/src/business/utilities/serveCaseDocument.test.ts index 3179e6138fd..1fda5965c51 100644 --- a/shared/src/business/utilities/serveCaseDocument.test.ts +++ b/shared/src/business/utilities/serveCaseDocument.test.ts @@ -153,7 +153,7 @@ describe('serveCaseDocument', () => { }, ], }, - { applicationContext }, + { authorizedUser: undefined }, ); await serveCaseDocument({ diff --git a/web-api/src/business/useCases/auth/changePasswordInteractor.ts b/web-api/src/business/useCases/auth/changePasswordInteractor.ts index bc577db1cb1..9f8f302b567 100644 --- a/web-api/src/business/useCases/auth/changePasswordInteractor.ts +++ b/web-api/src/business/useCases/auth/changePasswordInteractor.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { ChangePasswordForm } from '@shared/business/entities/ChangePasswordForm'; import { InvalidEntityError, NotFoundError } from '@web-api/errors/errors'; import { MESSAGE_TYPES } from '@web-api/gateways/worker/workerRouter'; @@ -73,7 +74,7 @@ export const changePasswordInteractor = async ( .getWorkerGateway() .queueWork(applicationContext, { message: { - authorizedUser: updatedUser, + authorizedUser: updatedUser as AuthUser, // In this context, we know for certain that the user has an email address, and is assignable to AuthUser. payload: { user: updatedUser }, type: MESSAGE_TYPES.QUEUE_UPDATE_ASSOCIATED_CASES, }, diff --git a/web-api/src/business/useCases/polling/startPollingForResultsInteractor.test.ts b/web-api/src/business/useCases/polling/startPollingForResultsInteractor.test.ts index b8a6da2b515..9bea5e1f5b3 100644 --- a/web-api/src/business/useCases/polling/startPollingForResultsInteractor.test.ts +++ b/web-api/src/business/useCases/polling/startPollingForResultsInteractor.test.ts @@ -1,3 +1,4 @@ +import { UnauthorizedError } from '@web-api/errors/errors'; import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; import { startPollingForResultsInteractor } from '@web-api/business/useCases/polling/startPollingForResultsInteractor'; @@ -66,6 +67,26 @@ describe('startPollingForResultsInteractor', () => { expect(results).toEqual(undefined); }); + it('should throw an error when the user is not an auth user', async () => { + applicationContext.getPersistenceGateway().getRequestResults = jest + .fn() + .mockResolvedValue([]); + + await expect( + startPollingForResultsInteractor( + applicationContext, + { + requestId: TEST_REQUEST_ID, + }, + undefined, + ), + ).rejects.toThrow( + new UnauthorizedError( + 'User attempting to poll for results is not an auth user', + ), + ); + }); + it('should returned undefined if all the records are not yet saved in the database', async () => { applicationContext.getPersistenceGateway().getRequestResults = jest .fn() diff --git a/web-api/src/business/useCases/polling/startPollingForResultsInteractor.ts b/web-api/src/business/useCases/polling/startPollingForResultsInteractor.ts index 2753e3c8463..9c8c788c161 100644 --- a/web-api/src/business/useCases/polling/startPollingForResultsInteractor.ts +++ b/web-api/src/business/useCases/polling/startPollingForResultsInteractor.ts @@ -1,11 +1,21 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { UnauthorizedError } from '@web-api/errors/errors'; +import { + UnknownAuthUser, + isAuthUser, +} from '@shared/business/entities/authUser/AuthUser'; export const startPollingForResultsInteractor = async ( applicationContext: ServerApplicationContext, { requestId }: { requestId: string }, authorizedUser: UnknownAuthUser, ): Promise<{ response: any } | undefined> => { + if (!isAuthUser(authorizedUser)) { + throw new UnauthorizedError( + 'User attempting to poll for results is not an auth user', + ); + } + const records = await applicationContext .getPersistenceGateway() .getRequestResults({ From 45d4b906ba1bc211ded432d67d598ad0b193ae0b Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 15:46:06 -0700 Subject: [PATCH 404/523] 10417: Update type errors. Pass in authUser --- .../useCaseHelper/saveFileAndGenerateUrl.ts | 2 +- .../getPublicDownloadPolicyUrlInteractor.ts | 1 - .../batchDownloadTrialSessionInteractor.ts | 20 ++++++++------- ...aredTrialSessionInteractor.locking.test.ts | 5 +++- ...orCalendaredTrialSessionInteractor.test.ts | 10 +++++++- .../updatePetitionerInformationInteractor.ts | 1 + web-api/src/gateways/worker/worker.test.ts | 3 ++- .../cases/deleteCounselFromCaseLambda.ts | 25 ++++++++----------- 8 files changed, 38 insertions(+), 29 deletions(-) diff --git a/web-api/src/business/useCaseHelper/saveFileAndGenerateUrl.ts b/web-api/src/business/useCaseHelper/saveFileAndGenerateUrl.ts index ac145106111..84794b5f14f 100644 --- a/web-api/src/business/useCaseHelper/saveFileAndGenerateUrl.ts +++ b/web-api/src/business/useCaseHelper/saveFileAndGenerateUrl.ts @@ -9,7 +9,7 @@ export const saveFileAndGenerateUrl = async ({ useTempBucket = false, }: { applicationContext: ServerApplicationContext; - file: Buffer; + file: WithImplicitCoercion; fileNamePrefix?: string; contentType?: string; useTempBucket?: boolean; diff --git a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts index 4493995eb96..1178821ca82 100644 --- a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts +++ b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.ts @@ -74,7 +74,6 @@ export const getPublicDownloadPolicyUrlInteractor = async ( isTerminalUser, rawCase: caseToCheck, user: { - name: '', role: ROLES.petitioner, userId: '', }, diff --git a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts index bb9e7a2c1a8..c1f05e3795a 100644 --- a/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/batchDownloadTrialSessionInteractor.ts @@ -32,21 +32,23 @@ export const batchDownloadTrialSessionInteractor = async ( authorizedUser, ); } catch (error: any) { - const { userId } = authorizedUser; + const userId = authorizedUser?.userId; const erMsg = error.message || 'unknown error'; applicationContext.logger.error( `Error when batch downloading trial session with id ${trialSessionId} - ${erMsg}`, { error }, ); - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - message: { - action: 'batch_download_error', - error, - }, - userId, - }); + if (userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + message: { + action: 'batch_download_error', + error, + }, + userId, + }); + } } }; diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts index 2058b805aa7..70f829a5954 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts @@ -82,7 +82,10 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { { ...MOCK_CASE, docketNumber: '100-23' }, { ...MOCK_CASE, docketNumber: '101-23' }, ]; - let mockRequest = { trialSessionId }; + let mockRequest = { + clientConnectionId: '8916f743-a22d-4946-ab06-57ddcf386912', + trialSessionId, + }; let mockLock; beforeEach(() => { diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.ts index 06ee3936104..cca1883314b 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.test.ts @@ -9,6 +9,7 @@ import { setNoticesForCalendaredTrialSessionInteractor } from './setNoticesForCa describe('setNoticesForCalendaredTrialSessionInteractor', () => { const trialSessionId = '6805d1ab-18d0-43ec-bafb-654e83405416'; + const clientConnectionId = '334304ba-79e6-4a1d-bd36-1e61f657a7ff'; beforeEach(() => { applicationContext @@ -54,7 +55,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { .mockImplementation((cb): ReturnType => { // eslint-disable-next-line promise/no-callback-in-promise (cb() as any).then(cb); - return undefined; + return undefined as any; }); }); @@ -65,6 +66,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, { + clientConnectionId, trialSessionId, }, mockPetitionerUser, @@ -84,6 +86,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, { + clientConnectionId, trialSessionId, }, mockPetitionsClerkUser, @@ -105,6 +108,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, { + clientConnectionId, trialSessionId, }, mockPetitionsClerkUser, @@ -123,6 +127,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, { + clientConnectionId, trialSessionId, }, mockPetitionsClerkUser, @@ -139,6 +144,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, { + clientConnectionId, trialSessionId, }, mockPetitionsClerkUser, @@ -164,6 +170,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, { + clientConnectionId, trialSessionId, }, mockPetitionsClerkUser, @@ -187,6 +194,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { await setNoticesForCalendaredTrialSessionInteractor( applicationContext, { + clientConnectionId, trialSessionId, }, mockPetitionsClerkUser, diff --git a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts index 0c9ef452e44..9a5c10463cf 100644 --- a/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updatePetitionerInformationInteractor.ts @@ -245,6 +245,7 @@ export const updatePetitionerInformation = async ( .getUseCaseHelpers() .generateAndServeDocketEntry({ applicationContext, + authorizedUser, caseEntity, documentType: documentTypeToGenerate, newData, diff --git a/web-api/src/gateways/worker/worker.test.ts b/web-api/src/gateways/worker/worker.test.ts index ab4c28a6bfc..474e1bb9c54 100644 --- a/web-api/src/gateways/worker/worker.test.ts +++ b/web-api/src/gateways/worker/worker.test.ts @@ -9,8 +9,9 @@ describe('worker', () => { it('should use the messaging service to send the provided message to the environment`s message queue', async () => { const mockMessage: WorkerMessage = { authorizedUser: { + email: 'person@hello.com', name: 'ignored', - role: 'ignored', + role: 'adc', userId: 'ignored', }, payload: { diff --git a/web-api/src/lambdas/cases/deleteCounselFromCaseLambda.ts b/web-api/src/lambdas/cases/deleteCounselFromCaseLambda.ts index 81930b7689c..ca48af23c67 100644 --- a/web-api/src/lambdas/cases/deleteCounselFromCaseLambda.ts +++ b/web-api/src/lambdas/cases/deleteCounselFromCaseLambda.ts @@ -1,4 +1,5 @@ import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; +import { deleteCounselFromCaseInteractor } from '@web-api/business/useCases/caseAssociation/deleteCounselFromCaseInteractor'; import { genericHandler } from '../../genericHandler'; /** @@ -11,18 +12,12 @@ export const deleteCounselFromCaseLambda = ( event, authorizedUser: UnknownAuthUser, ) => - genericHandler( - event, - async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .deleteCounselFromCaseInteractor( - applicationContext, - { - ...event.pathParameters, - }, - authorizedUser, - ); - }, - authorizedUser, - ); + genericHandler(event, async ({ applicationContext }) => { + return await deleteCounselFromCaseInteractor( + applicationContext, + { + ...event.pathParameters, + }, + authorizedUser, + ); + }); From 1ef377da58b8d696c51ef1bd6cbef9d46e8b10ac Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 15:57:58 -0700 Subject: [PATCH 405/523] 10417: Update type errors. Create a system user when sealing in lower environmnt --- .../cases/sealInLowerEnvironmentLambda.ts | 8 ++++++- .../getPaperServicePdfUrlLambda.ts | 3 +-- web-api/src/lambdas/v1/getCaseLambda.test.ts | 24 +++++-------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/web-api/src/lambdas/cases/sealInLowerEnvironmentLambda.ts b/web-api/src/lambdas/cases/sealInLowerEnvironmentLambda.ts index 9e28d310e38..694b9a4fb56 100644 --- a/web-api/src/lambdas/cases/sealInLowerEnvironmentLambda.ts +++ b/web-api/src/lambdas/cases/sealInLowerEnvironmentLambda.ts @@ -1,3 +1,4 @@ +import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createApplicationContext } from '../../applicationContext'; import { sealInLowerEnvironment } from '@web-api/business/useCaseHelper/sealInLowerEnvironment'; @@ -8,7 +9,12 @@ import { sealInLowerEnvironment } from '@web-api/business/useCaseHelper/sealInLo * @returns {Promise<*>|undefined} the response to the topic */ export const sealInLowerEnvironmentLambda = async event => { - const user = { role: 'docketclerk' }; + const user: AuthUser = { + email: 'system@ustc.gov', + name: 'ustc automated system', + role: 'docketclerk', + userId: 'N/A', + }; const applicationContext = createApplicationContext(user); diff --git a/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts b/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts index efd8aed1bc2..b098ae1f646 100644 --- a/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts +++ b/web-api/src/lambdas/trialSessions/getPaperServicePdfUrlLambda.ts @@ -1,10 +1,9 @@ -import { APIGatewayProxyEvent } from 'aws-lambda'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { genericHandler } from '../../genericHandler'; import { getPaperServicePdfUrlInteractor } from '@shared/business/useCases/getPaperServicePdfUrlInteractor'; export const getPaperServicePdfUrlLambda = ( - event: APIGatewayProxyEvent, + event, authorizedUser: UnknownAuthUser, ) => genericHandler( diff --git a/web-api/src/lambdas/v1/getCaseLambda.test.ts b/web-api/src/lambdas/v1/getCaseLambda.test.ts index f4da9333ab9..68181663318 100644 --- a/web-api/src/lambdas/v1/getCaseLambda.test.ts +++ b/web-api/src/lambdas/v1/getCaseLambda.test.ts @@ -98,7 +98,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG // disable logging by mimicking CI for this test beforeAll(() => { ({ CI } = process.env); - process.env.CI = true; + process.env.CI = 'true'; }); afterAll(() => (process.env.CI = CI)); @@ -112,7 +112,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser, {}); + const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -129,7 +129,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser, {}); + const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); @@ -152,11 +152,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda( - REQUEST_EVENT, - mockDocketClerkUser, - {}, - ); + const response = await getCaseLambda(REQUEST_EVENT, mockDocketClerkUser); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -173,11 +169,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: true, }); - const response = await getCaseLambda( - REQUEST_EVENT, - mockDocketClerkUser, - {}, - ); + const response = await getCaseLambda(REQUEST_EVENT, mockDocketClerkUser); expect(response.statusCode).toBe(500); expect(response.headers['Content-Type']).toBe('application/json'); @@ -197,11 +189,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda( - REQUEST_EVENT, - mockDocketClerkUser, - {}, - ); + const response = await getCaseLambda(REQUEST_EVENT, mockDocketClerkUser); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); From 4497fd446d8389c58add28651f17a1dada7043c2 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 16:15:58 -0700 Subject: [PATCH 406/523] 10417: Update type errors. Create a system user when sealing in lower environmnt --- web-api/src/lambdaWrapper.ts | 5 ++-- .../v1/getDocumentDownloadUrlLambda.test.ts | 11 ++++----- web-api/src/lambdas/v2/getCaseLambda.test.ts | 24 +++++-------------- .../v2/getDocumentDownloadUrlLambda.test.ts | 22 ++++++----------- .../src/middleware/apiGatewayHelper.test.ts | 4 ++-- .../presenter/computeds/alertHelper.test.ts | 2 +- 6 files changed, 24 insertions(+), 44 deletions(-) diff --git a/web-api/src/lambdaWrapper.ts b/web-api/src/lambdaWrapper.ts index 03b943af5e2..6d9bc78bec8 100644 --- a/web-api/src/lambdaWrapper.ts +++ b/web-api/src/lambdaWrapper.ts @@ -1,3 +1,4 @@ +import { ServerApplicationContext } from '@web-api/applicationContext'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { get } from 'lodash'; import { getCurrentInvoke } from '@vendia/serverless-express'; @@ -22,7 +23,7 @@ const defaultOptions: { export const lambdaWrapper = ( lambda: (awsEvent: any, user?: UnknownAuthUser) => any, options = defaultOptions, - applicationContext?: IApplicationContext, + applicationContext?: ServerApplicationContext, ) => { return async (req, res) => { // 'shouldMimicApiGatewayAsyncEndpoint' flag is set to mimic how API gateway async endpoints work locally. @@ -65,7 +66,7 @@ export const lambdaWrapper = ( const { asyncsyncid } = req.headers; - if (options.isAsyncSync && asyncsyncid && applicationContext) { + if (options.isAsyncSync && asyncsyncid && applicationContext && user) { try { const fullResponse = { ...response, diff --git a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts index da9e4c27f14..f2246fe2bd5 100644 --- a/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts +++ b/web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts @@ -76,7 +76,7 @@ describe('getDocumentDownloadUrlLambda', () => { // disable logging by mimicking CI for this test beforeAll(() => { ({ CI } = process.env); - process.env.CI = true; + process.env.CI = 'true'; }); afterAll(() => (process.env.CI = CI)); @@ -90,7 +90,10 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: false, }); - const response = await getDocumentDownloadUrlLambda(REQUEST_EVENT, {}); + const response = await getDocumentDownloadUrlLambda( + REQUEST_EVENT, + undefined, + ); expect(response.statusCode).toBe(403); expect(response.headers['Content-Type']).toBe('application/json'); @@ -114,7 +117,6 @@ describe('getDocumentDownloadUrlLambda', () => { const response = await getDocumentDownloadUrlLambda( request, mockPetitionerUser, - {}, ); expect(response.statusCode).toBe(404); @@ -157,7 +159,6 @@ describe('getDocumentDownloadUrlLambda', () => { const response = await getDocumentDownloadUrlLambda( request, mockPetitionerUser, - {}, ); expect(response.statusCode).toBe(404); @@ -185,7 +186,6 @@ describe('getDocumentDownloadUrlLambda', () => { const response = await getDocumentDownloadUrlLambda( request, mockDocketClerkUser, - {}, ); expect(response.statusCode).toBe(500); @@ -229,7 +229,6 @@ describe('getDocumentDownloadUrlLambda', () => { const response = await getDocumentDownloadUrlLambda( request, mockDocketClerkUser, - {}, ); expect(response.statusCode).toBe('200'); diff --git a/web-api/src/lambdas/v2/getCaseLambda.test.ts b/web-api/src/lambdas/v2/getCaseLambda.test.ts index 3ecd2b5def0..42533a60855 100644 --- a/web-api/src/lambdas/v2/getCaseLambda.test.ts +++ b/web-api/src/lambdas/v2/getCaseLambda.test.ts @@ -74,7 +74,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG // disable logging by mimicking CI for this test beforeAll(() => { ({ CI } = process.env); - process.env.CI = true; + process.env.CI = 'true'; }); afterAll(() => (process.env.CI = CI)); @@ -88,7 +88,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser, {}); + const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -105,7 +105,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser, {}); + const response = await getCaseLambda(REQUEST_EVENT, mockPetitionerUser); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); @@ -128,11 +128,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda( - REQUEST_EVENT, - mockDocketClerkUser, - {}, - ); + const response = await getCaseLambda(REQUEST_EVENT, mockDocketClerkUser); expect(response.statusCode).toBe(404); expect(response.headers['Content-Type']).toBe('application/json'); @@ -149,11 +145,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: true, }); - const response = await getCaseLambda( - REQUEST_EVENT, - mockDocketClerkUser, - {}, - ); + const response = await getCaseLambda(REQUEST_EVENT, mockDocketClerkUser); expect(response.statusCode).toBe(500); expect(response.headers['Content-Type']).toBe('application/json'); @@ -197,11 +189,7 @@ describe('getCaseLambda (which fails if version increase is needed, DO NOT CHANG shouldThrowError: false, }); - const response = await getCaseLambda( - REQUEST_EVENT, - mockDocketClerkUser, - {}, - ); + const response = await getCaseLambda(REQUEST_EVENT, mockDocketClerkUser); expect(response.statusCode).toBe('200'); expect(response.headers['Content-Type']).toBe('application/json'); diff --git a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts index f297c91097d..ef2c2798f5f 100644 --- a/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts +++ b/web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts @@ -76,7 +76,7 @@ describe('getDocumentDownloadUrlLambda', () => { // disable logging by mimicking CI for this test beforeAll(() => { ({ CI } = process.env); - process.env.CI = true; + process.env.CI = 'true'; }); afterAll(() => (process.env.CI = CI)); @@ -90,16 +90,12 @@ describe('getDocumentDownloadUrlLambda', () => { shouldThrowError: false, }); - const response = await getDocumentDownloadUrlLambda( - REQUEST_EVENT, - { - email: 'test@e.mail', - name: '', - role: 'roleWithNoPermissions' as Role, - userId: '612e3eb3-332c-4f1f-aaff-44ac8eae9a5f', - }, - {}, - ); + const response = await getDocumentDownloadUrlLambda(REQUEST_EVENT, { + email: 'test@e.mail', + name: '', + role: 'roleWithNoPermissions' as Role, + userId: '612e3eb3-332c-4f1f-aaff-44ac8eae9a5f', + }); expect(response.statusCode).toBe(403); expect(response.headers['Content-Type']).toBe('application/json'); @@ -123,7 +119,6 @@ describe('getDocumentDownloadUrlLambda', () => { const response = await getDocumentDownloadUrlLambda( request, mockDocketClerkUser, - {}, ); expect(response.statusCode).toBe(404); @@ -166,7 +161,6 @@ describe('getDocumentDownloadUrlLambda', () => { const response = await getDocumentDownloadUrlLambda( request, mockDocketClerkUser, - {}, ); expect(response.statusCode).toBe(404); @@ -194,7 +188,6 @@ describe('getDocumentDownloadUrlLambda', () => { const response = await getDocumentDownloadUrlLambda( request, mockDocketClerkUser, - {}, ); expect(response.statusCode).toBe(500); @@ -238,7 +231,6 @@ describe('getDocumentDownloadUrlLambda', () => { const response = await getDocumentDownloadUrlLambda( request, mockDocketClerkUser, - {}, ); expect(response.statusCode).toBe('200'); diff --git a/web-api/src/middleware/apiGatewayHelper.test.ts b/web-api/src/middleware/apiGatewayHelper.test.ts index e05ab40b848..bb393bffc3f 100644 --- a/web-api/src/middleware/apiGatewayHelper.test.ts +++ b/web-api/src/middleware/apiGatewayHelper.test.ts @@ -379,7 +379,7 @@ describe('getUserFromAuthHeader', () => { Authorization: `Bearer ${token}`, }, }); - expect(user.name).toEqual(mockUser.name); + expect(user?.name).toEqual(mockUser.name); }); it('should return undefined if the user token is not a valid jwt token', () => { @@ -403,7 +403,7 @@ describe('getUserFromAuthHeader', () => { token, }, }); - expect(user.userId).toEqual(mockUser['custom:userId']); + expect(user?.userId).toEqual(mockUser['custom:userId']); }); describe('redirect', () => { diff --git a/web-client/src/presenter/computeds/alertHelper.test.ts b/web-client/src/presenter/computeds/alertHelper.test.ts index 801e517d4ee..e60748e084b 100644 --- a/web-client/src/presenter/computeds/alertHelper.test.ts +++ b/web-client/src/presenter/computeds/alertHelper.test.ts @@ -25,8 +25,8 @@ describe('alertHelper', () => { const result = runCompute(alertHelper, { state: { alertError: { title: 'hello' }, + user, }, - user, }); expect(result).toMatchObject({ showErrorAlert: true, From 620168c87c1ac878cf72b9102423ccfa47bb9384 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 29 Jul 2024 16:24:44 -0700 Subject: [PATCH 407/523] 10417: Update appContext Type --- shared/src/business/useCases/generateDocumentIds.ts | 3 ++- ...enerateNoticesForCaseTrialSessionCalendarInteractor.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/shared/src/business/useCases/generateDocumentIds.ts b/shared/src/business/useCases/generateDocumentIds.ts index acec42d6331..a7a0485d324 100644 --- a/shared/src/business/useCases/generateDocumentIds.ts +++ b/shared/src/business/useCases/generateDocumentIds.ts @@ -1,3 +1,4 @@ +import { ClientApplicationContext } from '@web-client/applicationContext'; import { FileUploadProgressType } from '../entities/EntityConstants'; import { ROLE_PERMISSIONS, @@ -7,7 +8,7 @@ import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; export const generateDocumentIds = async ( - applicationContext: any, + applicationContext: ClientApplicationContext, { applicationForWaiverOfFilingFeeUploadProgress, attachmentToPetitionUploadProgress, diff --git a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts index 6235c56c000..c59aec7fb61 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticesForCaseTrialSessionCalendarInteractor.ts @@ -127,6 +127,14 @@ const setNoticeForCase = async ({ trialSession, trialSessionEntity, user, +}: { + applicationContext: ServerApplicationContext; + caseRecord: any; + docketNumber: any; + jobId: any; + trialSession: any; + trialSessionEntity: any; + user: any; }) => { const caseEntity = new Case(caseRecord, { authorizedUser: undefined }); const { procedureType } = caseRecord; From 2a6e6474f9faa3dac81d26d5f2002c760d120d7f Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Tue, 30 Jul 2024 09:00:48 -0500 Subject: [PATCH 408/523] 10417 fix tests --- ...setNoticesForCalendaredTrialSessionInteractor.locking.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts index 70f829a5954..4bf4cf779bd 100644 --- a/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts +++ b/web-api/src/business/useCases/trialSessions/setNoticesForCalendaredTrialSessionInteractor.locking.test.ts @@ -148,6 +148,7 @@ describe('setNoticesForCalendaredTrialSessionInteractor', () => { applicationContext.getNotificationGateway().sendNotificationToUser, ).toHaveBeenCalledWith({ applicationContext, + clientConnectionId: mockRequest.clientConnectionId, message: { action: 'retry_async_request', originalRequest: mockRequest, From 97e09ca8bb18cb2999636ea0d034395e24a8991a Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Tue, 30 Jul 2024 09:05:56 -0500 Subject: [PATCH 409/523] 10417 fix untouched file types --- .../generateNoticeOfChangeOfTrialJudgeInteractor.ts | 2 +- .../generateNoticeOfChangeToRemoteProceedingInteractor.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/generateNoticeOfChangeOfTrialJudgeInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticeOfChangeOfTrialJudgeInteractor.ts index c6f1f421cdb..edb13973837 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticeOfChangeOfTrialJudgeInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticeOfChangeOfTrialJudgeInteractor.ts @@ -18,7 +18,7 @@ export const generateNoticeOfChangeOfTrialJudgeInteractor = async ( docketNumber: string; trialSessionInformation: RawTrialSession; }, -): Promise => { +): Promise => { const formattedStartDate = formatDateString( trialSessionInformation.startDate, FORMATS.MONTH_DAY_YEAR_WITH_DAY_OF_WEEK, diff --git a/web-api/src/business/useCases/trialSessions/generateNoticeOfChangeToRemoteProceedingInteractor.ts b/web-api/src/business/useCases/trialSessions/generateNoticeOfChangeToRemoteProceedingInteractor.ts index 3d9158136f4..26e9c185d7a 100644 --- a/web-api/src/business/useCases/trialSessions/generateNoticeOfChangeToRemoteProceedingInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateNoticeOfChangeToRemoteProceedingInteractor.ts @@ -21,7 +21,7 @@ export const generateNoticeOfChangeToRemoteProceedingInteractor = async ( docketNumber, trialSessionInformation, }: { docketNumber; trialSessionInformation: TrialSessionInformationType }, -): Promise => { +): Promise => { const formattedStartDate = formatDateString( trialSessionInformation.startDate, FORMATS.MONTH_DAY_YEAR_WITH_DAY_OF_WEEK, From 8104a5d9f0a4b66a9012d0dd2b77a33a6e13408c Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 30 Jul 2024 08:22:24 -0700 Subject: [PATCH 410/523] 10417: Use new login helper function --- .../authentication/login-as-helpers.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cypress/helpers/authentication/login-as-helpers.ts b/cypress/helpers/authentication/login-as-helpers.ts index f16143b64af..501e12dde8d 100644 --- a/cypress/helpers/authentication/login-as-helpers.ts +++ b/cypress/helpers/authentication/login-as-helpers.ts @@ -1,3 +1,5 @@ +import { getCypressEnv } from '../env/cypressEnvironment'; + export function loginAsTestAdmissionsClerk() { cy.login('testAdmissionsClerk'); cy.get('#inbox-tab-content').should('exist'); @@ -76,7 +78,7 @@ export function loginAsPetitionsClerk() { } export function loginAsPetitionsClerk1() { - cy.login('petitionsclerk1'); + login({ email: 'petitionsclerk1@example.com' }); cy.get('[data-testid="inbox-tab-content"]').should('exist'); } @@ -119,3 +121,19 @@ export function loginAsIrsSuperUser() { cy.login('irssuperuser'); cy.get('[data-testid="advanced-search-link"]').should('exist'); } + +// We created this new login function because our current login function was too generically +// waiting for the account menu button, resulting in visiting a route before the page was fully loaded. +// We need to deprecate usage of cy.login and have all tests login through helper functions so we properly await +function login({ email }: { email: string }) { + Cypress.session.clearCurrentSessionData(); + cy.visit('/login'); + cy.get('[data-testid="email-input"]').type(email); + cy.get('[data-testid="password-input"]').type( + getCypressEnv().defaultAccountPass, + ); + cy.get('[data-testid="login-button"]').click(); + cy.window().then(win => + win.localStorage.setItem('__cypressOrderInSameTab', 'true'), + ); +} From b6fce8e070793dd2b077a38cd02e5382de40baf7 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 30 Jul 2024 10:41:02 -0700 Subject: [PATCH 411/523] 10417 Improve typing of validateRawCollection --- docs/remove-get-current-user.md | 77 +------------------ .../business/entities/JoiValidationEntity.ts | 12 ++- .../updateCaseAndAssociations.ts | 2 +- 3 files changed, 10 insertions(+), 81 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index 5b995974757..e395153a0a6 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -1,81 +1,6 @@ -# HeadSpace -- DO NOT REFACTOR -- If something seems questionable or gives a moment of pause mark with a comment: // TODO 10417 - # TODO -- Go back to all // TODO 10417 - Look at validateRawCollection() - check instances of `handleLockError` (or `OnLockError`) # Problems we see with the app that are unrelated to changes -- generateStampedCoversheetInteractor does not have any authorization - -# Web-Client -Steps to transition getCurrentUser() in web-client -1. Find applicationContext.getCurrentUser() and replace with get(state.user); -1. Update test to use state to set the user instead of mocking calls to getCurrentUser() - -# Shared(DocketEntry, Case, PublicCase) -For Interactors that are still in shared follow the steps in the `Web-Api` section - -For DocketEntry, Case, PublicCase - -# Web-Api -Steps To transition an interactor away from getCurrentUser() -1. Make Interactor accept a 3rd paramater called authorizedUser: UnknownAuthUser -1. Remove applicationContext.getCurrentUser() and replace with the authorizedUser input. -1. Update test to pass in user instead of mocking getCurrentUser. Test users can be found in `shared/src/test/mockAuthUsers.ts` -1. Update everywhere the interactor is being called to pass in an authorizedUser. Most likely this will be in the lambda file of the same name, in which case you will make the lambda accept a second argument of the authorizedUser. Example below: - - -## Before -```typescript -import { genericHandler } from '../../genericHandler'; - -/** - * lambda which is used for adding a petitioner to a case - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const addPetitionerToCaseLambda = event => - genericHandler(event, async ({ applicationContext }) => { - return await applicationContext - .getUseCases() - .addPetitionerToCaseInteractor(applicationContext, { - ...event.pathParameters, - ...JSON.parse(event.body), - }); - }); -``` - -## After -```typescript -import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { addPetitionerToCaseInteractor } from '@shared/business/useCases/addPetitionerToCaseInteractor'; -import { genericHandler } from '../../genericHandler'; - -/** - * lambda which is used for adding a petitioner to a case - * - * @param {object} event the AWS event object - * @returns {Promise<*|undefined>} the api gateway response object containing the statusCode, body, and headers - */ -export const addPetitionerToCaseLambda = ( - event, - authorizedUser: UnknownAuthUser, -) => - genericHandler( - event, - async ({ applicationContext }) => { - return await addPetitionerToCaseInteractor( - applicationContext, - { - ...event.pathParameters, - ...JSON.parse(event.body), - }, - authorizedUser, - ); - }, - ); -``` \ No newline at end of file +- generateStampedCoversheetInteractor does not have any authorization \ No newline at end of file diff --git a/shared/src/business/entities/JoiValidationEntity.ts b/shared/src/business/entities/JoiValidationEntity.ts index bf4b6ef0b0e..a9e1c563fc7 100644 --- a/shared/src/business/entities/JoiValidationEntity.ts +++ b/shared/src/business/entities/JoiValidationEntity.ts @@ -192,14 +192,18 @@ export abstract class JoiValidationEntity { return this.validate({ applicationContext, logErrors: true }); } - static validateRawCollection( - this: new (someVar: any, someArgs: any) => T, + static validateRawCollection any>( + this: ClassType, collection: any[] = [], - args?: any, + ...args: Tail> ) { return collection.map( rawEntity => - new this(rawEntity, args).validate().toRawObject() as ExcludeMethods, + new this(rawEntity, ...args) + .validate() + .toRawObject() as ExcludeMethods, ); } } + +type Tail = T extends [any, ...infer Rest] ? Rest : never; diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts index f298179b26e..d5e8a30db5e 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts @@ -378,7 +378,7 @@ const updateCaseWorkItems = async ({ trialLocation: caseToUpdate.trialLocation || null, })); - const validWorkItems = WorkItem.validateRawCollection(updatedWorkItems); // TODO: 10417, go look at validateRawCollection as a whole. + const validWorkItems = WorkItem.validateRawCollection(updatedWorkItems); return validWorkItems.map( validWorkItem => From b4f7e40a55c44681bd9b09509d6d388e72ffa580 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 30 Jul 2024 10:50:10 -0700 Subject: [PATCH 412/523] 10417 document followup changes --- docs/remove-get-current-user.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index e395153a0a6..0dad8b3b7e6 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -3,4 +3,7 @@ - check instances of `handleLockError` (or `OnLockError`) # Problems we see with the app that are unrelated to changes -- generateStampedCoversheetInteractor does not have any authorization \ No newline at end of file +- generateStampedCoversheetInteractor does not have any authorization +- Remove validateRawCollection +- remove cy.login() (enfornce login through user-specific helpers) +- \ No newline at end of file From 1ee5b7b366639f5e9bd096cdab5e00f2c6b64368 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 30 Jul 2024 11:02:25 -0700 Subject: [PATCH 413/523] 10417: Update validateRawCollection usage --- .../src/business/entities/IrsPractitioner.ts | 4 ++-- .../business/entities/PrivatePractitioner.ts | 4 ++-- .../getReconciliationReportInteractor.ts | 6 ++--- .../opinionAdvancedSearchInteractor.ts | 4 +--- .../useCases/orderAdvancedSearchInteractor.ts | 4 +--- .../createCaseAndAssociations.ts | 22 +++++++++++-------- .../updateCaseAndAssociations.ts | 9 +++++++- .../useCaseHelper/getJudgeInSectionHelper.ts | 4 +--- 8 files changed, 30 insertions(+), 27 deletions(-) diff --git a/shared/src/business/entities/IrsPractitioner.ts b/shared/src/business/entities/IrsPractitioner.ts index 8afe334c3f6..bc67c4a4469 100644 --- a/shared/src/business/entities/IrsPractitioner.ts +++ b/shared/src/business/entities/IrsPractitioner.ts @@ -8,8 +8,8 @@ export class IrsPractitioner extends User { public barNumber: string; public serviceIndicator: string; - constructor(rawUser, options?) { - super(rawUser, options); + constructor(rawUser, { filtered = false } = {}) { + super(rawUser, { filtered }); this.entityName = IrsPractitioner.ENTITY_NAME; diff --git a/shared/src/business/entities/PrivatePractitioner.ts b/shared/src/business/entities/PrivatePractitioner.ts index b4d320cea9a..42109ee8a68 100644 --- a/shared/src/business/entities/PrivatePractitioner.ts +++ b/shared/src/business/entities/PrivatePractitioner.ts @@ -11,8 +11,8 @@ export class PrivatePractitioner extends User { public representing: string; public serviceIndicator: string; - constructor(rawUser, options?) { - super(rawUser, options); + constructor(rawUser, { filtered = false } = {}) { + super(rawUser, { filtered }); this.entityName = PrivatePractitioner.ENTITY_NAME; this.barNumber = rawUser.barNumber; this.firmName = rawUser.firmName; diff --git a/shared/src/business/useCases/getReconciliationReportInteractor.ts b/shared/src/business/useCases/getReconciliationReportInteractor.ts index 0be273383c2..84edf5c7582 100644 --- a/shared/src/business/useCases/getReconciliationReportInteractor.ts +++ b/shared/src/business/useCases/getReconciliationReportInteractor.ts @@ -78,10 +78,8 @@ export const getReconciliationReportInteractor = async ( await assignCaseCaptionFromPersistence(applicationContext, docketEntries); const report = { - docketEntries: ReconciliationReportEntry.validateRawCollection( - docketEntries, - { applicationContext }, - ), + docketEntries: + ReconciliationReportEntry.validateRawCollection(docketEntries), reconciliationDate, reconciliationDateEnd: isoEnd, reportTitle: 'Reconciliation Report', diff --git a/shared/src/business/useCases/opinionAdvancedSearchInteractor.ts b/shared/src/business/useCases/opinionAdvancedSearchInteractor.ts index 0eedf229dd1..fae27ff6a06 100644 --- a/shared/src/business/useCases/opinionAdvancedSearchInteractor.ts +++ b/shared/src/business/useCases/opinionAdvancedSearchInteractor.ts @@ -69,7 +69,5 @@ export const opinionAdvancedSearchInteractor = async ( const filteredResults = results.slice(0, MAX_SEARCH_RESULTS); - return InternalDocumentSearchResult.validateRawCollection(filteredResults, { - applicationContext, - }); + return InternalDocumentSearchResult.validateRawCollection(filteredResults); }; diff --git a/shared/src/business/useCases/orderAdvancedSearchInteractor.ts b/shared/src/business/useCases/orderAdvancedSearchInteractor.ts index de3877e2931..d0c5e14b738 100644 --- a/shared/src/business/useCases/orderAdvancedSearchInteractor.ts +++ b/shared/src/business/useCases/orderAdvancedSearchInteractor.ts @@ -80,7 +80,5 @@ export const orderAdvancedSearchInteractor = async ( MAX_SEARCH_RESULTS, ); - return InternalDocumentSearchResult.validateRawCollection(filteredResults, { - applicationContext, - }); + return InternalDocumentSearchResult.validateRawCollection(filteredResults); }; diff --git a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts index 56140118588..4751c3e104a 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.ts @@ -15,12 +15,19 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; */ const createCaseDocketEntries = ({ applicationContext, + authorizedUser, docketEntries, docketNumber, petitioners, +}: { + applicationContext: ServerApplicationContext; + authorizedUser: AuthUser; + docketEntries: any; + docketNumber: any; + petitioners: any; }) => { const validDocketEntries = DocketEntry.validateRawCollection(docketEntries, { - applicationContext, + authorizedUser, petitioners, }); @@ -47,10 +54,8 @@ const connectIrsPractitioners = ({ docketNumber, irsPractitioners, }) => { - const validIrsPractitioners = IrsPractitioner.validateRawCollection( - irsPractitioners, - { applicationContext }, - ); + const validIrsPractitioners = + IrsPractitioner.validateRawCollection(irsPractitioners); return validIrsPractitioners.map(practitioner => applicationContext.getPersistenceGateway().updateIrsPractitionerOnCase({ @@ -75,10 +80,8 @@ const connectPrivatePractitioners = ({ docketNumber, privatePractitioners, }) => { - const validPrivatePractitioners = PrivatePractitioner.validateRawCollection( - privatePractitioners, - { applicationContext }, - ); + const validPrivatePractitioners = + PrivatePractitioner.validateRawCollection(privatePractitioners); return validPrivatePractitioners.map(practitioner => applicationContext.getPersistenceGateway().updatePrivatePractitionerOnCase({ @@ -129,6 +132,7 @@ export const createCaseAndAssociations = async ({ }), ...createCaseDocketEntries({ applicationContext, + authorizedUser, docketEntries, docketNumber, petitioners: caseToCreate.petitioners, diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts index d5e8a30db5e..167a8743dab 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts @@ -20,8 +20,14 @@ import diff from 'diff-arrays-of-objects'; */ const updateCaseDocketEntries = ({ applicationContext, + authorizedUser, caseToUpdate, oldCase, +}: { + applicationContext: ServerApplicationContext; + authorizedUser: UnknownAuthUser; + caseToUpdate: any; + oldCase: any; }) => { const { added: addedDocketEntries, updated: updatedDocketEntries } = diff( oldCase.docketEntries, @@ -45,7 +51,7 @@ const updateCaseDocketEntries = ({ ...addedArchivedDocketEntries, ...updatedArchivedDocketEntries, ], - { applicationContext, petitioners: caseToUpdate.petitioners }, + { authorizedUser, petitioners: caseToUpdate.petitioners }, ); return validDocketEntries.map( @@ -485,6 +491,7 @@ export const updateCaseAndAssociations = async ({ const validationRequests = RELATED_CASE_OPERATIONS.map(fn => fn({ applicationContext, + authorizedUser, caseToUpdate: validRawCaseEntity, oldCase: validRawOldCaseEntity, }), diff --git a/web-api/src/business/useCaseHelper/getJudgeInSectionHelper.ts b/web-api/src/business/useCaseHelper/getJudgeInSectionHelper.ts index a46579baf52..4e95096ed07 100644 --- a/web-api/src/business/useCaseHelper/getJudgeInSectionHelper.ts +++ b/web-api/src/business/useCaseHelper/getJudgeInSectionHelper.ts @@ -21,9 +21,7 @@ export const getJudgeInSectionHelper = async ( section, }); - const sectionUsers = User.validateRawCollection(rawUsers, { - applicationContext, - }); + const sectionUsers = User.validateRawCollection(rawUsers); const judgeUser = sectionUsers.find( sectionUser => sectionUser.role === ROLES.judge, From f7c2b1d406766c9b6016f62e52f6d4e47e681d27 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Tue, 30 Jul 2024 15:43:45 -0400 Subject: [PATCH 414/523] 10417 fix calls to validateRawCollection --- .../updateCaseAndAssociations.ts | 17 ++++++----------- .../getJudgesForPublicSearchInteractor.ts | 2 +- .../public/opinionPublicSearchInteractor.ts | 4 +--- .../public/orderPublicSearchInteractor.ts | 4 +--- .../useCases/user/getInternalUsersInteractor.ts | 2 +- .../getIrsPractitionersBySearchKeyInteractor.ts | 4 +--- ...PrivatePractitionersBySearchKeyInteractor.ts | 4 +--- .../user/getUsersInSectionInteractor.ts | 2 +- 8 files changed, 13 insertions(+), 26 deletions(-) diff --git a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts index 167a8743dab..d7f7de90c30 100644 --- a/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts +++ b/web-api/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.ts @@ -149,15 +149,12 @@ const updateCorrespondence = ({ 'correspondenceId', ); - const validCorrespondence = Correspondence.validateRawCollection( - [ - ...addedCorrespondences, - ...updatedCorrespondences, - ...addedArchivedCorrespondences, - ...updatedArchivedCorrespondences, - ], - { applicationContext }, - ); + const validCorrespondence = Correspondence.validateRawCollection([ + ...addedCorrespondences, + ...updatedCorrespondences, + ...addedArchivedCorrespondences, + ...updatedArchivedCorrespondences, + ]); return validCorrespondence.map( correspondence => @@ -235,7 +232,6 @@ const updateIrsPractitioners = ({ const validIrsPractitioners = IrsPractitioner.validateRawCollection( currentIrsPractitioners, - { applicationContext }, ); const deletePractitionerFunctions = deletedIrsPractitioners.map( @@ -305,7 +301,6 @@ const updatePrivatePractitioners = ({ const validPrivatePractitioners = PrivatePractitioner.validateRawCollection( currentPrivatePractitioners, - { applicationContext }, ); const deletePractitionerFunctions = deletedPrivatePractitioners.map( diff --git a/web-api/src/business/useCases/public/getJudgesForPublicSearchInteractor.ts b/web-api/src/business/useCases/public/getJudgesForPublicSearchInteractor.ts index a9a6fa83029..ea0f136186b 100644 --- a/web-api/src/business/useCases/public/getJudgesForPublicSearchInteractor.ts +++ b/web-api/src/business/useCases/public/getJudgesForPublicSearchInteractor.ts @@ -18,5 +18,5 @@ export const getJudgesForPublicSearchInteractor = async ( section: ROLES.judge, }); - return PublicUser.validateRawCollection(rawJudges, { applicationContext }); + return PublicUser.validateRawCollection(rawJudges); }; diff --git a/web-api/src/business/useCases/public/opinionPublicSearchInteractor.ts b/web-api/src/business/useCases/public/opinionPublicSearchInteractor.ts index ba4a91a7efd..10ece9c7aee 100644 --- a/web-api/src/business/useCases/public/opinionPublicSearchInteractor.ts +++ b/web-api/src/business/useCases/public/opinionPublicSearchInteractor.ts @@ -60,7 +60,5 @@ export const opinionPublicSearchInteractor = async ( const filteredResults = results.slice(0, MAX_SEARCH_RESULTS); - return PublicDocumentSearchResult.validateRawCollection(filteredResults, { - applicationContext, - }); + return PublicDocumentSearchResult.validateRawCollection(filteredResults); }; diff --git a/web-api/src/business/useCases/public/orderPublicSearchInteractor.ts b/web-api/src/business/useCases/public/orderPublicSearchInteractor.ts index 57270e18f34..62dba1059d5 100644 --- a/web-api/src/business/useCases/public/orderPublicSearchInteractor.ts +++ b/web-api/src/business/useCases/public/orderPublicSearchInteractor.ts @@ -61,7 +61,5 @@ export const orderPublicSearchInteractor = async ( const slicedResults = results.slice(0, MAX_SEARCH_RESULTS); - return PublicDocumentSearchResult.validateRawCollection(slicedResults, { - applicationContext, - }); + return PublicDocumentSearchResult.validateRawCollection(slicedResults); }; diff --git a/web-api/src/business/useCases/user/getInternalUsersInteractor.ts b/web-api/src/business/useCases/user/getInternalUsersInteractor.ts index fc2cb2fa529..719d9e24f34 100644 --- a/web-api/src/business/useCases/user/getInternalUsersInteractor.ts +++ b/web-api/src/business/useCases/user/getInternalUsersInteractor.ts @@ -27,5 +27,5 @@ export const getInternalUsersInteractor = async ( applicationContext, }); - return User.validateRawCollection(rawUsers, { applicationContext }); + return User.validateRawCollection(rawUsers); }; diff --git a/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.ts b/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.ts index 9efbcb7ff32..5ffe49c631e 100644 --- a/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.ts +++ b/web-api/src/business/useCases/user/getIrsPractitionersBySearchKeyInteractor.ts @@ -34,7 +34,5 @@ export const getIrsPractitionersBySearchKeyInteractor = async ( type: 'irsPractitioner', }); - return IrsPractitioner.validateRawCollection(users, { - applicationContext, - }); + return IrsPractitioner.validateRawCollection(users); }; diff --git a/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.ts b/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.ts index 82db824c48d..dd43d1f086c 100644 --- a/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.ts +++ b/web-api/src/business/useCases/user/getPrivatePractitionersBySearchKeyInteractor.ts @@ -34,7 +34,5 @@ export const getPrivatePractitionersBySearchKeyInteractor = async ( type: 'privatePractitioner', }); - return PrivatePractitioner.validateRawCollection(users, { - applicationContext, - }); + return PrivatePractitioner.validateRawCollection(users); }; diff --git a/web-api/src/business/useCases/user/getUsersInSectionInteractor.ts b/web-api/src/business/useCases/user/getUsersInSectionInteractor.ts index dfabb24df20..bc3092a70f3 100644 --- a/web-api/src/business/useCases/user/getUsersInSectionInteractor.ts +++ b/web-api/src/business/useCases/user/getUsersInSectionInteractor.ts @@ -34,5 +34,5 @@ export const getUsersInSectionInteractor = async ( section, }); - return User.validateRawCollection(rawUsers, { applicationContext }); + return User.validateRawCollection(rawUsers); }; From a14f97362d3cb486cd4f39ab4c69b28292bd9152 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Tue, 30 Jul 2024 15:57:31 -0400 Subject: [PATCH 415/523] 10417 fix handleLockError instances --- docs/remove-get-current-user.md | 5 +++-- .../serveCourtIssuedDocumentInteractor.ts | 22 ++++++++++--------- .../serveExternallyFiledDocumentInteractor.ts | 22 ++++++++++--------- .../updatePractitionerUserInteractor.ts | 22 ++++++++++--------- .../updateTrialSessionInteractor.ts | 20 +++++++++-------- .../updateUserContactInformationInteractor.ts | 20 +++++++++-------- 6 files changed, 61 insertions(+), 50 deletions(-) diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md index 0dad8b3b7e6..e5c05b56574 100644 --- a/docs/remove-get-current-user.md +++ b/docs/remove-get-current-user.md @@ -1,9 +1,10 @@ # TODO -- Look at validateRawCollection() + - check instances of `handleLockError` (or `OnLockError`) # Problems we see with the app that are unrelated to changes + - generateStampedCoversheetInteractor does not have any authorization - Remove validateRawCollection - remove cy.login() (enfornce login through user-specific helpers) -- \ No newline at end of file +- diff --git a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts index 6ad6c253b5d..d9aca4768a4 100644 --- a/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.ts @@ -218,16 +218,18 @@ export const handleLockError = async ( originalRequest, authorizedUser: UnknownAuthUser, ) => { - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - clientConnectionId: originalRequest.clientConnectionId, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'serve_court_issued_document', - }, - userId: authorizedUser?.userId || '', - }); + if (authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + clientConnectionId: originalRequest.clientConnectionId, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'serve_court_issued_document', + }, + userId: authorizedUser?.userId, + }); + } }; export const serveCourtIssuedDocumentInteractor = withLocking( diff --git a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts index 77605b70095..59e15a036e1 100644 --- a/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts +++ b/web-api/src/business/useCases/document/serveExternallyFiledDocumentInteractor.ts @@ -223,16 +223,18 @@ export const handleLockError = async ( originalRequest: any, authorizedUser: UnknownAuthUser, ) => { - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - clientConnectionId: originalRequest.clientConnectionId, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'serve_externally_filed_document', - }, - userId: authorizedUser!.userId, - }); + if (authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + clientConnectionId: originalRequest.clientConnectionId, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'serve_externally_filed_document', + }, + userId: authorizedUser.userId, + }); + } }; export const serveExternallyFiledDocumentInteractor = withLocking( diff --git a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts index e1143acb82e..d8e80f6e031 100644 --- a/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts +++ b/web-api/src/business/useCases/practitioner/updatePractitionerUserInteractor.ts @@ -209,16 +209,18 @@ export const handleLockError = async ( originalRequest: any, authorizedUser: UnknownAuthUser, ) => { - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - clientConnectionId: originalRequest.clientConnectionId, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'update_practitioner_user', - }, - userId: authorizedUser?.userId || '', - }); + if (authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + clientConnectionId: originalRequest.clientConnectionId, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'update_practitioner_user', + }, + userId: authorizedUser?.userId, + }); + } }; export const determineEntitiesToLock = async ( diff --git a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts index 51e5c10cbf1..9baadc4e9fd 100644 --- a/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/updateTrialSessionInteractor.ts @@ -386,15 +386,17 @@ export const handleLockError = async ( originalRequest: any, authorizedUser: UnknownAuthUser, ) => { - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'update_trial_session', - }, - userId: authorizedUser?.userId || '', - }); + if (authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'update_trial_session', + }, + userId: authorizedUser.userId, + }); + } }; export const updateTrialSessionInteractor = withLocking( diff --git a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts index 7fa81843309..0994799fb13 100644 --- a/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts +++ b/web-api/src/business/useCases/user/updateUserContactInformationInteractor.ts @@ -181,15 +181,17 @@ export const handleLockError = async ( originalRequest: any, authorizedUser: UnknownAuthUser, ) => { - await applicationContext.getNotificationGateway().sendNotificationToUser({ - applicationContext, - message: { - action: 'retry_async_request', - originalRequest, - requestToRetry: 'update_user_contact_information', - }, - userId: authorizedUser?.userId || '', - }); + if (authorizedUser?.userId) { + await applicationContext.getNotificationGateway().sendNotificationToUser({ + applicationContext, + message: { + action: 'retry_async_request', + originalRequest, + requestToRetry: 'update_user_contact_information', + }, + userId: authorizedUser.userId, + }); + } }; export const determineEntitiesToLock = async ( From 4f8bb9065774237eeb2e4c7c56158e9ff62edc09 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Tue, 30 Jul 2024 16:32:16 -0400 Subject: [PATCH 416/523] 10417 delete leftover files --- docs/remove-get-current-user.md | 10 ---------- todo_deleteme.md | 1 - 2 files changed, 11 deletions(-) delete mode 100644 docs/remove-get-current-user.md delete mode 100644 todo_deleteme.md diff --git a/docs/remove-get-current-user.md b/docs/remove-get-current-user.md deleted file mode 100644 index e5c05b56574..00000000000 --- a/docs/remove-get-current-user.md +++ /dev/null @@ -1,10 +0,0 @@ -# TODO - -- check instances of `handleLockError` (or `OnLockError`) - -# Problems we see with the app that are unrelated to changes - -- generateStampedCoversheetInteractor does not have any authorization -- Remove validateRawCollection -- remove cy.login() (enfornce login through user-specific helpers) -- diff --git a/todo_deleteme.md b/todo_deleteme.md deleted file mode 100644 index 21397870702..00000000000 --- a/todo_deleteme.md +++ /dev/null @@ -1 +0,0 @@ -# To do From 1cb85c851f0c282e8667ce316f73e63b7d18c06f Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Tue, 30 Jul 2024 16:50:04 -0500 Subject: [PATCH 417/523] 10417 switch to cy.clearAllCookies --- cypress/helpers/authentication/login-as-helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/helpers/authentication/login-as-helpers.ts b/cypress/helpers/authentication/login-as-helpers.ts index 501e12dde8d..40f27a56c8f 100644 --- a/cypress/helpers/authentication/login-as-helpers.ts +++ b/cypress/helpers/authentication/login-as-helpers.ts @@ -126,7 +126,7 @@ export function loginAsIrsSuperUser() { // waiting for the account menu button, resulting in visiting a route before the page was fully loaded. // We need to deprecate usage of cy.login and have all tests login through helper functions so we properly await function login({ email }: { email: string }) { - Cypress.session.clearCurrentSessionData(); + cy.clearAllCookies(); cy.visit('/login'); cy.get('[data-testid="email-input"]').type(email); cy.get('[data-testid="password-input"]').type( From b73cf5f62e9b2a9c23e36102d4b8a7520414f66d Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 31 Jul 2024 11:07:51 -0700 Subject: [PATCH 418/523] 10417 add type and empty state to user state --- web-client/src/presenter/actions/clearUserAction.ts | 6 +++--- .../src/presenter/actions/handleIdleLogoutAction.ts | 4 ++-- web-client/src/presenter/computeds/alertHelper.ts | 2 +- web-client/src/presenter/computeds/scanHelper.ts | 8 +++----- web-client/src/presenter/state.ts | 13 ++----------- web-client/src/presenter/state/userState.ts | 13 +++++++++++++ 6 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 web-client/src/presenter/state/userState.ts diff --git a/web-client/src/presenter/actions/clearUserAction.ts b/web-client/src/presenter/actions/clearUserAction.ts index 11fd3d6a5bc..17df53387a3 100644 --- a/web-client/src/presenter/actions/clearUserAction.ts +++ b/web-client/src/presenter/actions/clearUserAction.ts @@ -1,15 +1,15 @@ +import { cloneDeep } from 'lodash'; +import { emptyUserState } from '@web-client/presenter/state/userState'; import { setCurrentUserToken } from '@shared/proxies/requests'; import { state } from '@web-client/presenter/app.cerebral'; export const clearUserAction = async ({ applicationContext, - get, store, }: ActionProps) => { - store.unset(state.user); + store.set(state.user, cloneDeep(emptyUserState)); store.unset(state.token); store.unset(state.permissions); - console.debug('user cleared', get(state.user)); await applicationContext .getUseCases() diff --git a/web-client/src/presenter/actions/handleIdleLogoutAction.ts b/web-client/src/presenter/actions/handleIdleLogoutAction.ts index 34156d3ec30..76d43578d5c 100644 --- a/web-client/src/presenter/actions/handleIdleLogoutAction.ts +++ b/web-client/src/presenter/actions/handleIdleLogoutAction.ts @@ -5,9 +5,9 @@ export const handleIdleLogoutAction = ({ get, path, store }: ActionProps) => { const lastIdleAction = get(state.lastIdleAction); const idleLogoutState = get(state.idleLogoutState); const isUploading = get(state.fileUploadProgress.isUploading); - const user = get(state.user); + const userIsLoggedIn = !!get(state.token); - if (user && !isUploading && idleLogoutState.state === 'INITIAL') { + if (userIsLoggedIn && !isUploading && idleLogoutState.state === 'INITIAL') { store.set(state.idleLogoutState, { logoutAt: Date.now() + diff --git a/web-client/src/presenter/computeds/alertHelper.ts b/web-client/src/presenter/computeds/alertHelper.ts index 69c50855cf7..7f98c6267c9 100644 --- a/web-client/src/presenter/computeds/alertHelper.ts +++ b/web-client/src/presenter/computeds/alertHelper.ts @@ -11,7 +11,7 @@ const DEFAULT_ALERT_ERROR = { export const alertHelper = (get: Get): any => { const alertError = get(state.alertError) || DEFAULT_ALERT_ERROR; - const userIsIdentified = get(state.user) || false; + const userIsIdentified = get(state.token) || false; return { messagesDeduped: uniq(alertError.messages).filter(Boolean), diff --git a/web-client/src/presenter/computeds/scanHelper.ts b/web-client/src/presenter/computeds/scanHelper.ts index e7449eaa0f2..5ce5d8696e5 100644 --- a/web-client/src/presenter/computeds/scanHelper.ts +++ b/web-client/src/presenter/computeds/scanHelper.ts @@ -90,11 +90,9 @@ export const scanHelper = ( STINFileCompleted, disableModalSelect, hasLoadedScanDependencies: initiateScriptLoaded && configScriptLoaded, - hasScanFeature: !!( - user && - user.role && - applicationContext.getUtilities().isInternalUser(user.role) - ), + hasScanFeature: !!applicationContext + .getUtilities() + .isInternalUser(user.role), scanFeatureEnabled, scanModeNotSelected, scanModeOptions, diff --git a/web-client/src/presenter/state.ts b/web-client/src/presenter/state.ts index a309988a338..9136266a9f3 100644 --- a/web-client/src/presenter/state.ts +++ b/web-client/src/presenter/state.ts @@ -1,13 +1,11 @@ /* eslint-disable max-lines */ import { FormattedPendingMotionWithWorksheet } from '@web-api/business/useCases/pendingMotion/getPendingMotionDocketEntriesForCurrentJudgeInteractor'; import { GetCasesByStatusAndByJudgeResponse } from '@web-api/business/useCases/judgeActivityReport/getCaseWorksheetsByJudgeInteractor'; -import { GetUserResponse } from '@shared/business/useCases/getUserInteractor'; import { IrsNoticeForm } from '@shared/business/entities/startCase/IrsNoticeForm'; import { JudgeActivityReportState } from '@web-client/ustc-ui/Utils/types'; import { RawCaseDeadline } from '@shared/business/entities/CaseDeadline'; import { RawMessage } from '@shared/business/entities/Message'; import { RawUser } from '@shared/business/entities/User'; -import { Role } from '@shared/business/entities/EntityConstants'; import { TAssociatedCase } from '@shared/business/useCases/getCasesForUserInteractor'; import { addCourtIssuedDocketEntryHelper } from './computeds/addCourtIssuedDocketEntryHelper'; import { addCourtIssuedDocketEntryNonstandardHelper } from './computeds/addCourtIssuedDocketEntryNonstandardHelper'; @@ -60,6 +58,7 @@ import { draftDocumentViewerHelper } from './computeds/draftDocumentViewerHelper import { editDocketEntryMetaHelper } from './computeds/editDocketEntryMetaHelper'; import { editPetitionerInformationHelper } from './computeds/editPetitionerInformationHelper'; import { editStatisticFormHelper } from './computeds/editStatisticFormHelper'; +import { emptyUserState } from '@web-client/presenter/state/userState'; import { externalConsolidatedCaseGroupHelper } from './computeds/externalConsolidatedCaseGroupHelper'; import { externalUserCasesHelper } from './computeds/Dashboard/externalUserCasesHelper'; import { fileDocumentHelper } from './computeds/fileDocumentHelper'; @@ -828,15 +827,7 @@ export const baseState = { } as { selectedFilingOption?: string; }, - user: { - email: '', - name: '', - role: '' as Role, - section: '', - userId: '', - } as GetUserResponse & { - email: string; - }, // We know that the logged in user has an email otherwise they could not login. + user: cloneDeep(emptyUserState), userContactEditProgress: {} as { inProgress?: boolean }, users: [] as RawUser[], validationErrors: {} as Record, diff --git a/web-client/src/presenter/state/userState.ts b/web-client/src/presenter/state/userState.ts new file mode 100644 index 00000000000..4a2b95bcdf1 --- /dev/null +++ b/web-client/src/presenter/state/userState.ts @@ -0,0 +1,13 @@ +import { GetUserResponse } from '@shared/business/useCases/getUserInteractor'; +import { Role } from '@shared/business/entities/EntityConstants'; + +export const emptyUserState: GetUserResponse & { + email: string; +} = { + email: '', + entityName: '', + name: '', + role: '' as Role, + section: '', + userId: '', +}; // We know that the logged in user has an email otherwise they could not login. From 3657ee6d2e80b0d3e612b78f02a4d28391141152 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 31 Jul 2024 12:32:22 -0700 Subject: [PATCH 419/523] 10417 - Fix tests for state.user --- .../src/presenter/actions/clearUserAction.test.ts | 5 +++-- .../presenter/actions/handleIdleLogoutAction.test.ts | 10 +++++----- web-client/src/presenter/computeds/scanHelper.test.ts | 6 ++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/web-client/src/presenter/actions/clearUserAction.test.ts b/web-client/src/presenter/actions/clearUserAction.test.ts index bb61f6979d2..de47bec4434 100644 --- a/web-client/src/presenter/actions/clearUserAction.test.ts +++ b/web-client/src/presenter/actions/clearUserAction.test.ts @@ -1,12 +1,13 @@ import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { clearUserAction } from './clearUserAction'; +import { emptyUserState } from '@web-client/presenter/state/userState'; import { presenter } from '../presenter-mock'; import { runAction } from '@web-client/presenter/test.cerebral'; describe('clearUserAction', () => { presenter.providers.applicationContext = applicationContext; - it('should unset state.user, state.token, and state.permissions', async () => { + it('should unset state.token and state.permissions and reset state.user', async () => { const result = await runAction(clearUserAction, { modules: { presenter, @@ -18,7 +19,7 @@ describe('clearUserAction', () => { }, }); - expect(result.state.user).toBeUndefined(); + expect(result.state.user).toEqual(emptyUserState); expect(result.state.token).toBeUndefined(); expect(result.state.permissions).toBeUndefined(); }); diff --git a/web-client/src/presenter/actions/handleIdleLogoutAction.test.ts b/web-client/src/presenter/actions/handleIdleLogoutAction.test.ts index 20da394b7a6..6aa09562760 100644 --- a/web-client/src/presenter/actions/handleIdleLogoutAction.test.ts +++ b/web-client/src/presenter/actions/handleIdleLogoutAction.test.ts @@ -33,7 +33,7 @@ describe('handleIdleLogoutAction', () => { state: 'INITIAL', }, lastIdleAction: 0, - user: undefined, + token: undefined, }, }); @@ -61,7 +61,7 @@ describe('handleIdleLogoutAction', () => { state: 'INITIAL', }, lastIdleAction: 0, - user: {}, + token: '92c17761-d382-4231-b497-bc8c9e3ffea1', }, }); @@ -89,7 +89,7 @@ describe('handleIdleLogoutAction', () => { state: 'INITIAL', }, lastIdleAction: 0, - user: {}, + token: '9dfbf86d-d4e7-41da-a85a-1b57910a5eaa', }, }); @@ -118,7 +118,7 @@ describe('handleIdleLogoutAction', () => { state: 'MONITORING', }, lastIdleAction: 0, - user: {}, + token: '0e4d3b74-89bc-44a0-a9b9-59f5eece40a5', }, }); @@ -147,7 +147,7 @@ describe('handleIdleLogoutAction', () => { state: 'COUNTDOWN', }, lastIdleAction: 0, - user: {}, + token: 'd53d2132-860e-41a0-9f42-f73c7285721b', }, }); diff --git a/web-client/src/presenter/computeds/scanHelper.test.ts b/web-client/src/presenter/computeds/scanHelper.test.ts index 4ef0dd76ed1..144a8d91ad9 100644 --- a/web-client/src/presenter/computeds/scanHelper.test.ts +++ b/web-client/src/presenter/computeds/scanHelper.test.ts @@ -484,6 +484,7 @@ describe('scanHelper', () => { scanner: { sources: ['sourceA, sourceB'], }, + user: petitionerUser, }, }); @@ -500,6 +501,7 @@ describe('scanHelper', () => { scanner: { sources: ['sourceA, sourceB'], }, + user: petitionerUser, }, }); @@ -516,6 +518,7 @@ describe('scanHelper', () => { scanner: { sources: ['sourceA, sourceB'], }, + user: petitionerUser, }, }); @@ -532,6 +535,7 @@ describe('scanHelper', () => { scanner: { sources: [], }, + user: petitionerUser, }, }); @@ -545,6 +549,7 @@ describe('scanHelper', () => { scanMode: 'someScanMode', scanner: 'someScanner', }, + user: petitionerUser, }, }); @@ -561,6 +566,7 @@ describe('scanHelper', () => { scanner: { sources: ['sourceA, sourceB'], }, + user: petitionerUser, }, }); From 4ca53f234c3108d72b4aa880b75b9a3527f078ed Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 31 Jul 2024 17:24:58 -0500 Subject: [PATCH 420/523] 10417 check if user is logged in using token --- web-client/src/presenter/computeds/headerHelper.test.ts | 5 ++++- web-client/src/presenter/computeds/headerHelper.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/web-client/src/presenter/computeds/headerHelper.test.ts b/web-client/src/presenter/computeds/headerHelper.test.ts index b544dbf6a3e..ca176f97f81 100644 --- a/web-client/src/presenter/computeds/headerHelper.test.ts +++ b/web-client/src/presenter/computeds/headerHelper.test.ts @@ -1,6 +1,7 @@ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; //import { applicationContext } from '@shared/business/test/createTestApplicationContext'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { emptyUserState } from '@web-client/presenter/state/userState'; import { getUserPermissions } from '../../../../shared/src/authorization/getUserPermissions'; import { headerHelper as headerHelperComputed } from './headerHelper'; import { runCompute } from '@web-client/presenter/test.cerebral'; @@ -18,6 +19,7 @@ const getBaseState = user => { unreadCount: 0, }, permissions: getUserPermissions(user), + token: '283490', user, }; }; @@ -373,8 +375,9 @@ describe('headerHelper', () => { it('should be the public site url when the current user is not logged in', () => { const result = runCompute(headerHelper, { state: { - ...getBaseState(undefined), + ...getBaseState(emptyUserState), currentPage: 'Messages', + token: undefined, }, }); diff --git a/web-client/src/presenter/computeds/headerHelper.ts b/web-client/src/presenter/computeds/headerHelper.ts index f406858c1f1..65e82ef2def 100644 --- a/web-client/src/presenter/computeds/headerHelper.ts +++ b/web-client/src/presenter/computeds/headerHelper.ts @@ -7,8 +7,8 @@ export const headerHelper = ( applicationContext: ClientApplicationContext, ): any => { const user = get(state.user); - const userRole = user && user.role; - const isLoggedIn = !!user; + const userRole = user.role; + const isLoggedIn = !!get(state.token); const currentPage = get(state.currentPage) || ''; const { USER_ROLES } = applicationContext.getConstants(); const permissions = get(state.permissions); From 2eed27ccfad0e68d2530a132fc3e823e11d74985 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 1 Aug 2024 07:46:44 -0700 Subject: [PATCH 421/523] 10417 - Skip dynamsoft for cypress --- cypress/helpers/authentication/login-as-helpers.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cypress/helpers/authentication/login-as-helpers.ts b/cypress/helpers/authentication/login-as-helpers.ts index 40f27a56c8f..ae45f2e47f0 100644 --- a/cypress/helpers/authentication/login-as-helpers.ts +++ b/cypress/helpers/authentication/login-as-helpers.ts @@ -136,4 +136,10 @@ function login({ email }: { email: string }) { cy.window().then(win => win.localStorage.setItem('__cypressOrderInSameTab', 'true'), ); + cy.intercept('GET', 'https://**/dynamsoft.webtwain.initiate.js', { + body: `window.Dynamsoft = {DWT: { + GetWebTwain() {} + }}`, + statusCode: 200, + }); } From b25625e8b28908f82c45a63cf8e2ed687d1ddc9e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 1 Aug 2024 15:57:00 -0700 Subject: [PATCH 422/523] 10417 - Add script for checking if all cognito attributes exist --- .../verify-cognito-required-attributes.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 scripts/run-once-scripts/verify-cognito-required-attributes.ts diff --git a/scripts/run-once-scripts/verify-cognito-required-attributes.ts b/scripts/run-once-scripts/verify-cognito-required-attributes.ts new file mode 100644 index 00000000000..5afc128e251 --- /dev/null +++ b/scripts/run-once-scripts/verify-cognito-required-attributes.ts @@ -0,0 +1,38 @@ +import { createApplicationContext } from '../../web-api/src/applicationContext'; +import { environment } from '../../web-api/src/environment'; + +async function main() { + const applicationContext = createApplicationContext({}); + const cognito = applicationContext.getCognito(); + + const expectedAttributes = ['custom:userId', 'name', 'email', 'custom:role']; + + let PaginationToken: string | undefined; + let usersCompleted = 0; + do { + const response = await cognito.listUsers({ + Limit: 60, + PaginationToken, + UserPoolId: environment.userPoolId, + }); + + // eslint-disable-next-line prefer-destructuring + PaginationToken = response.PaginationToken; + response.Users?.forEach(user => { + const userHasAllAttributes = expectedAttributes.every( + expctedAttribute => + !!user.Attributes?.find( + cognitoAttribute => cognitoAttribute.Name === expctedAttribute, + ), + ); + + if (!userHasAllAttributes) { + console.log('User does not have required attributes', user); + } + }); + usersCompleted = usersCompleted + 60; + console.log('Users Completed: ', usersCompleted); + } while (PaginationToken); +} + +void main(); From d1c75cd49d4db8d816f979a1a2cebbf0f5e0e5f7 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 2 Aug 2024 14:45:19 -0700 Subject: [PATCH 423/523] 10417 - When creating users give them a name and a user id for automated tests --- cypress/helpers/cypressTasks/cognito/cognito-helpers.ts | 8 ++++++++ web-api/hostedEnvironmentTests/irsSuperUser.test.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts b/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts index 257a317ee36..9cdaa5ad57e 100644 --- a/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts +++ b/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts @@ -101,6 +101,14 @@ export const createAccount = async ({ await getCognito().adminCreateUser({ TemporaryPassword: password, UserAttributes: [ + { + Name: 'name', + Value: 'Cypress Created Account', + }, + { + Name: 'custom:userId', + Value: '7f7f4c76-c697-4095-a294-dd9d1c16c735', + }, { Name: 'custom:role', Value: role, diff --git a/web-api/hostedEnvironmentTests/irsSuperUser.test.ts b/web-api/hostedEnvironmentTests/irsSuperUser.test.ts index 38530bb653c..95b619e5cfb 100644 --- a/web-api/hostedEnvironmentTests/irsSuperUser.test.ts +++ b/web-api/hostedEnvironmentTests/irsSuperUser.test.ts @@ -139,6 +139,14 @@ async function createUserInIrsPool({ await cognito.adminCreateUser({ TemporaryPassword: password, UserAttributes: [ + { + Name: 'name', + Value: 'irsSuperUser CI/CD', + }, + { + Name: 'custom:userId', + Value: '37808c8c-e658-4ff9-a57e-bbb64f0e6065', + }, { Name: 'custom:role', Value: ROLES.irsSuperuser, From ca4264720823f9cf8534c321f869a204e33a99b4 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 2 Aug 2024 15:18:48 -0700 Subject: [PATCH 424/523] 10417 - Update IRS pool to have a custom UserId attribut --- .../modules/everything-else-deprecated/cognito.tf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web-api/terraform/modules/everything-else-deprecated/cognito.tf b/web-api/terraform/modules/everything-else-deprecated/cognito.tf index 504e2659250..fbd209bce73 100644 --- a/web-api/terraform/modules/everything-else-deprecated/cognito.tf +++ b/web-api/terraform/modules/everything-else-deprecated/cognito.tf @@ -294,6 +294,18 @@ resource "aws_cognito_user_pool" "irs_pool" { } } + schema { + attribute_data_type = "String" + name = "userId" + required = false + mutable = true + + string_attribute_constraints { + min_length = 0 + max_length = 255 + } + } + schema { attribute_data_type = "String" name = "name" From 58d7c2cd09ab5a582d4f4290abf57b5311fa17fa Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 2 Aug 2024 15:24:52 -0700 Subject: [PATCH 425/523] 10417 - Update test to pass in name and userId --- cypress-smoketests.config.ts | 14 ++++++++++---- .../irs-super-user-can-download-stin.cy.ts | 3 +++ .../cypressTasks/cognito/cognito-helpers.ts | 8 ++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cypress-smoketests.config.ts b/cypress-smoketests.config.ts index d79d850112c..a7cec9a0eb1 100644 --- a/cypress-smoketests.config.ts +++ b/cypress-smoketests.config.ts @@ -33,20 +33,26 @@ export default defineConfig({ return confirmUser({ email }); }, createAccount({ - irsEnv, + isIrsEnv, + name, password, role, + userId, userName, }: { - irsEnv: boolean; + userName: string; password: string; role: string; - userName: string; + isIrsEnv: boolean; + name: string; + userId: string; }) { return createAccount({ - isIrsEnv: irsEnv, + isIrsEnv, + name, password, role, + userId, userName, }); }, diff --git a/cypress/deployed-and-local/integration/irsSuperUser/irs-super-user-can-download-stin.cy.ts b/cypress/deployed-and-local/integration/irsSuperUser/irs-super-user-can-download-stin.cy.ts index ea84c9f723e..ece9778ab4e 100644 --- a/cypress/deployed-and-local/integration/irsSuperUser/irs-super-user-can-download-stin.cy.ts +++ b/cypress/deployed-and-local/integration/irsSuperUser/irs-super-user-can-download-stin.cy.ts @@ -3,6 +3,7 @@ import { getCypressEnv } from '../../../helpers/env/cypressEnvironment'; import { loginAsPetitioner } from '../../../helpers/authentication/login-as-helpers'; import { petitionerCreatesElectronicCase } from '../../../helpers/fileAPetition/petitioner-creates-electronic-case'; import { petitionsClerkQcsAndServesElectronicCase } from '../../../helpers/documentQC/petitions-clerk-qcs-and-serves-electronic-case'; +import { v4 } from 'uuid'; if (!Cypress.env('SMOKETESTS_LOCAL')) { describe('irs superuser integration', () => { @@ -21,8 +22,10 @@ if (!Cypress.env('SMOKETESTS_LOCAL')) { it('should let an irs superuser view the reconciliation report and download a STIN', () => { cy.task('createAccount', { irsEnv: true, + name: 'irsSuperUser CI/CD', password, role: ROLES.irsSuperuser, + userId: v4(), userName, }); diff --git a/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts b/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts index 9cdaa5ad57e..4d0f781832b 100644 --- a/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts +++ b/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts @@ -88,14 +88,18 @@ const getUserPoolId = async (isIrsEnv = false): Promise => { export const createAccount = async ({ isIrsEnv, + name, password, role, + userId, userName, }: { userName: string; password: string; role: string; isIrsEnv: boolean; + name: string; + userId: string; }): Promise => { const userPoolId = await getUserPoolId(isIrsEnv); await getCognito().adminCreateUser({ @@ -103,11 +107,11 @@ export const createAccount = async ({ UserAttributes: [ { Name: 'name', - Value: 'Cypress Created Account', + Value: name, }, { Name: 'custom:userId', - Value: '7f7f4c76-c697-4095-a294-dd9d1c16c735', + Value: userId, }, { Name: 'custom:role', From bb8cd24c1da6c752cc154ce9522e9cd56e60eb40 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 5 Aug 2024 08:23:31 -0700 Subject: [PATCH 426/523] 10417 - Update permissions to allow cognito to add attributes --- web-api/terraform/modules/ci-cd/ci-cd-permissions.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/web-api/terraform/modules/ci-cd/ci-cd-permissions.tf b/web-api/terraform/modules/ci-cd/ci-cd-permissions.tf index 7231fae22f8..d0675c53683 100644 --- a/web-api/terraform/modules/ci-cd/ci-cd-permissions.tf +++ b/web-api/terraform/modules/ci-cd/ci-cd-permissions.tf @@ -48,6 +48,7 @@ resource "aws_iam_policy" "ci_cd_policy" { "Sid": "Cognito", "Effect": "Allow", "Action": [ + "cognito-idp:AddCustomAttributes", "cognito-idp:AdminCreateUser", "cognito-idp:AdminDeleteUser", "cognito-idp:AdminDisableUser", From 3d3e4fd917120e98d7d43589e6d7ab80f448ac67 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 5 Aug 2024 09:47:52 -0700 Subject: [PATCH 427/523] 10417 - Pass in correct argument name --- .../irsSuperUser/irs-super-user-can-download-stin.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/deployed-and-local/integration/irsSuperUser/irs-super-user-can-download-stin.cy.ts b/cypress/deployed-and-local/integration/irsSuperUser/irs-super-user-can-download-stin.cy.ts index ece9778ab4e..25d97f6ae1c 100644 --- a/cypress/deployed-and-local/integration/irsSuperUser/irs-super-user-can-download-stin.cy.ts +++ b/cypress/deployed-and-local/integration/irsSuperUser/irs-super-user-can-download-stin.cy.ts @@ -21,7 +21,7 @@ if (!Cypress.env('SMOKETESTS_LOCAL')) { it('should let an irs superuser view the reconciliation report and download a STIN', () => { cy.task('createAccount', { - irsEnv: true, + isIrsEnv: true, name: 'irsSuperUser CI/CD', password, role: ROLES.irsSuperuser, From b94f0b0b6520d34d53741ff395b7b855ba240568 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 5 Aug 2024 11:06:09 -0700 Subject: [PATCH 428/523] 10417: script to check for malformed users --- .../verify-cognito-required-attributes.ts | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/scripts/run-once-scripts/verify-cognito-required-attributes.ts b/scripts/run-once-scripts/verify-cognito-required-attributes.ts index 5afc128e251..c74307b4f9d 100644 --- a/scripts/run-once-scripts/verify-cognito-required-attributes.ts +++ b/scripts/run-once-scripts/verify-cognito-required-attributes.ts @@ -1,3 +1,4 @@ +import { UserType } from '@aws-sdk/client-cognito-identity-provider'; import { createApplicationContext } from '../../web-api/src/applicationContext'; import { environment } from '../../web-api/src/environment'; @@ -6,6 +7,14 @@ async function main() { const cognito = applicationContext.getCognito(); const expectedAttributes = ['custom:userId', 'name', 'email', 'custom:role']; + const piiFields: (string | undefined)[] = ['name', 'email']; + const usersMissingAttributes: UserType[] = []; + const missingFieldSummary = { + ['custom:userId']: 0, + name: 0, + email: 0, + ['custom:role']: 0, + }; let PaginationToken: string | undefined; let usersCompleted = 0; @@ -20,19 +29,41 @@ async function main() { PaginationToken = response.PaginationToken; response.Users?.forEach(user => { const userHasAllAttributes = expectedAttributes.every( - expctedAttribute => - !!user.Attributes?.find( - cognitoAttribute => cognitoAttribute.Name === expctedAttribute, - ), + expectedAttribute => { + const theField = user.Attributes?.find( + cognitoAttribute => cognitoAttribute.Name === expectedAttribute, + ); + + if (!theField) { + missingFieldSummary[expectedAttribute]++; + } + return !!theField; + }, ); if (!userHasAllAttributes) { - console.log('User does not have required attributes', user); + user.Attributes?.forEach(cogAttribute => { + if (piiFields.includes(cogAttribute.Name) && cogAttribute.Value) { + cogAttribute.Value = '*******'; + } + }); + usersMissingAttributes.push(user); } }); + usersCompleted = usersCompleted + 60; console.log('Users Completed: ', usersCompleted); } while (PaginationToken); + + console.log( + 'Users missing attributes: ', + JSON.stringify(usersMissingAttributes, null, 2), + ); + console.log( + 'Users missing attributes (count): ', + usersMissingAttributes.length, + ); + console.log(missingFieldSummary); } void main(); From c16ea0fcd1a46980eea2503f98c289377c781755 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 5 Aug 2024 13:24:08 -0700 Subject: [PATCH 429/523] 10417: WIP swap with wrap --- .../documentQC/complete-docket-qc.cy.ts | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/cypress/deployed-and-local/integration/documentQC/complete-docket-qc.cy.ts b/cypress/deployed-and-local/integration/documentQC/complete-docket-qc.cy.ts index 2119d786ee5..8483ea128f0 100644 --- a/cypress/deployed-and-local/integration/documentQC/complete-docket-qc.cy.ts +++ b/cypress/deployed-and-local/integration/documentQC/complete-docket-qc.cy.ts @@ -1,3 +1,4 @@ +/* eslint-disable promise/no-nesting */ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { assertExists, retry } from '../../../helpers/retry'; import { goToCase } from '../../../helpers/caseDetail/go-to-case'; @@ -10,8 +11,8 @@ import { petitionsClerkServesPetition } from '../../../helpers/documentQC/petiti import { uploadFile } from '../../../helpers/file/upload-file'; describe('Document QC Complete', () => { - let CASE_SERVICE_SUPERVISOR_INFO: { userId: string; name: string } = - undefined as unknown as { userId: string; name: string }; + // let CASE_SERVICE_SUPERVISOR_INFO: { userId: string; name: string } = + // undefined as unknown as { userId: string; name: string }; let DOCKET_CLERK_INFO: { userId: string; name: string } = undefined as unknown as { userId: string; name: string }; @@ -21,8 +22,10 @@ describe('Document QC Complete', () => { before(() => { cy.intercept('GET', '**/users', req => { req.on('before:response', res => { + console.log('********************** this is our log', res.body); if (res.body.role === ROLES.caseServicesSupervisor) { - CASE_SERVICE_SUPERVISOR_INFO = res.body; + cy.wrap(res.body).as('CASE_SERVICE_SUPERVISOR_INFO'); + // CASE_SERVICE_SUPERVISOR_INFO = res.body; } if (res.body.role === ROLES.docketClerk) { DOCKET_CLERK_INFO = res.body; @@ -54,18 +57,21 @@ describe('Document QC Complete', () => { cy.get('@DOCKET_NUMBER').then(docketNumber => { loginAsAdmissionsClerk(); goToCase(docketNumber); + cy.get<{ userId: string; name: string }>( + '@CASE_SERVICE_SUPERVISOR_INFO', + ).then(caseServiceSupervisorInfo => { + sendMessages( + caseServiceSupervisorInfo.userId, + docketSectionMessage, + 'docket', + ); - sendMessages( - CASE_SERVICE_SUPERVISOR_INFO.userId, - docketSectionMessage, - 'docket', - ); - - sendMessages( - CASE_SERVICE_SUPERVISOR_INFO.userId, - petitionsSectionMessage, - 'petitions', - ); + sendMessages( + caseServiceSupervisorInfo.userId, + petitionsSectionMessage, + 'petitions', + ); + }); retry(() => { cy.login('caseServicesSupervisor1', '/messages/my/inbox'); From 6958ab81d35ffa0821e677a1a2d6658f33b4acb1 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 5 Aug 2024 15:10:53 -0700 Subject: [PATCH 430/523] 10417: Update to use tasks to get userIds instead of wrap --- cypress-smoketests.config.ts | 4 + cypress.config.ts | 4 + .../documentQC/complete-docket-qc.cy.ts | 103 ++++++++---------- .../cypressTasks/cognito/cognito-helpers.ts | 23 +++- .../cypressTasks/dynamo/dynamo-helpers.ts | 8 +- .../wait-for-practitioner-email-update.ts | 6 +- 6 files changed, 82 insertions(+), 66 deletions(-) diff --git a/cypress-smoketests.config.ts b/cypress-smoketests.config.ts index a7cec9a0eb1..fa94c93204f 100644 --- a/cypress-smoketests.config.ts +++ b/cypress-smoketests.config.ts @@ -4,6 +4,7 @@ import { deleteAllCypressTestAccounts, deleteAllIrsCypressTestAccounts, getIrsBearerToken, + getUserByEmail, } from './cypress/helpers/cypressTasks/cognito/cognito-helpers'; import { defineConfig } from 'cypress'; import { @@ -89,6 +90,9 @@ export default defineConfig({ getNewAccountVerificationCode({ email }) { return getNewAccountVerificationCode({ email }); }, + getUserByEmail(email: string) { + return getUserByEmail(email); + }, readAllItemsInBucket({ bucketName, retries, diff --git a/cypress.config.ts b/cypress.config.ts index b7e107ea875..fde1b1e8159 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,6 +1,7 @@ import { confirmUser, deleteAllCypressTestAccounts, + getUserByEmail, } from './cypress/helpers/cypressTasks/cognito/cognito-helpers'; import { defineConfig } from 'cypress'; import { @@ -51,6 +52,9 @@ export default defineConfig({ getNewAccountVerificationCode({ email }) { return getNewAccountVerificationCode({ email }); }, + getUserByEmail(email: string) { + return getUserByEmail(email); + }, table(message) { console.table(message); return null; diff --git a/cypress/deployed-and-local/integration/documentQC/complete-docket-qc.cy.ts b/cypress/deployed-and-local/integration/documentQC/complete-docket-qc.cy.ts index 8483ea128f0..5001c0e3df0 100644 --- a/cypress/deployed-and-local/integration/documentQC/complete-docket-qc.cy.ts +++ b/cypress/deployed-and-local/integration/documentQC/complete-docket-qc.cy.ts @@ -1,5 +1,4 @@ /* eslint-disable promise/no-nesting */ -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; import { assertExists, retry } from '../../../helpers/retry'; import { goToCase } from '../../../helpers/caseDetail/go-to-case'; import { @@ -11,31 +10,10 @@ import { petitionsClerkServesPetition } from '../../../helpers/documentQC/petiti import { uploadFile } from '../../../helpers/file/upload-file'; describe('Document QC Complete', () => { - // let CASE_SERVICE_SUPERVISOR_INFO: { userId: string; name: string } = - // undefined as unknown as { userId: string; name: string }; - let DOCKET_CLERK_INFO: { userId: string; name: string } = - undefined as unknown as { userId: string; name: string }; - const docketSectionMessage = 'To CSS under Docket Section'; const petitionsSectionMessage = 'To CSS under Petitions Section'; before(() => { - cy.intercept('GET', '**/users', req => { - req.on('before:response', res => { - console.log('********************** this is our log', res.body); - if (res.body.role === ROLES.caseServicesSupervisor) { - cy.wrap(res.body).as('CASE_SERVICE_SUPERVISOR_INFO'); - // CASE_SERVICE_SUPERVISOR_INFO = res.body; - } - if (res.body.role === ROLES.docketClerk) { - DOCKET_CLERK_INFO = res.body; - } - }); - }); - - cy.login('caseServicesSupervisor1'); - cy.login('docketclerk1'); - loginAsPetitioner(); petitionerCreatesElectronicCase().then(docketNumber => { cy.wrap(docketNumber).as('DOCKET_NUMBER'); @@ -57,8 +35,9 @@ describe('Document QC Complete', () => { cy.get('@DOCKET_NUMBER').then(docketNumber => { loginAsAdmissionsClerk(); goToCase(docketNumber); - cy.get<{ userId: string; name: string }>( - '@CASE_SERVICE_SUPERVISOR_INFO', + cy.task<{ userId: string; name: string; email: string; role: string }>( + 'getUserByEmail', + 'caseServicesSupervisor1@example.com', ).then(caseServiceSupervisorInfo => { sendMessages( caseServiceSupervisorInfo.userId, @@ -131,42 +110,49 @@ describe('Document QC Complete', () => { cy.get(`[data-testid="work-item-${docketNumber}"]`) .find('[data-testid="checkbox-assign-work-item"]') .click(); - - cy.get('[data-testid="dropdown-select-assignee"]').select( - DOCKET_CLERK_INFO.name, - ); - - retry(() => { - cy.login( - 'caseServicesSupervisor1', - '/document-qc/section/inbox/selectedSection?section=docket', + cy.task<{ userId: string; name: string; email: string; role: string }>( + 'getUserByEmail', + 'docketclerk1@example.com', + ).then(docketClerkInfo => { + cy.get('[data-testid="dropdown-select-assignee"]').select( + docketClerkInfo.name, ); - cy.get('table.usa-table'); - return cy.get('body').then(body => { - const workItem = body.find( - `[data-testid="work-item-${docketNumber}"]`, - ); - const assigneeName = workItem.find( - '[data-testid="table-column-work-item-assigned-to"]', + + retry(() => { + cy.login( + 'caseServicesSupervisor1', + '/document-qc/section/inbox/selectedSection?section=docket', ); - const text = assigneeName.text(); - return cy.wrap(text.includes(DOCKET_CLERK_INFO.name)); + cy.get('table.usa-table'); + return cy.get('body').then(body => { + const workItem = body.find( + `[data-testid="work-item-${docketNumber}"]`, + ); + const assigneeName = workItem.find( + '[data-testid="table-column-work-item-assigned-to"]', + ); + const text = assigneeName.text(); + return cy.wrap(text.includes(docketClerkInfo.name)); + }); }); - }); - cy.get(`[data-testid="work-item-${docketNumber}"]`) - .find('.message-document-title') - .find('a') - .click(); + cy.get(`[data-testid="work-item-${docketNumber}"]`) + .find('.message-document-title') + .find('a') + .click(); - cy.get('#save-and-finish').click(); + cy.get('#save-and-finish').click(); - cy.get('[data-testid="success-alert"]').should('contain', 'QC Completed'); + cy.get('[data-testid="success-alert"]').should( + 'contain', + 'QC Completed', + ); - cy.visit('/document-qc/my/outbox'); - cy.get(`[data-testid="section-work-item-outbox-${docketNumber}"]`).should( - 'exist', - ); + cy.visit('/document-qc/my/outbox'); + cy.get( + `[data-testid="section-work-item-outbox-${docketNumber}"]`, + ).should('exist'); + }); }); }); @@ -187,9 +173,14 @@ describe('Document QC Complete', () => { .find('[data-testid="checkbox-assign-work-item"]') .click(); - cy.get('[data-testid="dropdown-select-assignee"]').select( - CASE_SERVICE_SUPERVISOR_INFO.name, - ); + cy.task<{ userId: string; name: string; email: string; role: string }>( + 'getUserByEmail', + 'caseServicesSupervisor1@example.com', + ).then(caseServiceSupervisorInfo => { + cy.get('[data-testid="dropdown-select-assignee"]').select( + caseServiceSupervisorInfo.name, + ); + }); cy.visit('/document-qc/my/inbox'); cy.get( diff --git a/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts b/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts index 4d0f781832b..24ef243864e 100644 --- a/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts +++ b/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts @@ -52,9 +52,9 @@ const getClientId = async (userPoolId: string): Promise => { return clientId; }; -export const getCognitoUserIdByEmail = async ( +export const getUserByEmail = async ( email: string, -): Promise => { +): Promise<{ role: string; name: string; userId: string; email: string }> => { const userPoolId = await getUserPoolId(); const foundUser = await getCognito().adminGetUser({ UserPoolId: userPoolId, @@ -65,7 +65,24 @@ export const getCognitoUserIdByEmail = async ( element => element.Name === 'custom:userId', )?.Value!; - return userId; + const name = foundUser.UserAttributes?.find( + element => element.Name === 'name', + )?.Value!; + + const userEmail = foundUser.UserAttributes?.find( + element => element.Name === 'email', + )?.Value!; + + const role = foundUser.UserAttributes?.find( + element => element.Name === 'custom:role', + )?.Value!; + + return { + email: userEmail, + name, + role, + userId, + }; }; const getUserPoolId = async (isIrsEnv = false): Promise => { diff --git a/cypress/helpers/cypressTasks/dynamo/dynamo-helpers.ts b/cypress/helpers/cypressTasks/dynamo/dynamo-helpers.ts index c8176092544..b887201e996 100644 --- a/cypress/helpers/cypressTasks/dynamo/dynamo-helpers.ts +++ b/cypress/helpers/cypressTasks/dynamo/dynamo-helpers.ts @@ -1,6 +1,6 @@ -import { getCognitoUserIdByEmail } from '../cognito/cognito-helpers'; import { getCypressEnv } from '../../env/cypressEnvironment'; import { getDocumentClient } from './getDynamoCypress'; +import { getUserByEmail } from '../cognito/cognito-helpers'; export const getUserConfirmationCodeFromDynamo = async ( userId: string, @@ -21,7 +21,7 @@ export const getNewAccountVerificationCode = async ({ userId: string | undefined; confirmationCode: string | undefined; }> => { - const userId = await getCognitoUserIdByEmail(email); + const { userId } = await getUserByEmail(email); if (!userId) return { confirmationCode: undefined, @@ -39,7 +39,7 @@ export const getNewAccountVerificationCode = async ({ export const expireUserConfirmationCode = async ( email: string, ): Promise => { - const userId = await getCognitoUserIdByEmail(email); + const { userId } = await getUserByEmail(email); if (!userId) return null; await getDocumentClient() @@ -99,7 +99,7 @@ export const getEmailVerificationToken = async ({ }: { email: string; }): Promise => { - const userId = await getCognitoUserIdByEmail(email); + const { userId } = await getUserByEmail(email); const result = await getDocumentClient().get({ Key: { pk: `user|${userId}`, diff --git a/cypress/helpers/cypressTasks/wait-for-practitioner-email-update.ts b/cypress/helpers/cypressTasks/wait-for-practitioner-email-update.ts index 2c7c50bef4b..add62bd31c6 100644 --- a/cypress/helpers/cypressTasks/wait-for-practitioner-email-update.ts +++ b/cypress/helpers/cypressTasks/wait-for-practitioner-email-update.ts @@ -1,6 +1,6 @@ -import { getCognitoUserIdByEmail } from './cognito/cognito-helpers'; import { getCypressEnv } from '../env/cypressEnvironment'; import { getDocumentClient } from './dynamo/getDynamoCypress'; +import { getUserByEmail } from './cognito/cognito-helpers'; export async function waitForPractitionerEmailUpdate({ attempts = 0, @@ -12,11 +12,11 @@ export async function waitForPractitionerEmailUpdate({ attempts?: number; }): Promise { const maxAttempts = 10; - const practitionerUserId = await getCognitoUserIdByEmail(practitionerEmail); + const { userId } = await getUserByEmail(practitionerEmail); const result = await getDocumentClient().get({ Key: { pk: `case|${docketNumber}`, - sk: `privatePractitioner|${practitionerUserId}`, + sk: `privatePractitioner|${userId}`, }, TableName: getCypressEnv().dynamoDbTableName, }); From f554ad3ecebe1dfb9bb8892ed6b32606711f6514 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 5 Aug 2024 15:33:34 -0700 Subject: [PATCH 431/523] 10417: Update test to not use getCurrentUser --- .../notifications/onConnectInteractor.test.ts | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/web-api/src/business/useCases/notifications/onConnectInteractor.test.ts b/web-api/src/business/useCases/notifications/onConnectInteractor.test.ts index eccd0ceafed..d3041ec1cb8 100644 --- a/web-api/src/business/useCases/notifications/onConnectInteractor.test.ts +++ b/web-api/src/business/useCases/notifications/onConnectInteractor.test.ts @@ -1,17 +1,15 @@ import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; +import { + mockDocketClerkUser, + mockPetitionerUser, +} from '@shared/test/mockAuthUsers'; import { onConnectInteractor } from './onConnectInteractor'; -import { petitionerUser } from '@shared/test/mockUsers'; describe('onConnectInteractor', () => { const mockClientConnectionId = '03c1ee1e-c24a-480d-9ffc-683c8c417df7'; const mockConnectionId = '7f926304-e167-45e7-8601-e320298aaed3'; const mockEndpoint = 'www.example.com'; - beforeEach(() => { - applicationContext.getCurrentUser.mockReturnValue(petitionerUser); - }); - it('should save the user connection', async () => { await onConnectInteractor( applicationContext, @@ -46,11 +44,15 @@ describe('onConnectInteractor', () => { it('should add https protocol to the endpoint when the endpoint does not have a protocol', async () => { let endpoint = 'somedomain.hello.org'; - await onConnectInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - connectionId: mockConnectionId, - endpoint, - }); + await onConnectInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + connectionId: mockConnectionId, + endpoint, + }, + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveUserConnection, @@ -59,17 +61,21 @@ describe('onConnectInteractor', () => { clientConnectionId: mockClientConnectionId, connectionId: mockConnectionId, endpoint: 'https://' + endpoint, - userId: petitionerUser.userId, + userId: mockPetitionerUser.userId, }); }); it('should not add https protocol when endpoint already has a protocol', async () => { let endpoint = 'https://somedomain.hello.org'; - await onConnectInteractor(applicationContext, { - clientConnectionId: mockClientConnectionId, - connectionId: mockConnectionId, - endpoint, - }); + await onConnectInteractor( + applicationContext, + { + clientConnectionId: mockClientConnectionId, + connectionId: mockConnectionId, + endpoint, + }, + mockPetitionerUser, + ); expect( applicationContext.getPersistenceGateway().saveUserConnection, @@ -78,7 +84,7 @@ describe('onConnectInteractor', () => { clientConnectionId: mockClientConnectionId, connectionId: mockConnectionId, endpoint, - userId: petitionerUser.userId, + userId: mockPetitionerUser.userId, }); }); }); From e2d4d651f469ae73f906976cfe5d4169fb763e94 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 5 Aug 2024 15:45:50 -0700 Subject: [PATCH 432/523] 10417: Look for custom:name --- cypress/helpers/cypressTasks/cognito/cognito-helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts b/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts index 24ef243864e..215726dc546 100644 --- a/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts +++ b/cypress/helpers/cypressTasks/cognito/cognito-helpers.ts @@ -66,7 +66,7 @@ export const getUserByEmail = async ( )?.Value!; const name = foundUser.UserAttributes?.find( - element => element.Name === 'name', + element => element.Name === 'name' || element.Name === 'custom:name', // custom:name is only used locally for cognito-local )?.Value!; const userEmail = foundUser.UserAttributes?.find( From c2955d2446ceff19a2de2f0c2b895bc9cd61a6a0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 7 Aug 2024 08:00:08 -0700 Subject: [PATCH 433/523] 10417: Add defaulting of role to petitioner. Half of all prod users do not have a role. --- .../src/middleware/apiGatewayHelper.test.ts | 19 ++++++++++++++++++- web-api/src/middleware/apiGatewayHelper.ts | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/web-api/src/middleware/apiGatewayHelper.test.ts b/web-api/src/middleware/apiGatewayHelper.test.ts index bb393bffc3f..5f88d479820 100644 --- a/web-api/src/middleware/apiGatewayHelper.test.ts +++ b/web-api/src/middleware/apiGatewayHelper.test.ts @@ -396,7 +396,7 @@ describe('getUserFromAuthHeader', () => { expect(user).toEqual(undefined); }); - it('returns custom:userId when it is present in the token', () => { + it('should return custom:userId when it is present in the token', () => { const user = getUserFromAuthHeader({ headers: { Authorization: `Bearer ${token}`, @@ -406,6 +406,23 @@ describe('getUserFromAuthHeader', () => { expect(user?.userId).toEqual(mockUser['custom:userId']); }); + it('should default to a petitioner role when no role is present in the token', () => { + const mockNoRoleUser = { + 'custom:userId': '188a5b0f-e7ae-4647-98a1-43a0d4d00eee', + name: 'Test Petitioner', + }; + const noRoleToken = jwt.sign(mockNoRoleUser, 'secret'); + + const user = getUserFromAuthHeader({ + headers: { + Authorization: `Bearer ${noRoleToken}`, + token, + }, + }); + + expect(user?.role).toEqual(ROLES.petitioner); + }); + describe('redirect', () => { it('should return a redirect status in the header', async () => { const response = await redirect({}, () => ({ url: 'example.com' })); diff --git a/web-api/src/middleware/apiGatewayHelper.ts b/web-api/src/middleware/apiGatewayHelper.ts index ca908d7c3af..d159e66568c 100644 --- a/web-api/src/middleware/apiGatewayHelper.ts +++ b/web-api/src/middleware/apiGatewayHelper.ts @@ -3,6 +3,7 @@ import { UnauthorizedError, UnsanitizedEntityError, } from '@web-api/errors/errors'; +import { ROLES } from '@shared/business/entities/EntityConstants'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createApplicationContext } from '../applicationContext'; import { headerOverride } from '../lambdaWrapper'; @@ -177,7 +178,7 @@ export const getUserFromAuthHeader = (event): UnknownAuthUser => { return { email: decoded.email, name: decoded.name || decoded['custom:name'], // custom:name only exists locally. This is a workaround for cognito-local. - role: decoded['custom:role'], + role: decoded['custom:role'] || ROLES.petitioner, userId: decoded['custom:userId'], }; } else { From af8bf8b7d0928e663663a0c700da412faedb0f95 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 1 Aug 2024 16:17:18 -0500 Subject: [PATCH 434/523] 10417 fix IRS superuser test --- web-api/hostedEnvironmentTests/irsSuperUser.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web-api/hostedEnvironmentTests/irsSuperUser.test.ts b/web-api/hostedEnvironmentTests/irsSuperUser.test.ts index 95b619e5cfb..dd12d73f3d3 100644 --- a/web-api/hostedEnvironmentTests/irsSuperUser.test.ts +++ b/web-api/hostedEnvironmentTests/irsSuperUser.test.ts @@ -151,6 +151,10 @@ async function createUserInIrsPool({ Name: 'custom:role', Value: ROLES.irsSuperuser, }, + { + Name: 'custom:userId', + Value: '14de78aa-b148-4a55-a2a1-875253e414f3', + }, { Name: 'email', Value: userName, @@ -163,6 +167,7 @@ async function createUserInIrsPool({ UserPoolId: irsUserPoolId, Username: userName, }); + await cognito.adminSetUserPassword({ Password: password, Permanent: true, From 83cab2ab07b6bd67306d1f4d352cd11de75684ba Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 7 Aug 2024 15:01:10 -0500 Subject: [PATCH 435/523] 10417 - Add script to give all users a role of petitioner if they do not have a role --- .../add-petioner-role-to-roleless-user.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 scripts/run-once-scripts/add-petioner-role-to-roleless-user.ts diff --git a/scripts/run-once-scripts/add-petioner-role-to-roleless-user.ts b/scripts/run-once-scripts/add-petioner-role-to-roleless-user.ts new file mode 100644 index 00000000000..592e7eac7df --- /dev/null +++ b/scripts/run-once-scripts/add-petioner-role-to-roleless-user.ts @@ -0,0 +1,46 @@ +import { createApplicationContext } from '../../web-api/src/applicationContext'; +import { environment } from '../../web-api/src/environment'; +import { ROLES } from '../../shared/src/business/entities/EntityConstants'; + +async function main() { + const applicationContext = createApplicationContext({}); + const cognito = applicationContext.getCognito(); + const PAGE_SIZE = 10; + + let PaginationToken: string | undefined; + let usersCompleted = 0; + do { + await new Promise(resolve => setTimeout(resolve, 300)); + const response = await cognito.listUsers({ + Limit: PAGE_SIZE, + PaginationToken, + UserPoolId: environment.userPoolId, + }); + + PaginationToken = response.PaginationToken; + response.Users?.forEach(async user => { + const userHasRole = user.Attributes?.find( + cognitoAttribute => cognitoAttribute.Name === 'custom:role', + ); + + if (!userHasRole) { + await cognito.adminUpdateUserAttributes({ + UserAttributes: [ + { + Name: 'custom:role', + Value: ROLES.petitioner, + }, + ], + UserPoolId: environment.userPoolId, + Username: user.Username, + }); + console.log('Updated: ', user.Username); + } + }); + + usersCompleted = usersCompleted + PAGE_SIZE; + console.log('Users Completed: ', usersCompleted); + } while (PaginationToken); +} + +void main(); From 2c59f91f101099b5f513cfbc904a616098df6bbe Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 7 Aug 2024 13:35:36 -0700 Subject: [PATCH 436/523] 10417: Add script to verify confirming to a user --- scripts/run-once-scripts/verify-user-shape.ts | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 scripts/run-once-scripts/verify-user-shape.ts diff --git a/scripts/run-once-scripts/verify-user-shape.ts b/scripts/run-once-scripts/verify-user-shape.ts new file mode 100644 index 00000000000..8c8e45ac76f --- /dev/null +++ b/scripts/run-once-scripts/verify-user-shape.ts @@ -0,0 +1,61 @@ +import { createApplicationContext } from '../../web-api/src/applicationContext'; +import { environment } from '../../web-api/src/environment'; +import joi from 'joi'; + +async function main() { + const applicationContext = createApplicationContext({}); + const cognito = applicationContext.getCognito(); + const PAGE_SIZE = 60; + const authUserSchema = joi + .object() + .required() + .keys({ + email: joi.string().min(1).max(100).email({ tlds: false }).required(), + name: joi.string().min(1).required(), + userId: joi.string().min(1).uuid().required(), + }); + + let PaginationToken: string | undefined; + let usersCompleted = 0; + do { + const response = await cognito.listUsers({ + Limit: PAGE_SIZE, + PaginationToken, + UserPoolId: environment.userPoolId, + }); + + PaginationToken = response.PaginationToken; + response.Users?.forEach(async user => { + const userId = user.Attributes?.find( + cognitoAttribute => cognitoAttribute.Name === 'custom:userId', + )?.Value; + const email = user.Attributes?.find( + cognitoAttribute => cognitoAttribute.Name === 'email', + )?.Value; + const name = user.Attributes?.find( + cognitoAttribute => cognitoAttribute.Name === 'name', + )?.Value; + + const authUser = { + userId, + name, + email, + }; + + const { error } = authUserSchema.validate(authUser, { + abortEarly: false, + allowUnknown: true, + }); + + if (error) { + console.log(error); + console.log('User does not meet authUser standards', user); + } + }); + + usersCompleted = usersCompleted + PAGE_SIZE; + console.log('Users Completed: ', usersCompleted); + } while (PaginationToken); +} + +void main(); From 27ec65a26d13e5552d399150ed2f1562c6844656 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 7 Aug 2024 14:10:37 -0700 Subject: [PATCH 437/523] 10417: Remove uneeded script --- scripts/run-once-scripts/verify-user-shape.ts | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 scripts/run-once-scripts/verify-user-shape.ts diff --git a/scripts/run-once-scripts/verify-user-shape.ts b/scripts/run-once-scripts/verify-user-shape.ts deleted file mode 100644 index 8c8e45ac76f..00000000000 --- a/scripts/run-once-scripts/verify-user-shape.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { createApplicationContext } from '../../web-api/src/applicationContext'; -import { environment } from '../../web-api/src/environment'; -import joi from 'joi'; - -async function main() { - const applicationContext = createApplicationContext({}); - const cognito = applicationContext.getCognito(); - const PAGE_SIZE = 60; - const authUserSchema = joi - .object() - .required() - .keys({ - email: joi.string().min(1).max(100).email({ tlds: false }).required(), - name: joi.string().min(1).required(), - userId: joi.string().min(1).uuid().required(), - }); - - let PaginationToken: string | undefined; - let usersCompleted = 0; - do { - const response = await cognito.listUsers({ - Limit: PAGE_SIZE, - PaginationToken, - UserPoolId: environment.userPoolId, - }); - - PaginationToken = response.PaginationToken; - response.Users?.forEach(async user => { - const userId = user.Attributes?.find( - cognitoAttribute => cognitoAttribute.Name === 'custom:userId', - )?.Value; - const email = user.Attributes?.find( - cognitoAttribute => cognitoAttribute.Name === 'email', - )?.Value; - const name = user.Attributes?.find( - cognitoAttribute => cognitoAttribute.Name === 'name', - )?.Value; - - const authUser = { - userId, - name, - email, - }; - - const { error } = authUserSchema.validate(authUser, { - abortEarly: false, - allowUnknown: true, - }); - - if (error) { - console.log(error); - console.log('User does not meet authUser standards', user); - } - }); - - usersCompleted = usersCompleted + PAGE_SIZE; - console.log('Users Completed: ', usersCompleted); - } while (PaginationToken); -} - -void main(); From 8bb4dcc239d3b305f5c35307b6b39539e317ba49 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 7 Aug 2024 16:24:23 -0500 Subject: [PATCH 438/523] Revert "devex - Remove unused oauth flows from cognito" This reverts commit f16b6d45bb1e7d9cf90a891c991db065490e3624. --- .../modules/everything-else-deprecated/cognito.tf | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web-api/terraform/modules/everything-else-deprecated/cognito.tf b/web-api/terraform/modules/everything-else-deprecated/cognito.tf index fbd209bce73..10c3cb6b04d 100644 --- a/web-api/terraform/modules/everything-else-deprecated/cognito.tf +++ b/web-api/terraform/modules/everything-else-deprecated/cognito.tf @@ -162,7 +162,7 @@ resource "aws_cognito_user_pool_client" "client" { explicit_auth_flows = ["ADMIN_NO_SRP_AUTH", "USER_PASSWORD_AUTH"] generate_secret = false - allowed_oauth_flows_user_pool_client = false + allowed_oauth_flows_user_pool_client = true token_validity_units { access_token = "hours" @@ -173,6 +173,9 @@ resource "aws_cognito_user_pool_client" "client" { access_token_validity = 1 id_token_validity = 1 + allowed_oauth_flows = ["code", "implicit"] + allowed_oauth_scopes = ["email", "openid", "profile", "phone", "aws.cognito.signin.user.admin"] + supported_identity_providers = ["COGNITO"] user_pool_id = aws_cognito_user_pool.pool.id @@ -345,7 +348,7 @@ resource "aws_cognito_user_pool_client" "irs_client" { explicit_auth_flows = ["ADMIN_NO_SRP_AUTH", "USER_PASSWORD_AUTH"] generate_secret = false - allowed_oauth_flows_user_pool_client = false + allowed_oauth_flows_user_pool_client = true token_validity_units { access_token = "hours" id_token = "hours" @@ -355,6 +358,10 @@ resource "aws_cognito_user_pool_client" "irs_client" { access_token_validity = 1 id_token_validity = 1 + allowed_oauth_flows = ["code", "implicit"] + allowed_oauth_scopes = ["email", "openid", "profile", "phone", "aws.cognito.signin.user.admin"] + supported_identity_providers = ["COGNITO"] + user_pool_id = aws_cognito_user_pool.irs_pool.id write_attributes = [ From b25966c748919c2fc1afae22517966f01d2df3bc Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Wed, 7 Aug 2024 16:25:18 -0500 Subject: [PATCH 439/523] Revert "devex - Replace outdated terraform module" This reverts commit 336765246e323c1b2387796fd0a4eb327b0f96b7. --- web-api/terraform/modules/dynamsoft/dynamsoft.tf | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/web-api/terraform/modules/dynamsoft/dynamsoft.tf b/web-api/terraform/modules/dynamsoft/dynamsoft.tf index b35552c2ded..09df081dd3c 100644 --- a/web-api/terraform/modules/dynamsoft/dynamsoft.tf +++ b/web-api/terraform/modules/dynamsoft/dynamsoft.tf @@ -10,16 +10,22 @@ resource "aws_instance" "dynamsoft" { Name = "dynamsoft-${var.environment}" environment = var.environment } - user_data = templatefile("${path.module}/setup_dynamsoft.sh", { - dynamsoft_s3_zip_path = var.dynamsoft_s3_zip_path - dynamsoft_url = var.dynamsoft_url - dynamsoft_product_keys = var.dynamsoft_product_keys - }) + user_data = data.template_file.setup_dynamsoft.rendered user_data_replace_on_change = true iam_instance_profile = "dynamsoft_s3_download_role" } +data "template_file" "setup_dynamsoft" { + template = file("${path.module}/setup_dynamsoft.sh") + + vars = { + dynamsoft_s3_zip_path = var.dynamsoft_s3_zip_path + dynamsoft_url = var.dynamsoft_url + dynamsoft_product_keys = var.dynamsoft_product_keys + } +} + resource "aws_security_group" "dynamsoft_load_balancer_security_group" { name = "dynamsoft-load-balancer-${var.environment}" description = "dynamsoft-load-balancer-security-group" From cad92124da27511a45de54496e1ce9b23d6786ea Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 7 Aug 2024 14:55:32 -0700 Subject: [PATCH 440/523] 10417: Remove defaulting of user to petitioner. Rely on role to come in the identity token --- web-api/src/middleware/apiGatewayHelper.test.ts | 17 ----------------- web-api/src/middleware/apiGatewayHelper.ts | 3 +-- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/web-api/src/middleware/apiGatewayHelper.test.ts b/web-api/src/middleware/apiGatewayHelper.test.ts index 5f88d479820..f41af22ed1a 100644 --- a/web-api/src/middleware/apiGatewayHelper.test.ts +++ b/web-api/src/middleware/apiGatewayHelper.test.ts @@ -406,23 +406,6 @@ describe('getUserFromAuthHeader', () => { expect(user?.userId).toEqual(mockUser['custom:userId']); }); - it('should default to a petitioner role when no role is present in the token', () => { - const mockNoRoleUser = { - 'custom:userId': '188a5b0f-e7ae-4647-98a1-43a0d4d00eee', - name: 'Test Petitioner', - }; - const noRoleToken = jwt.sign(mockNoRoleUser, 'secret'); - - const user = getUserFromAuthHeader({ - headers: { - Authorization: `Bearer ${noRoleToken}`, - token, - }, - }); - - expect(user?.role).toEqual(ROLES.petitioner); - }); - describe('redirect', () => { it('should return a redirect status in the header', async () => { const response = await redirect({}, () => ({ url: 'example.com' })); diff --git a/web-api/src/middleware/apiGatewayHelper.ts b/web-api/src/middleware/apiGatewayHelper.ts index d159e66568c..ca908d7c3af 100644 --- a/web-api/src/middleware/apiGatewayHelper.ts +++ b/web-api/src/middleware/apiGatewayHelper.ts @@ -3,7 +3,6 @@ import { UnauthorizedError, UnsanitizedEntityError, } from '@web-api/errors/errors'; -import { ROLES } from '@shared/business/entities/EntityConstants'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; import { createApplicationContext } from '../applicationContext'; import { headerOverride } from '../lambdaWrapper'; @@ -178,7 +177,7 @@ export const getUserFromAuthHeader = (event): UnknownAuthUser => { return { email: decoded.email, name: decoded.name || decoded['custom:name'], // custom:name only exists locally. This is a workaround for cognito-local. - role: decoded['custom:role'] || ROLES.petitioner, + role: decoded['custom:role'], userId: decoded['custom:userId'], }; } else { From fb9fb7af6b0f6647dd82598da56f570127f0f652 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 8 Aug 2024 15:40:13 -0500 Subject: [PATCH 441/523] 10417 add ability to update name in cognito --- shared/admin-tools/user/admin.ts | 1 + web-api/src/gateways/user/updateUser.test.ts | 25 ++++++++++++++++++++ web-api/src/gateways/user/updateUser.ts | 8 +++++++ 3 files changed, 34 insertions(+) diff --git a/shared/admin-tools/user/admin.ts b/shared/admin-tools/user/admin.ts index 562ec3c1ce4..9489bbebdb5 100644 --- a/shared/admin-tools/user/admin.ts +++ b/shared/admin-tools/user/admin.ts @@ -124,6 +124,7 @@ export async function createOrUpdateUser( if (userExists) { await applicationContext.getUserGateway().updateUser(applicationContext, { attributesToUpdate: { + name: rawUser.name, role: rawUser.role, }, email: rawUser.email!, diff --git a/web-api/src/gateways/user/updateUser.test.ts b/web-api/src/gateways/user/updateUser.test.ts index fa9d82e02e0..76c7a076c40 100644 --- a/web-api/src/gateways/user/updateUser.test.ts +++ b/web-api/src/gateways/user/updateUser.test.ts @@ -60,6 +60,31 @@ describe('updateUser', () => { }); }); + it('should update the user`s name in persistence when it is provided as an attribute to update', async () => { + const mockUserPoolId = 'test'; + applicationContext.environment.UserPoolId = mockUserPoolId; + + await updateUser(applicationContext, { + attributesToUpdate: { + name: 'Tattersail', + }, + email: mockEmail, + }); + + expect( + applicationContext.getCognito().adminUpdateUserAttributes, + ).toHaveBeenCalledWith({ + UserAttributes: [ + { + Name: 'name', + Value: 'Tattersail', + }, + ], + UserPoolId: applicationContext.environment.userPoolId, + Username: mockLowerCasedEmail, + }); + }); + it('should update the user`s role and email in persistence when they are both provided as attributes to update', async () => { const mockUserPoolId = 'test'; applicationContext.environment.userPoolId = mockUserPoolId; diff --git a/web-api/src/gateways/user/updateUser.ts b/web-api/src/gateways/user/updateUser.ts index 210f52e4c18..443a4901cf4 100644 --- a/web-api/src/gateways/user/updateUser.ts +++ b/web-api/src/gateways/user/updateUser.ts @@ -5,6 +5,7 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; interface UserAttributes { role?: Role; email?: string; + name?: string; } export async function updateUser( @@ -35,6 +36,13 @@ export async function updateUser( }); } + if (attributesToUpdate.name) { + formattedAttributesToUpdate.push({ + Name: 'name', + Value: attributesToUpdate.name, + }); + } + await applicationContext.getCognito().adminUpdateUserAttributes({ UserAttributes: formattedAttributesToUpdate, UserPoolId: poolId ?? applicationContext.environment.userPoolId, From afe5cd4c64d4557ee1702c4e7af530e0c7b94c64 Mon Sep 17 00:00:00 2001 From: Christopher Bisom Date: Mon, 12 Aug 2024 16:10:50 -0400 Subject: [PATCH 442/523] Remove duplicate, outdated file --- .../fileCourtIssuedOrderInteractor.test.ts | 509 ------------------ .../fileCourtIssuedOrderInteractor.ts | 150 ------ 2 files changed, 659 deletions(-) delete mode 100644 web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.test.ts delete mode 100644 web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.ts diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.test.ts b/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.test.ts deleted file mode 100644 index 684f252bd5a..00000000000 --- a/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.test.ts +++ /dev/null @@ -1,509 +0,0 @@ -import { - CASE_STATUS_TYPES, - CASE_TYPES_MAP, - CONTACT_TYPES, - COUNTRY_TYPES, - PARTY_TYPES, - PETITIONS_SECTION, - ROLES, -} from '../../../../../shared/src/business/entities/EntityConstants'; -import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock'; -import { ServiceUnavailableError } from '@web-api/errors/errors'; -import { User } from '../../../../../shared/src/business/entities/User'; -import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; -import { fileCourtIssuedOrderInteractor } from './fileCourtIssuedOrderInteractor'; - -describe('fileCourtIssuedOrderInteractor', () => { - const mockUserId = applicationContext.getUniqueId(); - const caseRecord = { - caseCaption: 'Caption', - caseType: CASE_TYPES_MAP.whistleblower, - createdAt: '', - docketEntries: [ - { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - docketNumber: '45678-18', - documentType: 'Answer', - eventCode: 'A', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: mockUserId, - }, - { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - docketNumber: '45678-18', - documentType: 'Answer', - eventCode: 'A', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: mockUserId, - }, - { - docketEntryId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - docketNumber: '45678-18', - documentType: 'Answer', - eventCode: 'A', - filedBy: 'Test Petitioner', - filedByRole: ROLES.petitioner, - userId: mockUserId, - }, - ], - docketNumber: '45678-18', - docketNumberWithSuffix: '45678-18W', - filingType: 'Myself', - partyType: PARTY_TYPES.petitioner, - petitioners: [ - { - address1: '123 Main St', - city: 'Somewhere', - contactType: CONTACT_TYPES.primary, - countryType: COUNTRY_TYPES.DOMESTIC, - email: 'fieri@example.com', - name: 'Roslindis Angelino', - phone: '1234567890', - postalCode: '12345', - state: 'CA', - }, - ], - preferredTrialCity: 'Fresno, California', - procedureType: 'Regular', - role: ROLES.petitioner, - status: CASE_STATUS_TYPES.new, - userId: 'ddd6c900-388b-4151-8014-b3378076bfb0', - }; - let mockLock; - - beforeAll(() => { - applicationContext - .getPersistenceGateway() - .getLock.mockImplementation(() => mockLock); - }); - - beforeEach(() => { - mockLock = undefined; - applicationContext.getCurrentUser.mockReturnValue( - new User({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ); - - applicationContext.getPersistenceGateway().getUserById.mockReturnValue( - new User({ - name: 'Emmett Lathrop "Doc" Brown, Ph.D.', - role: ROLES.petitionsClerk, - userId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ); - - applicationContext - .getPersistenceGateway() - .getCaseByDocketNumber.mockReturnValue(caseRecord); - }); - - it('should throw an error if not authorized', async () => { - applicationContext.getCurrentUser.mockReturnValue({}); - - await expect( - fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - eventCode: 'OSC', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ).rejects.toThrow('Unauthorized'); - }); - - it('should add order document to case', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries.length, - ).toEqual(4); - }); - - it('should add order document to case and set freeText and draftOrderState.freeText to the document title if it is a generic order (eventCode O)', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - draftOrderState: {}, - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries.length, - ).toEqual(4); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3], - ).toMatchObject({ - draftOrderState: { freeText: 'Order to do anything' }, - freeText: 'Order to do anything', - }); - }); - - it('should delete draftOrderState properties if they exists on the documentMetadata, after saving the document', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: {}, - documentTitle: 'Order to do anything', - documentType: 'Order', - draftOrderState: { - documentContents: 'something', - editorDelta: 'something', - richText: 'something', - }, - eventCode: 'O', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3].draftOrderState.documentContents, - ).toBeUndefined(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3].draftOrderState.editorDelta, - ).toBeUndefined(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3].draftOrderState.richText, - ).toBeUndefined(); - }); - - it('should add a generic notice document to case, set freeText to the document title, and set the document to signed', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Notice to be nice', - documentType: 'Notice', - eventCode: 'NOT', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().updateCase, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries.length, - ).toEqual(4); - const result = - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3]; - expect(result).toMatchObject({ freeText: 'Notice to be nice' }); - expect(result.signedAt).toBeTruthy(); - }); - - it('should store documentMetadata.documentContents in S3 and delete from data sent to persistence', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().saveDocumentFromLambda.mock - .calls[0][0], - ).toMatchObject({ - useTempBucket: false, - }); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3].documentContents, - ).toBeUndefined(); - expect( - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[3], - ).toMatchObject({ - documentContentsId: expect.anything(), - draftOrderState: {}, - }); - }); - - it('should append docket number with suffix and case caption to document contents before storing', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - const savedDocumentContents = JSON.parse( - applicationContext - .getPersistenceGateway() - .saveDocumentFromLambda.mock.calls[0][0].document.toString(), - ).documentContents; - - expect(savedDocumentContents).toContain(caseRecord.docketNumberWithSuffix); - expect(savedDocumentContents).toContain(caseRecord.caseCaption); - }); - - it('should set documentMetadata documentContents if parseAndScrapePdfContents returns content', async () => { - const mockDocumentContents = 'bloop ee doop brnabowbow'; - applicationContext - .getUseCaseHelpers() - .parseAndScrapePdfContents.mockReturnValue(mockDocumentContents); - - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - const savedDocumentContents = JSON.parse( - applicationContext - .getPersistenceGateway() - .saveDocumentFromLambda.mock.calls[0][0].document.toString(), - ).documentContents; - - expect(savedDocumentContents).toContain(mockDocumentContents); - }); - - it('should parse and scrape pdf contents', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'TC Opinion', - documentType: 'T.C. Opinion', - eventCode: 'TCOP', - judge: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getUseCaseHelpers().parseAndScrapePdfContents, - ).toHaveBeenCalled(); - }); - - it('should add order document to most recent message if a parentMessageId is passed in', async () => { - applicationContext - .getPersistenceGateway() - .getMessageThreadByParentId.mockReturnValue([ - { - caseStatus: caseRecord.status, - caseTitle: PARTY_TYPES.petitioner, - createdAt: '2019-03-01T21:40:46.415Z', - docketNumber: caseRecord.docketNumber, - docketNumberWithSuffix: caseRecord.docketNumber, - from: 'Test Petitionsclerk', - fromSection: PETITIONS_SECTION, - fromUserId: '4791e892-14ee-4ab1-8468-0c942ec379d2', - message: 'hey there', - messageId: 'a10d6855-f3ee-4c11-861c-c7f11cba4dff', - parentMessageId: '31687a1e-3640-42cd-8e7e-a8e6df39ce9a', - subject: 'hello', - to: 'Test Petitionsclerk2', - toSection: PETITIONS_SECTION, - toUserId: '449b916e-3362-4a5d-bf56-b2b94ba29c12', - }, - ]); - - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - eventCode: 'O', - parentMessageId: '6c1fd626-c1e1-4367-bca6-e00f9ef98cf5', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().updateMessage, - ).toHaveBeenCalled(); - expect( - applicationContext.getPersistenceGateway().updateMessage.mock.calls[0][0] - .message.attachments, - ).toEqual([ - { - documentId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - documentTitle: 'Order to do anything', - }, - ]); - }); - - it('should set isDraft to true when creating a court issued document', async () => { - applicationContext - .getPersistenceGateway() - .getMessageThreadByParentId.mockReturnValue([ - { - caseStatus: caseRecord.status, - caseTitle: PARTY_TYPES.petitioner, - createdAt: '2019-03-01T21:40:46.415Z', - docketNumber: caseRecord.docketNumber, - docketNumberWithSuffix: caseRecord.docketNumber, - from: 'Test Petitionsclerk', - fromSection: PETITIONS_SECTION, - fromUserId: '4791e892-14ee-4ab1-8468-0c942ec379d2', - message: 'hey there', - messageId: 'a10d6855-f3ee-4c11-861c-c7f11cba4dff', - parentMessageId: '31687a1e-3640-42cd-8e7e-a8e6df39ce9a', - subject: 'hello', - to: 'Test Petitionsclerk2', - toSection: PETITIONS_SECTION, - toUserId: '449b916e-3362-4a5d-bf56-b2b94ba29c12', - }, - ]); - - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'Order to do anything', - documentType: 'Order', - eventCode: 'O', - parentMessageId: '6c1fd626-c1e1-4367-bca6-e00f9ef98cf5', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - const lastDocumentIndex = - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries.length - 1; - - const newlyFiledDocument = - applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0] - .caseToUpdate.docketEntries[lastDocumentIndex]; - - expect(newlyFiledDocument).toMatchObject({ - isDraft: true, - }); - }); - - it('should throw an error if fails to parse pdf', async () => { - applicationContext - .getUseCaseHelpers() - .parseAndScrapePdfContents.mockImplementation(() => { - throw new Error('error parsing pdf'); - }); - - await expect( - fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentTitle: 'TC Opinion', - documentType: 'T.C. Opinion', - eventCode: 'TCOP', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ).rejects.toThrow('error parsing pdf'); - }); - - it('should throw a ServiceUnavailableError if the Case is currently locked', async () => { - mockLock = MOCK_LOCK; - - await expect( - fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }), - ).rejects.toThrow(ServiceUnavailableError); - - expect( - applicationContext.getPersistenceGateway().getCaseByDocketNumber, - ).not.toHaveBeenCalled(); - }); - - it('should acquire and remove the lock on the case', async () => { - await fileCourtIssuedOrderInteractor(applicationContext, { - documentMetadata: { - docketNumber: caseRecord.docketNumber, - documentContents: 'I am some document contents', - documentType: 'Order to Show Cause', - eventCode: 'OSC', - signedAt: '2019-03-01T21:40:46.415Z', - signedByUserId: mockUserId, - signedJudgeName: 'Dredd', - }, - primaryDocumentFileId: 'c54ba5a9-b37b-479d-9201-067ec6e335bb', - }); - - expect( - applicationContext.getPersistenceGateway().createLock, - ).toHaveBeenCalledWith({ - applicationContext, - identifier: `case|${caseRecord.docketNumber}`, - ttl: 30, - }); - - expect( - applicationContext.getPersistenceGateway().removeLock, - ).toHaveBeenCalledWith({ - applicationContext, - identifiers: [`case|${caseRecord.docketNumber}`], - }); - }); -}); diff --git a/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.ts b/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.ts deleted file mode 100644 index 39390119fbc..00000000000 --- a/web-api/src/business/useCases/courtIssuedDocument/fileCourtIssuedOrderInteractor.ts +++ /dev/null @@ -1,150 +0,0 @@ -import { Case } from '../../../../../shared/src/business/entities/cases/Case'; -import { DOCUMENT_RELATIONSHIPS } from '../../../../../shared/src/business/entities/EntityConstants'; -import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; -import { Message } from '../../../../../shared/src/business/entities/Message'; -import { - ROLE_PERMISSIONS, - isAuthorized, -} from '../../../../../shared/src/authorization/authorizationClientService'; -import { ServerApplicationContext } from '@web-api/applicationContext'; -import { UnauthorizedError } from '@web-api/errors/errors'; -import { orderBy } from 'lodash'; -import { withLocking } from '@web-api/business/useCaseHelper/acquireLock'; - -export const fileCourtIssuedOrder = async ( - applicationContext: ServerApplicationContext, - { - documentMetadata, - primaryDocumentFileId, - }: { documentMetadata: any; primaryDocumentFileId: string }, -): Promise => { - const authorizedUser = applicationContext.getCurrentUser(); - const { docketNumber } = documentMetadata; - - if (!isAuthorized(authorizedUser, ROLE_PERMISSIONS.COURT_ISSUED_DOCUMENT)) { - throw new UnauthorizedError('Unauthorized'); - } - - const user = await applicationContext - .getPersistenceGateway() - .getUserById({ applicationContext, userId: authorizedUser.userId }); - - const caseToUpdate = await applicationContext - .getPersistenceGateway() - .getCaseByDocketNumber({ - applicationContext, - docketNumber, - }); - const caseEntity = new Case(caseToUpdate, { applicationContext }); - - const shouldScrapePDFContents = !documentMetadata.documentContents; - - if (['O', 'NOT'].includes(documentMetadata.eventCode)) { - documentMetadata.freeText = documentMetadata.documentTitle; - if (documentMetadata.draftOrderState) { - documentMetadata.draftOrderState.freeText = - documentMetadata.documentTitle; - } - } - - if (shouldScrapePDFContents) { - const pdfBuffer = await applicationContext - .getPersistenceGateway() - .getDocument({ applicationContext, key: primaryDocumentFileId }); - - const contents = await applicationContext - .getUseCaseHelpers() - .parseAndScrapePdfContents({ applicationContext, pdfBuffer }); - - if (contents) { - documentMetadata.documentContents = contents; - } - } - - if (documentMetadata.documentContents) { - documentMetadata.documentContents += ` ${caseEntity.docketNumberWithSuffix} ${caseEntity.caseCaption}`; - - const documentContentsId = applicationContext.getUniqueId(); - - const contentToStore = { - documentContents: documentMetadata.documentContents, - richText: documentMetadata.draftOrderState - ? documentMetadata.draftOrderState.richText - : undefined, - }; - - await applicationContext.getPersistenceGateway().saveDocumentFromLambda({ - applicationContext, - contentType: 'application/json', - document: Buffer.from(JSON.stringify(contentToStore)), - key: documentContentsId, - useTempBucket: false, - }); - - if (documentMetadata.draftOrderState) { - delete documentMetadata.draftOrderState.documentContents; - delete documentMetadata.draftOrderState.richText; - delete documentMetadata.draftOrderState.editorDelta; - } - - delete documentMetadata.documentContents; - documentMetadata.documentContentsId = documentContentsId; - } - - const docketEntryEntity = new DocketEntry( - { - ...documentMetadata, - docketEntryId: primaryDocumentFileId, - documentType: documentMetadata.documentType, - filedBy: user.name, - isDraft: true, - isFileAttached: true, - relationship: DOCUMENT_RELATIONSHIPS.PRIMARY, - }, - { applicationContext }, - ); - - docketEntryEntity.setFiledBy(user); - - docketEntryEntity.setAsProcessingStatusAsCompleted(); - - caseEntity.addDocketEntry(docketEntryEntity); - - await applicationContext.getUseCaseHelpers().updateCaseAndAssociations({ - applicationContext, - caseToUpdate: caseEntity, - }); - - if (documentMetadata.parentMessageId) { - const messages = await applicationContext - .getPersistenceGateway() - .getMessageThreadByParentId({ - applicationContext, - parentMessageId: documentMetadata.parentMessageId, - }); - - const mostRecentMessage = orderBy(messages, 'createdAt', 'desc')[0]; - - const messageEntity = new Message(mostRecentMessage, { - applicationContext, - }).validate(); - messageEntity.addAttachment({ - documentId: docketEntryEntity.docketEntryId, - documentTitle: docketEntryEntity.documentTitle, - }); - - await applicationContext.getPersistenceGateway().updateMessage({ - applicationContext, - message: messageEntity.validate().toRawObject(), - }); - } - - return caseEntity.toRawObject(); -}; - -export const fileCourtIssuedOrderInteractor = withLocking( - fileCourtIssuedOrder, - (_applicationContext: ServerApplicationContext, { documentMetadata }) => ({ - identifiers: [`case|${documentMetadata.docketNumber}`], - }), -); From 38588aed23a1c77d5421fab704246cc4cb7de894 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 20 Aug 2024 08:27:19 -0700 Subject: [PATCH 443/523] 10417: Update tests --- .../generatePetitionPdfInteractor.test.ts | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/shared/src/business/useCases/generatePetitionPdfInteractor.test.ts b/shared/src/business/useCases/generatePetitionPdfInteractor.test.ts index 2853be77b8b..bffaef8fa8c 100644 --- a/shared/src/business/useCases/generatePetitionPdfInteractor.test.ts +++ b/shared/src/business/useCases/generatePetitionPdfInteractor.test.ts @@ -30,7 +30,7 @@ describe('generatePetitionPdfInteractor', () => { it('should throw an Unauthorized user error when user does not have the correct permissions', async () => { await expect( - generatePetitionPdfInteractor(applicationContext, {}, undefined), + generatePetitionPdfInteractor(applicationContext, {} as any, undefined), ).rejects.toThrow('Unauthorized'); }); @@ -144,21 +144,25 @@ describe('generatePetitionPdfInteractor', () => { }, ]; - const results = await generatePetitionPdfInteractor(applicationContext, { - caseCaptionExtension: 'TEST_caseCaptionExtension', - caseTitle: 'TEST_caseTitle', - contactPrimary: 'TEST_contactPrimary' as any, - contactSecondary: 'TEST_contactSecondary' as any, - hasIrsNotice: true, - hasUploadedIrsNotice: true, - irsNotices, - originalCaseType: 'Disclosure1', - partyType: 'TEST_partyType', - petitionFacts: ['TEST_petitionFacts'], - petitionReasons: ['TEST_petitionReasons'], - preferredTrialCity: 'TEST_preferredTrialCity', - procedureType: 'TEST_procedureType', - }); + const results = await generatePetitionPdfInteractor( + applicationContext, + { + caseCaptionExtension: 'TEST_caseCaptionExtension', + caseTitle: 'TEST_caseTitle', + contactPrimary: 'TEST_contactPrimary' as any, + contactSecondary: 'TEST_contactSecondary' as any, + hasIrsNotice: true, + hasUploadedIrsNotice: true, + irsNotices, + originalCaseType: 'Disclosure1', + partyType: 'TEST_partyType', + petitionFacts: ['TEST_petitionFacts'], + petitionReasons: ['TEST_petitionReasons'], + preferredTrialCity: 'TEST_preferredTrialCity', + procedureType: 'TEST_procedureType', + }, + mockPetitionerUser, + ); const petitionCalls = applicationContext.getDocumentGenerators().petition.mock.calls; From dd44c545735cacb838aa99d668b95d028d3d779b Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Tue, 20 Aug 2024 11:42:26 -0500 Subject: [PATCH 444/523] 10417 add wrapper in validateRawCollection return type --- shared/src/business/entities/JoiValidationEntity.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/src/business/entities/JoiValidationEntity.ts b/shared/src/business/entities/JoiValidationEntity.ts index a9e1c563fc7..f826965f8ae 100644 --- a/shared/src/business/entities/JoiValidationEntity.ts +++ b/shared/src/business/entities/JoiValidationEntity.ts @@ -199,9 +199,9 @@ export abstract class JoiValidationEntity { ) { return collection.map( rawEntity => - new this(rawEntity, ...args) - .validate() - .toRawObject() as ExcludeMethods, + new this(rawEntity, ...args).validate().toRawObject() as ExcludeMethods< + InstanceType + >, ); } } From c17795dcd9f54c9e3a63c161c1c77b284975c7c0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 20 Aug 2024 10:30:56 -0700 Subject: [PATCH 445/523] 10417: Fix type errors. Remove unused parameter from sendNotificationOfSealing --- .../noticeOfChangeToInPersonProceeding.ts | 6 +++--- .../src/business/utilities/documentGenerators/petition.ts | 3 ++- .../src/business/utilities/getFormattedCaseDetail.test.ts | 2 +- web-api/src/dispatchers/sns/sendNotificationOfSealing.ts | 8 ++------ 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/shared/src/business/utilities/documentGenerators/noticeOfChangeToInPersonProceeding.ts b/shared/src/business/utilities/documentGenerators/noticeOfChangeToInPersonProceeding.ts index 498988cdc00..e0f8e94b72c 100644 --- a/shared/src/business/utilities/documentGenerators/noticeOfChangeToInPersonProceeding.ts +++ b/shared/src/business/utilities/documentGenerators/noticeOfChangeToInPersonProceeding.ts @@ -1,5 +1,5 @@ import { DateServedFooter } from '@shared/business/utilities/pdfGenerator/components/DateServedFooter'; -import { FormattedTrialInfo } from '@web-api/business/useCases/trialSessions/generateNoticeOfChangeOfTrialJudgeInteractor'; +import { FormattedTrialInfoType } from '@web-api/business/useCases/trialSessions/generateNoticeOfTrialIssuedInteractor'; import { NoticeOfChangeToInPersonProceeding } from '@shared/business/utilities/pdfGenerator/documentTemplates/NoticeOfChangeToInPersonProceeding'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; @@ -17,9 +17,9 @@ export const noticeOfChangeToInPersonProceeding = async ({ docketNumberWithSuffix: string; nameOfClerk: string; titleOfClerk: string; - trialInfo: FormattedTrialInfo; + trialInfo: FormattedTrialInfoType; }; -}): Promise => { +}): Promise => { const noticeOfChangeToInPersonProceedingTemplate = ReactDOM.renderToString( React.createElement(NoticeOfChangeToInPersonProceeding, data), ); diff --git a/shared/src/business/utilities/documentGenerators/petition.ts b/shared/src/business/utilities/documentGenerators/petition.ts index 4554341da9b..49f76330ae3 100644 --- a/shared/src/business/utilities/documentGenerators/petition.ts +++ b/shared/src/business/utilities/documentGenerators/petition.ts @@ -3,6 +3,7 @@ import { PetitionPdfBase, } from '@shared/business/useCases/generatePetitionPdfInteractor'; import { Petition } from '@shared/business/utilities/pdfGenerator/documentTemplates/Petition'; +import { ServerApplicationContext } from '@web-api/applicationContext'; import { generateHTMLTemplateForPDF } from '../generateHTMLTemplateForPDF/generateHTMLTemplateForPDF'; import React from 'react'; import ReactDOM from 'react-dom/server'; @@ -11,7 +12,7 @@ export const petition = async ({ applicationContext, data, }: { - applicationContext: IApplicationContext; + applicationContext: ServerApplicationContext; data: PetitionPdfBase & { caseDescription: string; irsNotices: IrsNoticesWithCaseDescription[]; diff --git a/shared/src/business/utilities/getFormattedCaseDetail.test.ts b/shared/src/business/utilities/getFormattedCaseDetail.test.ts index 0267dc9ff9c..e4aa9c014b3 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.test.ts +++ b/shared/src/business/utilities/getFormattedCaseDetail.test.ts @@ -1,6 +1,6 @@ import { CASE_STATUS_TYPES, PAYMENT_STATUS } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; -import { applicationContext } from '../../../../web-client/src/applicationContext'; +import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { formatCase, getFormattedCaseDetail } from './getFormattedCaseDetail'; import { mockDocketClerkUser } from '@shared/test/mockAuthUsers'; diff --git a/web-api/src/dispatchers/sns/sendNotificationOfSealing.ts b/web-api/src/dispatchers/sns/sendNotificationOfSealing.ts index d5589bef36b..5329a0fda24 100644 --- a/web-api/src/dispatchers/sns/sendNotificationOfSealing.ts +++ b/web-api/src/dispatchers/sns/sendNotificationOfSealing.ts @@ -3,13 +3,10 @@ import { ServerApplicationContext } from '@web-api/applicationContext'; export const sendNotificationOfSealing = async ( applicationContext: ServerApplicationContext, - { - docketEntryId, - docketNumber, - }: { docketEntryId: string; docketNumber: string }, + { docketNumber }: { docketNumber: string }, ): Promise => { const params = { - Message: JSON.stringify({ docketEntryId, docketNumber }), + Message: JSON.stringify({ docketNumber }), TopicArn: `arn:aws:sns:us-east-1:${process.env.AWS_ACCOUNT_ID}:seal_notifier`, }; @@ -22,7 +19,6 @@ export const sendNotificationOfSealing = async ( .getNotificationService() .send(publishCommand); applicationContext.logger.info('sent notification of sealing', { - docketEntryId, docketNumber, response, }); From aa6ede20e2ac40cb6f4f3d658875755c9ccc62d8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 20 Aug 2024 14:32:45 -0700 Subject: [PATCH 446/523] 10417: updating types --- .../createAndServeNoticeDocketEntry.ts | 2 +- ...erateNoticeOfChangeToInPersonProceeding.ts | 2 +- ...tePrintableFilingReceiptInteractor.test.ts | 28 +++++++++---------- ...tPublicDownloadPolicyUrlInteractor.test.ts | 12 +++++--- .../persistence/s3/saveDocumentFromLambda.ts | 2 +- .../actions/updatedValidatePetitionAction.ts | 2 +- .../computeds/messageDocumentHelper.ts | 2 +- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts index bd0b96d2454..abadb1a5098 100644 --- a/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts +++ b/web-api/src/business/useCaseHelper/docketEntry/createAndServeNoticeDocketEntry.ts @@ -30,7 +30,7 @@ export const createAndServeNoticeDocketEntry = async ( eventCode: string; }; newPdfDoc: any; - noticePdf: Buffer; + noticePdf: Uint8Array; onlyProSePetitioners?: boolean; }, authorizedUser: AuthUser, diff --git a/web-api/src/business/useCaseHelper/trialSessions/generateNoticeOfChangeToInPersonProceeding.ts b/web-api/src/business/useCaseHelper/trialSessions/generateNoticeOfChangeToInPersonProceeding.ts index ee2380b5fb6..37d2e01f21c 100644 --- a/web-api/src/business/useCaseHelper/trialSessions/generateNoticeOfChangeToInPersonProceeding.ts +++ b/web-api/src/business/useCaseHelper/trialSessions/generateNoticeOfChangeToInPersonProceeding.ts @@ -14,7 +14,7 @@ export const generateNoticeOfChangeToInPersonProceeding = async ( docketNumber, trialSessionInformation, }: { docketNumber: string; trialSessionInformation: any }, -): Promise => { +): Promise => { const formattedStartDate = formatDateString( trialSessionInformation.startDate, FORMATS.MONTH_DAY_YEAR_WITH_DAY_OF_WEEK, diff --git a/web-api/src/business/useCases/docketEntry/generatePrintableFilingReceiptInteractor.test.ts b/web-api/src/business/useCases/docketEntry/generatePrintableFilingReceiptInteractor.test.ts index a8e7cae6702..4b8d02a2cf4 100644 --- a/web-api/src/business/useCases/docketEntry/generatePrintableFilingReceiptInteractor.test.ts +++ b/web-api/src/business/useCases/docketEntry/generatePrintableFilingReceiptInteractor.test.ts @@ -143,10 +143,10 @@ describe('generatePrintableFilingReceiptInteractor', () => { expect(receiptMockCall.secondaryDocument).toBeDefined(); }); - it( - 'formats certificateOfServiceDate', - async () => { - await generatePrintableFilingReceiptInteractor(applicationContext, { + it('formats certificateOfServiceDate', async () => { + await generatePrintableFilingReceiptInteractor( + applicationContext, + { docketNumber: mockCase.docketNumber, documentsFiled: { certificateOfService: true, @@ -154,17 +154,17 @@ describe('generatePrintableFilingReceiptInteractor', () => { primaryDocumentId: mockPrimaryDocketEntryId, }, fileAcrossConsolidatedGroup: false, - }); + }, + mockDocketClerkUser, + ); - const receiptMockCall = - applicationContext.getDocumentGenerators().receiptOfFiling.mock - .calls[0][0].data; - expect( - receiptMockCall.document.formattedCertificateOfServiceDate, - ).toEqual('08/25/19'); - }, - mockDocketClerkUser, - ); + const receiptMockCall = + applicationContext.getDocumentGenerators().receiptOfFiling.mock + .calls[0][0].data; + expect(receiptMockCall.document.formattedCertificateOfServiceDate).toEqual( + '08/25/19', + ); + }); it('should call the Receipt of Filing document generator with consolidatedCases array populated when fileAcrossConsolidatedGroup is true', async () => { await generatePrintableFilingReceiptInteractor( diff --git a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts index 7892fba48c1..bd602a0d170 100644 --- a/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts +++ b/web-api/src/business/useCases/public/getPublicDownloadPolicyUrlInteractor.test.ts @@ -66,10 +66,14 @@ describe('getPublicDownloadPolicyUrlInteractor', () => { .getCaseByDocketNumber.mockReturnValue({ docketEntries: [] }); await expect( - getPublicDownloadPolicyUrlInteractor(applicationContext, { - docketNumber: '123-20', - key: '9de27a7d-7c6b-434b-803b-7655f82d5e07', - } as any), + getPublicDownloadPolicyUrlInteractor( + applicationContext, + { + docketNumber: '123-20', + key: '9de27a7d-7c6b-434b-803b-7655f82d5e07', + } as any, + mockDocketClerkUser, + ), ).rejects.toThrow('Case 123-20 was not found.'); }); diff --git a/web-api/src/persistence/s3/saveDocumentFromLambda.ts b/web-api/src/persistence/s3/saveDocumentFromLambda.ts index be26a0ebfc0..d3bc3501b5f 100644 --- a/web-api/src/persistence/s3/saveDocumentFromLambda.ts +++ b/web-api/src/persistence/s3/saveDocumentFromLambda.ts @@ -9,7 +9,7 @@ export const saveDocumentFromLambda = async ({ }: { applicationContext: ServerApplicationContext; contentType?: string; - document: any; + document: WithImplicitCoercion; key: string; useTempBucket?: boolean; }): Promise => { diff --git a/web-client/src/presenter/actions/updatedValidatePetitionAction.ts b/web-client/src/presenter/actions/updatedValidatePetitionAction.ts index de2ad753ef2..fd8e80ed2f0 100644 --- a/web-client/src/presenter/actions/updatedValidatePetitionAction.ts +++ b/web-client/src/presenter/actions/updatedValidatePetitionAction.ts @@ -4,7 +4,7 @@ export const updatedValidatePetitionAction = ({ applicationContext, get, path, -}: ActionProps<{}, IApplicationContext>) => { +}: ActionProps) => { const petition = get(state.petitionFormatted); const errors = applicationContext diff --git a/web-client/src/presenter/computeds/messageDocumentHelper.ts b/web-client/src/presenter/computeds/messageDocumentHelper.ts index 9eaf583a0f1..7db2a85a0da 100644 --- a/web-client/src/presenter/computeds/messageDocumentHelper.ts +++ b/web-client/src/presenter/computeds/messageDocumentHelper.ts @@ -125,7 +125,7 @@ export const messageDocumentHelper = ( // The variables affected by formattedDocument are showApplyStampButton and showStatusReportOrderButton. const { draftDocuments } = applicationContext .getUtilities() - .formatCase(applicationContext, caseDetail); + .formatCase(applicationContext, caseDetail, user); const formattedDocument = draftDocuments.find( doc => doc.docketEntryId === viewerDocumentToDisplayDocumentId, ); From b39eae2415c8127815579325ee0aacc6328c7111 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 22 Aug 2024 13:46:49 -0500 Subject: [PATCH 447/523] deps: easy lib upgrades --- package-lock.json | 2506 +++++++++++++++++++++++---------------------- package.json | 76 +- 2 files changed, 1332 insertions(+), 1250 deletions(-) diff --git a/package-lock.json b/package-lock.json index e49e57a1f93..7c5ab29ab42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,34 +12,34 @@ "dependencies": { "@18f/us-federal-holidays": "4.0.0", "@aws-crypto/sha256-browser": "5.2.0", - "@aws-sdk/client-api-gateway": "3.632.0", - "@aws-sdk/client-apigatewaymanagementapi": "3.632.0", - "@aws-sdk/client-apigatewayv2": "3.632.0", - "@aws-sdk/client-cloudfront": "3.632.0", - "@aws-sdk/client-cloudwatch": "3.632.0", - "@aws-sdk/client-cloudwatch-logs": "3.632.0", - "@aws-sdk/client-cognito-identity-provider": "3.632.0", - "@aws-sdk/client-dynamodb": "3.632.0", - "@aws-sdk/client-dynamodb-streams": "3.632.0", - "@aws-sdk/client-glue": "3.632.0", - "@aws-sdk/client-lambda": "3.632.0", - "@aws-sdk/client-opensearch": "3.632.0", - "@aws-sdk/client-route-53": "3.632.0", - "@aws-sdk/client-s3": "3.633.0", - "@aws-sdk/client-ses": "3.632.0", - "@aws-sdk/client-sns": "3.632.0", - "@aws-sdk/client-sqs": "3.632.0", - "@aws-sdk/client-ssm": "3.632.0", + "@aws-sdk/client-api-gateway": "3.635.0", + "@aws-sdk/client-apigatewaymanagementapi": "3.635.0", + "@aws-sdk/client-apigatewayv2": "3.635.0", + "@aws-sdk/client-cloudfront": "3.635.0", + "@aws-sdk/client-cloudwatch": "3.635.0", + "@aws-sdk/client-cloudwatch-logs": "3.635.0", + "@aws-sdk/client-cognito-identity-provider": "3.635.0", + "@aws-sdk/client-dynamodb": "3.635.0", + "@aws-sdk/client-dynamodb-streams": "3.635.0", + "@aws-sdk/client-glue": "3.636.0", + "@aws-sdk/client-lambda": "3.636.0", + "@aws-sdk/client-opensearch": "3.635.0", + "@aws-sdk/client-route-53": "3.635.0", + "@aws-sdk/client-s3": "3.635.0", + "@aws-sdk/client-ses": "3.636.0", + "@aws-sdk/client-sns": "3.635.0", + "@aws-sdk/client-sqs": "3.635.0", + "@aws-sdk/client-ssm": "3.635.0", "@aws-sdk/cloudfront-signer": "3.621.0", - "@aws-sdk/credential-provider-node": "3.632.0", - "@aws-sdk/lib-dynamodb": "3.632.0", - "@aws-sdk/lib-storage": "3.633.0", + "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/lib-dynamodb": "3.635.0", + "@aws-sdk/lib-storage": "3.635.0", "@aws-sdk/node-http-handler": "3.374.0", "@aws-sdk/protocol-http": "3.374.0", - "@aws-sdk/s3-presigned-post": "3.633.0", - "@aws-sdk/s3-request-presigner": "3.633.0", + "@aws-sdk/s3-presigned-post": "3.635.0", + "@aws-sdk/s3-request-presigner": "3.635.0", "@aws-sdk/signature-v4": "3.374.0", - "@aws-sdk/util-dynamodb": "3.632.0", + "@aws-sdk/util-dynamodb": "3.635.0", "@cerebral/react": "4.2.1", "@fortawesome/fontawesome-svg-core": "1.2.36", "@fortawesome/free-regular-svg-icons": "5.15.4", @@ -57,7 +57,7 @@ "cerebral": "5.2.1", "classnames": "2.5.1", "cookie": "0.6.0", - "core-js": "3.38.0", + "core-js": "3.38.1", "cors": "2.8.5", "csv-stringify": "6.5.1", "deep-freeze": "0.0.1", @@ -102,12 +102,12 @@ "winston": "3.14.2" }, "devDependencies": { - "@aws-sdk/client-iam": "3.632.0", - "@aws-sdk/client-secrets-manager": "3.632.0", + "@aws-sdk/client-iam": "3.635.0", + "@aws-sdk/client-secrets-manager": "3.635.0", "@babel/cli": "7.24.8", "@babel/core": "7.25.2", "@babel/eslint-parser": "7.25.1", - "@babel/preset-env": "7.25.3", + "@babel/preset-env": "7.25.4", "@babel/preset-react": "7.24.7", "@babel/preset-typescript": "7.24.7", "@babel/register": "7.24.6", @@ -118,19 +118,19 @@ "@types/jest": "29.5.12", "@types/lodash": "4.17.7", "@types/luxon": "3.4.2", - "@types/node": "22.4.0", + "@types/node": "22.5.0", "@types/promise-retry": "1.1.6", - "@types/react": "18.3.3", + "@types/react": "18.3.4", "@types/react-dom": "18.3.0", "@types/react-paginate": "7.1.4", "@types/uuid": "10.0.0", "@types/websocket": "1.0.10", - "@typescript-eslint/eslint-plugin": "8.1.0", - "@typescript-eslint/parser": "8.1.0", + "@typescript-eslint/eslint-plugin": "8.2.0", + "@typescript-eslint/parser": "8.2.0", "@vendia/serverless-express": "4.12.6", "ajv": "8.17.1", - "artillery": "2.0.19", - "artillery-plugin-metrics-by-endpoint": "1.13.0", + "artillery": "2.0.20", + "artillery-plugin-metrics-by-endpoint": "1.14.0", "autoprefixer": "10.4.20", "aws-sdk-client-mock": "4.0.1", "axe-core": "4.10.0", @@ -150,7 +150,7 @@ "decimal.js": "10.4.3", "dynamodb-admin": "4.6.1", "dynamodb-streams-readable": "3.0.0", - "esbuild": "0.23.0", + "esbuild": "0.23.1", "esbuild-css-modules-plugin": "3.1.2", "esbuild-plugin-babel-cached": "0.2.3", "esbuild-plugin-clean": "1.0.1", @@ -177,7 +177,7 @@ "eslint-plugin-spellcheck": "0.0.20", "esm": "3.2.25", "file-loader": "6.2.0", - "husky": "9.1.4", + "husky": "9.1.5", "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", "jest-environment-node": "29.7.0", @@ -203,7 +203,7 @@ "readline": "1.3.0", "s3rver": "github:20minutes/s3rver", "sass": "1.77.8", - "sass-loader": "16.0.0", + "sass-loader": "16.0.1", "shuffle-seed": "1.1.6", "stream-browserify": "3.0.0", "style-loader": "4.0.0", @@ -218,7 +218,7 @@ "ts-loader": "9.5.1", "ts-node": "10.9.2", "tsconfig-paths": "4.2.0", - "typescript": "5.4.5", + "typescript": "5.5.4", "utf8": "3.0.0" }, "engines": { @@ -445,9 +445,9 @@ } }, "node_modules/@artilleryio/int-commons": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/@artilleryio/int-commons/-/int-commons-2.10.0.tgz", - "integrity": "sha512-CukRix3yxcsbjPTPhIyXN7qZ6f/3W+LQtF96RxuZ7L3P0F7y7t4NswPSll2+zDkAMvvBgFojgPL+bFf2EDIiOA==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/@artilleryio/int-commons/-/int-commons-2.11.0.tgz", + "integrity": "sha512-De713S8MG7qV3Qp1TWPLt+ivA9NHvetzdbNoNNWszLeljCP6Frp+jmXlZG3u7dISFzq/ONH0ROO17n8CEytY/g==", "dev": true, "dependencies": { "async": "^2.6.4", @@ -461,12 +461,12 @@ } }, "node_modules/@artilleryio/int-core": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/@artilleryio/int-core/-/int-core-2.14.0.tgz", - "integrity": "sha512-u0q5p5aWE7DRNRnfmj8JzXqNFitoBKQ4/N/Uur4PXcZCPzB7yQWppRPRJqFUh14zmC/UybDMui1EnbDhBqGGIg==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/@artilleryio/int-core/-/int-core-2.15.0.tgz", + "integrity": "sha512-C2EP+6PrU/PoBDDgr0hyIFlC1OGmvjgs5HMuUEJyyIVfm1eN1BeSRlQ5q3SG/baxz7IySO1WaGZ9FX/KefBofQ==", "dev": true, "dependencies": { - "@artilleryio/int-commons": "2.10.0", + "@artilleryio/int-commons": "2.11.0", "@artilleryio/sketches-js": "^2.1.1", "agentkeepalive": "^4.1.0", "arrivals": "^2.1.2", @@ -807,16 +807,16 @@ } }, "node_modules/@aws-sdk/client-api-gateway": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-api-gateway/-/client-api-gateway-3.632.0.tgz", - "integrity": "sha512-bO9JQHLXWYiAZ32kwzCcxjtslegucEnb9Oi3B5NpknrbqTkAmUFDnD9vFyAnEovorfnZAOOO9Xlr+pyNDP+iNQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-api-gateway/-/client-api-gateway-3.635.0.tgz", + "integrity": "sha512-m9DG4OB0HFm1LMV2b6iz2nCIsOjwEgciy3M02/sNeKLSdUCQZsdUQKXIU7aGIZncZgn5CiV+UN+HvrdOlTYifw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -828,26 +828,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -860,14 +860,14 @@ } }, "node_modules/@aws-sdk/client-api-gateway/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -878,26 +878,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -908,19 +908,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-api-gateway/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -931,26 +931,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -962,16 +962,16 @@ } }, "node_modules/@aws-sdk/client-api-gateway/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -1023,16 +1023,16 @@ } }, "node_modules/@aws-sdk/client-apigatewaymanagementapi": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-apigatewaymanagementapi/-/client-apigatewaymanagementapi-3.632.0.tgz", - "integrity": "sha512-1R/17iZBBlc7QqfBUyNWWYANDJz0K5wNVHYnqmjZKYyo7eGr9/GV4Qo9uFtjcmGdlTi3B2zmti/7rSyVIjxymw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-apigatewaymanagementapi/-/client-apigatewaymanagementapi-3.635.0.tgz", + "integrity": "sha512-WTq1SA2SoRSbMAHrTRTdHokW7U25bVtTe/eeTg/ZJovdbSz6InUc6WosOQ1JTouu3iOLDO4FFElp3pAySvs6+w==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1043,26 +1043,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1074,14 +1074,14 @@ } }, "node_modules/@aws-sdk/client-apigatewaymanagementapi/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1092,26 +1092,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1122,19 +1122,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-apigatewaymanagementapi/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1145,26 +1145,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1176,16 +1176,16 @@ } }, "node_modules/@aws-sdk/client-apigatewaymanagementapi/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -1237,16 +1237,16 @@ } }, "node_modules/@aws-sdk/client-apigatewayv2": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-apigatewayv2/-/client-apigatewayv2-3.632.0.tgz", - "integrity": "sha512-yl/BjrYV2b4gnwbCL+moYVTRLWYja2VCESyWOnW98rNK95wwjb/t/CNWfidi40Lhg37IdIyMmY7g18mkKk/8/w==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-apigatewayv2/-/client-apigatewayv2-3.635.0.tgz", + "integrity": "sha512-1EvlJm76x+GIrn6xdSaHus21rwGBAqlaBRpjLu06Iyqtkhtl2FzzYRYyy/rY/kznF5pmtnRhQVJPY4QU+vUUTw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1257,26 +1257,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1289,14 +1289,14 @@ } }, "node_modules/@aws-sdk/client-apigatewayv2/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1307,26 +1307,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1337,19 +1337,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-apigatewayv2/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1360,26 +1360,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1391,16 +1391,16 @@ } }, "node_modules/@aws-sdk/client-apigatewayv2/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -1452,16 +1452,16 @@ } }, "node_modules/@aws-sdk/client-cloudfront": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudfront/-/client-cloudfront-3.632.0.tgz", - "integrity": "sha512-xCjfX83ySDomnT0Lr5dNo1kwM6SrtNuTWFd7BJb7FeqMeUyjwI/9/zbrXY6eNZAzwSSxNVrJSYHkCioe+Rfwxw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudfront/-/client-cloudfront-3.635.0.tgz", + "integrity": "sha512-JHFSh5g/3nj3/Z6Zwll6v2Sgooj5XS9mncmb14BLhIIKg8XJDXMlxsykgCpH7Kf/zpVn3+oufEuz41iX5xQDzQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1473,26 +1473,26 @@ "@aws-sdk/util-user-agent-node": "3.614.0", "@aws-sdk/xml-builder": "3.609.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1506,14 +1506,14 @@ } }, "node_modules/@aws-sdk/client-cloudfront/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1524,26 +1524,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1554,19 +1554,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-cloudfront/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1577,26 +1577,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1608,16 +1608,16 @@ } }, "node_modules/@aws-sdk/client-cloudfront/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -1669,16 +1669,16 @@ } }, "node_modules/@aws-sdk/client-cloudwatch": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudwatch/-/client-cloudwatch-3.632.0.tgz", - "integrity": "sha512-RIItCf874T8aiE17yikJ6VcARvRv/sn86WMpyJCN0+aUMSOB8X86OHe7KCUN72EkvFKeWXim808RPpS8fZLXKw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudwatch/-/client-cloudwatch-3.635.0.tgz", + "integrity": "sha512-49JkjJncrKNwHlHA/KXbeHiHZ1svD38SYuPMcnOXAizqxRwKldyahooFCAaR6LlFzjSktDcABmCdj+IpV4XNWA==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1689,27 +1689,27 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-compression": "^3.0.7", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1722,16 +1722,16 @@ } }, "node_modules/@aws-sdk/client-cloudwatch-logs": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudwatch-logs/-/client-cloudwatch-logs-3.632.0.tgz", - "integrity": "sha512-QrG04Ss2/KDsvGmoBH9QHjaC/wx7Gf9U2F5o8gYbHVU5ZGDW+zMX2Sj/6jjSyZ4qLD4sxK7sRHwK+fYA21OQQA==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudwatch-logs/-/client-cloudwatch-logs-3.635.0.tgz", + "integrity": "sha512-M2SGf0B/WmHYNxUhUWKIYI5NW4Si7cyokB6Lt3RtDof3WVHA8L0LLl+EEo1URUkpxH8/F8VH2fTES7ODm2c+7g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1742,7 +1742,7 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/eventstream-serde-browser": "^3.0.6", "@smithy/eventstream-serde-config-resolver": "^3.0.3", "@smithy/eventstream-serde-node": "^3.0.5", @@ -1751,20 +1751,20 @@ "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1777,14 +1777,14 @@ } }, "node_modules/@aws-sdk/client-cloudwatch-logs/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1795,26 +1795,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1825,19 +1825,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-cloudwatch-logs/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1848,26 +1848,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -1879,16 +1879,16 @@ } }, "node_modules/@aws-sdk/client-cloudwatch-logs/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -1952,14 +1952,14 @@ } }, "node_modules/@aws-sdk/client-cloudwatch/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -1970,26 +1970,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2000,19 +2000,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-cloudwatch/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2023,26 +2023,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2054,16 +2054,16 @@ } }, "node_modules/@aws-sdk/client-cloudwatch/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -2167,16 +2167,16 @@ } }, "node_modules/@aws-sdk/client-cognito-identity-provider": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity-provider/-/client-cognito-identity-provider-3.632.0.tgz", - "integrity": "sha512-RP9L/LKu3qwXT6z+eq8tjOb4kpT2JiQYi483pVg85jf1PiIB+aoPA0Dbre7f+b7Wpo3FyPIlFqKuHzqhPWZvfQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity-provider/-/client-cognito-identity-provider-3.635.0.tgz", + "integrity": "sha512-PeO+uHkTc73qbaLqLgwEtk32wTAuAjI3KUILRoN40hLpbeKEKjymkL7V8NEP6itePlfjA4Gac1yG29Tzw/dTkg==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2187,26 +2187,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2218,14 +2218,14 @@ } }, "node_modules/@aws-sdk/client-cognito-identity-provider/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2236,26 +2236,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2266,19 +2266,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-cognito-identity-provider/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2289,26 +2289,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2320,16 +2320,16 @@ } }, "node_modules/@aws-sdk/client-cognito-identity-provider/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -2417,16 +2417,16 @@ } }, "node_modules/@aws-sdk/client-dynamodb": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb/-/client-dynamodb-3.632.0.tgz", - "integrity": "sha512-Y7u/B/lyLdLZBrBSXjYZviyck0e3dZLL/Va6HIShNlDG8FyWuArefWr57/bu9Q8smdqpEduldprSRSWI7MPykg==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb/-/client-dynamodb-3.635.0.tgz", + "integrity": "sha512-Nn4aFYkmEKmGqzw+KJHZEDblQZRUx0WcZCIz46iGQO8DXau3dmeRfJEO6HmUpewkvuVP0tQudv1CjgxqnNoKlQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-endpoint-discovery": "3.620.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", @@ -2438,26 +2438,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2471,16 +2471,16 @@ } }, "node_modules/@aws-sdk/client-dynamodb-streams": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb-streams/-/client-dynamodb-streams-3.632.0.tgz", - "integrity": "sha512-vy44vep7i1ZzVC/3cv11Jh3hDOxQnqz3ftXDEAJEC9t+Ltz74Z9drPdxR3DyA8//hZI3SfIMdURAaTUXBb6e1A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb-streams/-/client-dynamodb-streams-3.635.0.tgz", + "integrity": "sha512-Fg1uJ3m1+lhrxOclLIg1nfSngVzngOKHMFkSuz9iSGtVJVRAQu7rmTiD+GcTNCWOqnleBlMdd2K298I6irtH1w==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2491,26 +2491,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2522,14 +2522,14 @@ } }, "node_modules/@aws-sdk/client-dynamodb-streams/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2540,26 +2540,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2570,19 +2570,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-dynamodb-streams/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2593,26 +2593,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2624,16 +2624,16 @@ } }, "node_modules/@aws-sdk/client-dynamodb-streams/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -2685,14 +2685,14 @@ } }, "node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2703,26 +2703,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2733,19 +2733,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2756,26 +2756,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2787,16 +2787,16 @@ } }, "node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -2860,16 +2860,16 @@ } }, "node_modules/@aws-sdk/client-glue": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-glue/-/client-glue-3.632.0.tgz", - "integrity": "sha512-2UyPVHGNT/LKDmFUYxghW95fP6rCrMMhk4FgUUGnTFBOqsfAhfR9VPw8iACvH0I5RdP0qqumh1ZBEXwcokpngA==", + "version": "3.636.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-glue/-/client-glue-3.636.0.tgz", + "integrity": "sha512-xFm/rXjlBDB/IoeeZy/pMXLTwsDWSt8ILQeHNzdBAhmyGEP2xkxT6f54IkxQgosrNpoosfBNANhRNjjlq0xWqQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2880,26 +2880,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2911,14 +2911,14 @@ } }, "node_modules/@aws-sdk/client-glue/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2929,26 +2929,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -2959,19 +2959,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-glue/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -2982,26 +2982,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3013,16 +3013,16 @@ } }, "node_modules/@aws-sdk/client-glue/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -3074,17 +3074,17 @@ } }, "node_modules/@aws-sdk/client-iam": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-iam/-/client-iam-3.632.0.tgz", - "integrity": "sha512-iwivASUliVxCEbT/mu5s03SCyqQKNXbJUpG17ywT4taA2xvLisGRI5iNV3OYT1qDmK9DOLMSJYpeX2GWCijPxw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-iam/-/client-iam-3.635.0.tgz", + "integrity": "sha512-sflTv6XcwO5UX+U9x31+T6TBEgVIzG61giLgRV51kkFGErni++GpxUcc6O1mpDwb3jpbntJf7QPjrkkj9wsTPA==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3095,26 +3095,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3127,15 +3127,15 @@ } }, "node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3146,26 +3146,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3176,20 +3176,20 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3200,26 +3200,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3231,17 +3231,17 @@ } }, "node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dev": true, "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -3296,16 +3296,16 @@ } }, "node_modules/@aws-sdk/client-lambda": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-lambda/-/client-lambda-3.632.0.tgz", - "integrity": "sha512-vF4KRuHGr6EfW+dssm56S6b+jAa8dKqdWduHNms1TQFah0iOkjc9Dpo4p4j6bobZcuricGko/OZy9ynb1Dwldg==", + "version": "3.636.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-lambda/-/client-lambda-3.636.0.tgz", + "integrity": "sha512-rJitBBQAEVdyf4E6PhwFwD7uIM222dfx2oEIuFKkUb5rMKaFocnJbzvS3yGv/dZwDcUtMV5+5ibMCfgE8gAiJg==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3316,7 +3316,7 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/eventstream-serde-browser": "^3.0.6", "@smithy/eventstream-serde-config-resolver": "^3.0.3", "@smithy/eventstream-serde-node": "^3.0.5", @@ -3325,20 +3325,20 @@ "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3352,14 +3352,14 @@ } }, "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3370,26 +3370,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3400,19 +3400,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3423,26 +3423,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3454,16 +3454,16 @@ } }, "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -3515,16 +3515,16 @@ } }, "node_modules/@aws-sdk/client-opensearch": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-opensearch/-/client-opensearch-3.632.0.tgz", - "integrity": "sha512-ZeWedGeWBj6rh+tEX0olvyLUH6iMpNt5cO5pw49Mjpnt4dE3W4JgieCd5ZyfFtJoHroYvG41ZA4p+b2aUjxgwQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-opensearch/-/client-opensearch-3.635.0.tgz", + "integrity": "sha512-hFZlPxUHiaVQJq3QBd8EBwFmP+3iRen22q3YVs44ee6Fi3H7fpwtiq5HLCNO2BF61999OA9PAYF5RrjWorNoYA==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3535,26 +3535,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3566,14 +3566,14 @@ } }, "node_modules/@aws-sdk/client-opensearch/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3584,26 +3584,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3614,19 +3614,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-opensearch/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3637,26 +3637,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3668,16 +3668,16 @@ } }, "node_modules/@aws-sdk/client-opensearch/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -3729,16 +3729,16 @@ } }, "node_modules/@aws-sdk/client-route-53": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-route-53/-/client-route-53-3.632.0.tgz", - "integrity": "sha512-BEMRHWxmXBzWlnCuW1rTaqYHUSGPDMpQbZdsC7dCuVcYdIBwKfJrPe1HtvT0+6W/KkDQqxoEgKrl47+Jzl06qw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-route-53/-/client-route-53-3.635.0.tgz", + "integrity": "sha512-SU932rYfL6aVVTCxAR6p7H+l7eh8qyZFp1bprgm4Yciv0bz9B/k1c6Ra48Z0Pt2mCRdnZT1m9Zn+UvgRYrBFhQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3751,26 +3751,26 @@ "@aws-sdk/util-user-agent-node": "3.614.0", "@aws-sdk/xml-builder": "3.609.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3783,14 +3783,14 @@ } }, "node_modules/@aws-sdk/client-route-53/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3801,26 +3801,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3831,19 +3831,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-route-53/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -3854,26 +3854,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -3885,16 +3885,16 @@ } }, "node_modules/@aws-sdk/client-route-53/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -3946,17 +3946,17 @@ } }, "node_modules/@aws-sdk/client-s3": { - "version": "3.633.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.633.0.tgz", - "integrity": "sha512-KPwNGlZlCRUADNTvwPJmvDvlh8N/jxjcv5e71M/mWxLXwSPdlHlRjVSBL1/CPSXUr86XRAsPL+BCRkdiytUhbg==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.635.0.tgz", + "integrity": "sha512-4RP+DJZWqUka1MW2aSEzTzntY3GrDzS26D8dHZvbt2I0x+dSmlnmXiJkCxLjmti2SDVYAGL9gX6e7mLS7W55jA==", "dependencies": { "@aws-crypto/sha1-browser": "5.2.0", "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-bucket-endpoint": "3.620.0", "@aws-sdk/middleware-expect-continue": "3.620.0", "@aws-sdk/middleware-flexible-checksums": "3.620.0", @@ -3964,18 +3964,18 @@ "@aws-sdk/middleware-location-constraint": "3.609.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-sdk-s3": "3.633.0", + "@aws-sdk/middleware-sdk-s3": "3.635.0", "@aws-sdk/middleware-ssec": "3.609.0", "@aws-sdk/middleware-user-agent": "3.632.0", "@aws-sdk/region-config-resolver": "3.614.0", - "@aws-sdk/signature-v4-multi-region": "3.633.0", + "@aws-sdk/signature-v4-multi-region": "3.635.0", "@aws-sdk/types": "3.609.0", "@aws-sdk/util-endpoints": "3.632.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@aws-sdk/xml-builder": "3.609.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/eventstream-serde-browser": "^3.0.6", "@smithy/eventstream-serde-config-resolver": "^3.0.3", "@smithy/eventstream-serde-node": "^3.0.5", @@ -3987,20 +3987,20 @@ "@smithy/md5-js": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4014,14 +4014,14 @@ } }, "node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4032,26 +4032,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4062,19 +4062,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4085,26 +4085,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4116,16 +4116,16 @@ } }, "node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -4177,17 +4177,17 @@ } }, "node_modules/@aws-sdk/client-secrets-manager": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-secrets-manager/-/client-secrets-manager-3.632.0.tgz", - "integrity": "sha512-WsQhPHHK1yPfALcP1B7nBSGDzky6vFTUEXnUdfzb5Xy2cT+JTBTS6ChtQGqqOuGHDP/3t/9soqZ+L6rUCYBb/Q==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-secrets-manager/-/client-secrets-manager-3.635.0.tgz", + "integrity": "sha512-taa+sa8xFym7ZYzybqkOVy5MAdedcIt2pKEVOReEaNkUuOwMUo+wF4QhJeyhaLPTs2l0rHR1bnwYOG+0fW0Kvg==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4198,26 +4198,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4230,15 +4230,15 @@ } }, "node_modules/@aws-sdk/client-secrets-manager/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4249,26 +4249,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4279,20 +4279,20 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-secrets-manager/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4303,26 +4303,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4334,17 +4334,17 @@ } }, "node_modules/@aws-sdk/client-secrets-manager/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dev": true, "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -4412,16 +4412,16 @@ } }, "node_modules/@aws-sdk/client-ses": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-ses/-/client-ses-3.632.0.tgz", - "integrity": "sha512-hi01MPJF55LEK7NB1LZrqUV7b5GyjH08EToYuekFvQf9aNoR5mqWuMEDQ/dFAowYhUa2KqCdn67HnPn0ySQxHg==", + "version": "3.636.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-ses/-/client-ses-3.636.0.tgz", + "integrity": "sha512-72LwrowWBR4W6ilkc1AIBJZV7UbA9YvmqfHyh+D+Ek7VK65cW9mskLE9rFX/uI4CzupCSxVvEy2d23M/6w+Saw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4432,26 +4432,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4464,14 +4464,14 @@ } }, "node_modules/@aws-sdk/client-ses/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4482,26 +4482,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4512,19 +4512,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-ses/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4535,26 +4535,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4566,16 +4566,16 @@ } }, "node_modules/@aws-sdk/client-ses/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -4627,16 +4627,16 @@ } }, "node_modules/@aws-sdk/client-sns": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sns/-/client-sns-3.632.0.tgz", - "integrity": "sha512-I8S0tFx26LL59/PiL4Reqna+LW7oIbRB+jygl4vrf4XIvpX5o4tmZmOmR0caYA+Cks3AomCi4cp+7WuwUpuATQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sns/-/client-sns-3.635.0.tgz", + "integrity": "sha512-jlx6o7sDIX1R07z8+hjqlxaBmaXPDQ2xgU8KD0HtGAAHj+P7oDQypSxorelh3tc+UQdFN4tJ0xBxFRGYejL6lg==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4647,26 +4647,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4678,14 +4678,14 @@ } }, "node_modules/@aws-sdk/client-sns/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4696,26 +4696,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4726,19 +4726,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-sns/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4749,26 +4749,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4780,16 +4780,16 @@ } }, "node_modules/@aws-sdk/client-sns/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -4841,20 +4841,20 @@ } }, "node_modules/@aws-sdk/client-sqs": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sqs/-/client-sqs-3.632.0.tgz", - "integrity": "sha512-UK4JQ6nF6qDtc2rLdrYTgyZWTdUgfVHbVHQdHkrni2TNac3kEksgiDFxsm6zQjy1NoOg4YdPDeMOeHRvWImlPQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sqs/-/client-sqs-3.635.0.tgz", + "integrity": "sha512-0b53yd0oTfR9dCCbBTuoKwslQdAnonkprzKyrrj3vffcnrr+U7fq11OU6WHX0Vu3WxNx1GGMvUnF6SJEsPdBDA==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-sdk-sqs": "3.622.0", + "@aws-sdk/middleware-sdk-sqs": "3.635.0", "@aws-sdk/middleware-user-agent": "3.632.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", @@ -4862,27 +4862,27 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/md5-js": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4894,14 +4894,14 @@ } }, "node_modules/@aws-sdk/client-sqs/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4912,26 +4912,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4942,19 +4942,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-sqs/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -4965,26 +4965,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -4996,16 +4996,16 @@ } }, "node_modules/@aws-sdk/client-sqs/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -5057,16 +5057,16 @@ } }, "node_modules/@aws-sdk/client-ssm": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-ssm/-/client-ssm-3.632.0.tgz", - "integrity": "sha512-p9QZguhC6NB6CQTFgLcYhU1yhGF7SN9kDMtFwtFBxTPO/SQJ/PJcEyL40yXPbuPUXFtT/YRhT9mIwQagfkXzAA==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-ssm/-/client-ssm-3.635.0.tgz", + "integrity": "sha512-8aMG5TN+QgziahHuzZB3MoREVfV4IRIG3+kR55vZCRGUtnwgOdTwrtjKV+VOE2ulAk8WiNHsJyjz1iUXr7bG3g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/client-sts": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -5077,26 +5077,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -5110,14 +5110,14 @@ } }, "node_modules/@aws-sdk/client-ssm/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -5128,26 +5128,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -5158,19 +5158,19 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/client-ssm/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -5181,26 +5181,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -5212,16 +5212,16 @@ } }, "node_modules/@aws-sdk/client-ssm/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -5619,15 +5619,15 @@ } }, "node_modules/@aws-sdk/credential-provider-node": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.632.0.tgz", - "integrity": "sha512-cL8fuJWm/xQBO4XJPkeuZzl3XinIn9EExWgzpG48NRMKR5us1RI/ucv7xFbBBaG+r/sDR2HpYBIA3lVIpm1H3Q==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.635.0.tgz", + "integrity": "sha512-bmd23mnb94S6AxmWPgqJTnvT9ONKlTx7EPafE1RNO+vUl6mHih4iyqX6ZPaRcSfaPx4U1R7H1RM8cSnafXgaBg==", "dependencies": { "@aws-sdk/credential-provider-env": "3.620.1", - "@aws-sdk/credential-provider-http": "3.622.0", - "@aws-sdk/credential-provider-ini": "3.632.0", + "@aws-sdk/credential-provider-http": "3.635.0", + "@aws-sdk/credential-provider-ini": "3.635.0", "@aws-sdk/credential-provider-process": "3.620.1", - "@aws-sdk/credential-provider-sso": "3.632.0", + "@aws-sdk/credential-provider-sso": "3.635.0", "@aws-sdk/credential-provider-web-identity": "3.621.0", "@aws-sdk/types": "3.609.0", "@smithy/credential-provider-imds": "^3.2.0", @@ -5641,13 +5641,13 @@ } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/client-sso": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.632.0.tgz", - "integrity": "sha512-iYWHiKBz44m3chCFvtvHnvCpL2rALzyr1e6tOZV3dLlOKtQtDUlPy6OtnXDu4y+wyJCniy8ivG3+LAe4klzn1Q==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.635.0.tgz", + "integrity": "sha512-/Hl69+JpFUo9JNVmh2gSvMgYkE4xjd+1okiRoPBbQqjI7YBP2JWCUDP8IoEkNq3wj0vNTq0OWfn6RpZycIkAXQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", + "@aws-sdk/core": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -5658,26 +5658,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -5689,15 +5689,15 @@ } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.632.0.tgz", - "integrity": "sha512-Oh1fIWaoZluihOCb/zDEpRTi+6an82fgJz7fyRBugyLhEtDjmvpCQ3oKjzaOhoN+4EvXAm1ZS/ZgpvXBlIRTgw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", + "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", "peer": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -5708,26 +5708,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -5738,20 +5738,20 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/client-sts": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.632.0.tgz", - "integrity": "sha512-Ss5cBH09icpTvT+jtGGuQlRdwtO7RyE9BF4ZV/CEPATdd9whtJt4Qxdya8BUnkWR7h5HHTrQHqai3YVYjku41A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", + "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", "peer": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.632.0", - "@aws-sdk/core": "3.629.0", - "@aws-sdk/credential-provider-node": "3.632.0", + "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/core": "3.635.0", + "@aws-sdk/credential-provider-node": "3.635.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", @@ -5762,26 +5762,26 @@ "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/fetch-http-handler": "^3.2.4", "@smithy/hash-node": "^3.0.3", "@smithy/invalid-dependency": "^3.0.3", "@smithy/middleware-content-length": "^3.0.5", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/middleware-stack": "^3.0.3", "@smithy/node-config-provider": "^3.1.4", "@smithy/node-http-handler": "^3.1.4", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/url-parser": "^3.0.3", "@smithy/util-base64": "^3.0.0", "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-defaults-mode-browser": "^3.0.15", + "@smithy/util-defaults-mode-node": "^3.0.15", "@smithy/util-endpoints": "^2.0.5", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -5793,16 +5793,16 @@ } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -5812,15 +5812,34 @@ "node": ">=16.0.0" } }, + "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-http": { + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.635.0.tgz", + "integrity": "sha512-iJyRgEjOCQlBMXqtwPLIKYc7Bsc6nqjrZybdMDenPDa+kmLg7xh8LxHsu9088e+2/wtLicE34FsJJIfzu3L82g==", + "dependencies": { + "@aws-sdk/types": "3.609.0", + "@smithy/fetch-http-handler": "^3.2.4", + "@smithy/node-http-handler": "^3.1.4", + "@smithy/property-provider": "^3.1.3", + "@smithy/protocol-http": "^4.1.0", + "@smithy/smithy-client": "^3.2.0", + "@smithy/types": "^3.3.0", + "@smithy/util-stream": "^3.1.3", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-ini": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.632.0.tgz", - "integrity": "sha512-m6epoW41xa1ajU5OiHcmQHoGVtrbXBaRBOUhlCLZmcaqMLYsboM4iD/WZP8aatKEON5tTnVXh/4StV8D/+wemw==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.635.0.tgz", + "integrity": "sha512-+OqcNhhOFFY08YHLjO9/Y1n37RKAO7LADnsJ7VTXca7IfvYh27BVBn+FdlqnyEb1MQ5ArHTY4pq3pKRIg6RW4Q==", "dependencies": { "@aws-sdk/credential-provider-env": "3.620.1", - "@aws-sdk/credential-provider-http": "3.622.0", + "@aws-sdk/credential-provider-http": "3.635.0", "@aws-sdk/credential-provider-process": "3.620.1", - "@aws-sdk/credential-provider-sso": "3.632.0", + "@aws-sdk/credential-provider-sso": "3.635.0", "@aws-sdk/credential-provider-web-identity": "3.621.0", "@aws-sdk/types": "3.609.0", "@smithy/credential-provider-imds": "^3.2.0", @@ -5833,15 +5852,15 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.632.0" + "@aws-sdk/client-sts": "^3.635.0" } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-sso": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.632.0.tgz", - "integrity": "sha512-P/4wB6j7ym5QCPTL2xlMfvf2NcXSh+z0jmsZP4WW/tVwab4hvgabPPbLeEZDSWZ0BpgtxKGvRq0GSHuGeirQbA==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.635.0.tgz", + "integrity": "sha512-hO/fKyvUaGpK9zyvCnmJz70EputvGWDr2UTOn/RzvcR6UB4yXoFf0QcCMubEsE3v67EsAv6PadgOeJ0vz6IazA==", "dependencies": { - "@aws-sdk/client-sso": "3.632.0", + "@aws-sdk/client-sso": "3.635.0", "@aws-sdk/token-providers": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/property-provider": "^3.1.3", @@ -6006,13 +6025,13 @@ } }, "node_modules/@aws-sdk/lib-dynamodb": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/lib-dynamodb/-/lib-dynamodb-3.632.0.tgz", - "integrity": "sha512-8QBjfCEKPOpU2stxCJ/DGDL7Gb1tzgwPwC1XLMzLW3rR94EcrlmJatEBXIHbGQypVvHVdwu3xILDrp4qn6P+Sg==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/lib-dynamodb/-/lib-dynamodb-3.635.0.tgz", + "integrity": "sha512-EEuurFULGzHYA1gk1uNXclkw38TFgFhzO1hKu6FchjeLv7mw1Z9Pj5hkGjmNOqesQDjSfYbEXs3JI2jYWwp7Iw==", "dependencies": { - "@aws-sdk/util-dynamodb": "3.632.0", - "@smithy/core": "^2.3.2", - "@smithy/smithy-client": "^3.1.12", + "@aws-sdk/util-dynamodb": "3.635.0", + "@smithy/core": "^2.4.0", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" }, @@ -6020,17 +6039,17 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-dynamodb": "^3.632.0" + "@aws-sdk/client-dynamodb": "^3.635.0" } }, "node_modules/@aws-sdk/lib-storage": { - "version": "3.633.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/lib-storage/-/lib-storage-3.633.0.tgz", - "integrity": "sha512-bc+o95CWgyY9BwY6BmmvM+SfmOTNzkvszE8jSNtw4RO8rhhy+cDkwMOpyHe2mBWMUEq2LMXW3TvIrPZT1bvTyA==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/lib-storage/-/lib-storage-3.635.0.tgz", + "integrity": "sha512-1aLTfCuQijyGefbdn8RHV3uTNKcDMPFMKZBX6C9mSHBpR2lTNNGEyu2/KFKO3wcLXt5fZRQovexlixMx5Tnkyg==", "dependencies": { "@smithy/abort-controller": "^3.1.1", "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "buffer": "5.6.0", "events": "3.3.0", "stream-browserify": "3.0.0", @@ -6040,7 +6059,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-s3": "^3.633.0" + "@aws-sdk/client-s3": "^3.635.0" } }, "node_modules/@aws-sdk/middleware-bucket-endpoint": { @@ -6202,18 +6221,18 @@ } }, "node_modules/@aws-sdk/middleware-sdk-s3": { - "version": "3.633.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-s3/-/middleware-sdk-s3-3.633.0.tgz", - "integrity": "sha512-7jjmWVw28wIHOdrHyTCvwKr1EYGrZI13DviwAOwRC0y9dB8gGCdRiA4fNczripUBxolCCE9mpqLrqy5pXtTzvA==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-s3/-/middleware-sdk-s3-3.635.0.tgz", + "integrity": "sha512-RLdYJPEV4JL/7NBoFUs7VlP90X++5FlJdxHz0DzCjmiD3qCviKy+Cym3qg1gBgHwucs5XisuClxDrGokhAdTQw==", "dependencies": { - "@aws-sdk/core": "3.629.0", + "@aws-sdk/core": "3.635.0", "@aws-sdk/types": "3.609.0", "@aws-sdk/util-arn-parser": "3.568.0", - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-config-provider": "^3.0.0", "@smithy/util-middleware": "^3.0.3", @@ -6226,16 +6245,16 @@ } }, "node_modules/@aws-sdk/middleware-sdk-s3/node_modules/@aws-sdk/core": { - "version": "3.629.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.629.0.tgz", - "integrity": "sha512-+/ShPU/tyIBM3oY1cnjgNA/tFyHtlWq+wXF9xEKRv19NOpYbWQ+xzNwVjGq8vR07cCRqy/sDQLWPhxjtuV/FiQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.635.0.tgz", + "integrity": "sha512-i1x/E/sgA+liUE1XJ7rj1dhyXpAKO1UKFUcTTHXok2ARjWTvszHnSXMOsB77aPbmn0fUp1JTx2kHUAZ1LVt5Bg==", "dependencies": { - "@smithy/core": "^2.3.2", + "@smithy/core": "^2.4.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "fast-xml-parser": "4.4.1", @@ -6258,12 +6277,12 @@ } }, "node_modules/@aws-sdk/middleware-sdk-sqs": { - "version": "3.622.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-sqs/-/middleware-sdk-sqs-3.622.0.tgz", - "integrity": "sha512-kOPX94jlVcvH7Wutzag99L+BSjT6LjXxW7Ntc02/oywYX6Gft4YdbeUYdcGYYHWDy/IT6jJ2wMJfFUEEh8U/9A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-sqs/-/middleware-sdk-sqs-3.635.0.tgz", + "integrity": "sha512-EsrTqso8dBeugdKYyKmF2faqplYoPvW7YNE5wttgFCeSn4HvG8lh+oGt9/ofawTy0GLkQG2Z5eKhUAgYSrP2Ww==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-hex-encoding": "^3.0.0", "@smithy/util-utf8": "^3.0.0", @@ -6453,11 +6472,11 @@ } }, "node_modules/@aws-sdk/s3-presigned-post": { - "version": "3.633.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/s3-presigned-post/-/s3-presigned-post-3.633.0.tgz", - "integrity": "sha512-EmfgQKWDbNUWJOjciE3asMKHChjFOKIIEs4aRW6nYol6rvDwp4hyRu+sTUZOu2jdSKqR/1dhan4k+WCiqw/YTQ==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/s3-presigned-post/-/s3-presigned-post-3.635.0.tgz", + "integrity": "sha512-1kYYpnAvNVe/Mrlk06bNie+pWMFu9rZF0zQSfdjWXQPTfYnCJdl79nXoKU1Mlwc5s7YneRwoBJ39KQKrump0/Q==", "dependencies": { - "@aws-sdk/client-s3": "3.633.0", + "@aws-sdk/client-s3": "3.635.0", "@aws-sdk/types": "3.609.0", "@aws-sdk/util-format-url": "3.609.0", "@smithy/middleware-endpoint": "^3.1.0", @@ -6484,16 +6503,16 @@ } }, "node_modules/@aws-sdk/s3-request-presigner": { - "version": "3.633.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/s3-request-presigner/-/s3-request-presigner-3.633.0.tgz", - "integrity": "sha512-WUcBSdBenzA65y8MCDPcOaKWYhU0+AuocI1hm46TaPcPhE4E2oVoYbk1MeufkaSavR741iM4fm+b16ESUF963A==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/s3-request-presigner/-/s3-request-presigner-3.635.0.tgz", + "integrity": "sha512-hiAmZvPjNjQA/RXPc0LVc93ytit7PyDswMAPooCS85564lSNCJw+ygP8nnUPGpkjnHkZ9UgjNDc/UQxzwj0eLA==", "dependencies": { - "@aws-sdk/signature-v4-multi-region": "3.633.0", + "@aws-sdk/signature-v4-multi-region": "3.635.0", "@aws-sdk/types": "3.609.0", "@aws-sdk/util-format-url": "3.609.0", "@smithy/middleware-endpoint": "^3.1.0", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" }, @@ -6515,11 +6534,11 @@ } }, "node_modules/@aws-sdk/signature-v4-multi-region": { - "version": "3.633.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.633.0.tgz", - "integrity": "sha512-96F7Mx4lybMZdE0TTEkw6EKpeB0hxqp3J8fUJasesekTnO7jsklc47GHL5R3whyS/L4/JaPazm0Pi2DEH3kw1w==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.635.0.tgz", + "integrity": "sha512-J6QY4/invOkpogCHjSaDON1hF03viPpOnsrzVuCvJMmclS/iG62R4EY0wq1alYll0YmSdmKlpJwHMWwGtqK63Q==", "dependencies": { - "@aws-sdk/middleware-sdk-s3": "3.633.0", + "@aws-sdk/middleware-sdk-s3": "3.635.0", "@aws-sdk/types": "3.609.0", "@smithy/protocol-http": "^4.1.0", "@smithy/signature-v4": "^4.1.0", @@ -6710,9 +6729,9 @@ } }, "node_modules/@aws-sdk/util-dynamodb": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-dynamodb/-/util-dynamodb-3.632.0.tgz", - "integrity": "sha512-uvfHEk7y9JKLTOXPOQi+GhQLs0Eo09xNNMGk8ptZUeXS4u/Qs6lHKJK6i1khoeeQ6+ASSxmYmTbDhpPqUKGPEg==", + "version": "3.635.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-dynamodb/-/util-dynamodb-3.635.0.tgz", + "integrity": "sha512-j0xMQRgRrdZmdlrFjan5z7eJUcK0TboW2BTMB2TYo/tZw5DT8f7PIs/e3TTndPRGfzTUwggopd9+lAm5Wk4hQA==", "dependencies": { "tslib": "^2.6.2" }, @@ -6720,7 +6739,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-dynamodb": "^3.632.0" + "@aws-sdk/client-dynamodb": "^3.635.0" } }, "node_modules/@aws-sdk/util-endpoints": { @@ -7262,9 +7281,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.2.tgz", - "integrity": "sha512-bYcppcpKBvX4znYaPEeFau03bp89ShqNMLs+rmdptMw+heSZh9+z84d2YG+K7cYLbWwzdjtDoW/uqZmPjulClQ==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.4.tgz", + "integrity": "sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==", "dev": true, "engines": { "node": ">=6.9.0" @@ -7319,11 +7338,11 @@ } }, "node_modules/@babel/generator": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.0.tgz", - "integrity": "sha512-3LEEcj3PVW8pW2R1SR1M89g/qrYk/m/mB/tLqn7dn4sbBUQyTqnlod+II2U4dqiGtUmkcnAmkMDralTFZttRiw==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.4.tgz", + "integrity": "sha512-NFtZmZsyzDPJnk9Zg3BbTfKKc9UlHYzD0E//p2Z3B9nCwwtJW9T0gVbCz8+fBngnn4zf1Dr3IK8PHQQHq0lDQw==", "dependencies": { - "@babel/types": "^7.25.0", + "@babel/types": "^7.25.4", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -7374,9 +7393,9 @@ } }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.25.0.tgz", - "integrity": "sha512-GYM6BxeQsETc9mnct+nIIpf63SAyzvyYN7UB/IlTyd+MBg06afFGp0mIeUqGyWgS2mxad6vqbMrHVlaL3m70sQ==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.25.4.tgz", + "integrity": "sha512-ro/bFs3/84MDgDmMwbcHgDa8/E6J3QKNTk4xJJnVeFtGE+tL0K26E3pNxhYz2b67fJpt7Aphw5XcploKXuCvCQ==", "dev": true, "dependencies": { "@babel/helper-annotate-as-pure": "^7.24.7", @@ -7384,7 +7403,7 @@ "@babel/helper-optimise-call-expression": "^7.24.7", "@babel/helper-replace-supers": "^7.25.0", "@babel/helper-skip-transparent-expression-wrappers": "^7.24.7", - "@babel/traverse": "^7.25.0", + "@babel/traverse": "^7.25.4", "semver": "^6.3.1" }, "engines": { @@ -7618,11 +7637,11 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.3.tgz", - "integrity": "sha512-iLTJKDbJ4hMvFPgQwwsVoxtHyWpKKPBrxkANrSYewDPaPpT5py5yeVkgPIJ7XYXhndxJpaA3PyALSXQ7u8e/Dw==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.4.tgz", + "integrity": "sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==", "dependencies": { - "@babel/types": "^7.25.2" + "@babel/types": "^7.25.4" }, "bin": { "parser": "bin/babel-parser.js" @@ -8015,15 +8034,15 @@ } }, "node_modules/@babel/plugin-transform-async-generator-functions": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.25.0.tgz", - "integrity": "sha512-uaIi2FdqzjpAMvVqvB51S42oC2JEVgh0LDsGfZVDysWE8LrJtQC2jvKmOqEYThKyB7bDEb7BP1GYWDm7tABA0Q==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.25.4.tgz", + "integrity": "sha512-jz8cV2XDDTqjKPwVPJBIjORVEmSGYhdRa8e5k5+vN+uwcjSrSxUaebBRa4ko1jqNF2uxyg8G6XYk30Jv285xzg==", "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.24.8", "@babel/helper-remap-async-to-generator": "^7.25.0", "@babel/plugin-syntax-async-generators": "^7.8.4", - "@babel/traverse": "^7.25.0" + "@babel/traverse": "^7.25.4" }, "engines": { "node": ">=6.9.0" @@ -8080,13 +8099,13 @@ } }, "node_modules/@babel/plugin-transform-class-properties": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.24.7.tgz", - "integrity": "sha512-vKbfawVYayKcSeSR5YYzzyXvsDFWU2mD8U5TFeXtbCPLFUqe7GyCgvO6XDHzje862ODrOwy6WCPmKeWHbCFJ4w==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.25.4.tgz", + "integrity": "sha512-nZeZHyCWPfjkdU5pA/uHiTaDAFUEqkpzf1YoQT2NeSynCGYq9rxfyI3XpQbfx/a0hSnFH6TGlEXvae5Vi7GD8g==", "dev": true, "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" + "@babel/helper-create-class-features-plugin": "^7.25.4", + "@babel/helper-plugin-utils": "^7.24.8" }, "engines": { "node": ">=6.9.0" @@ -8113,16 +8132,16 @@ } }, "node_modules/@babel/plugin-transform-classes": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.25.0.tgz", - "integrity": "sha512-xyi6qjr/fYU304fiRwFbekzkqVJZ6A7hOjWZd+89FVcBqPV3S9Wuozz82xdpLspckeaafntbzglaW4pqpzvtSw==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.25.4.tgz", + "integrity": "sha512-oexUfaQle2pF/b6E0dwsxQtAol9TLSO88kQvym6HHBWFliV2lGdrPieX+WgMRLSJDVzdYywk7jXbLPuO2KLTLg==", "dev": true, "dependencies": { "@babel/helper-annotate-as-pure": "^7.24.7", - "@babel/helper-compilation-targets": "^7.24.8", + "@babel/helper-compilation-targets": "^7.25.2", "@babel/helper-plugin-utils": "^7.24.8", "@babel/helper-replace-supers": "^7.25.0", - "@babel/traverse": "^7.25.0", + "@babel/traverse": "^7.25.4", "globals": "^11.1.0" }, "engines": { @@ -8566,13 +8585,13 @@ } }, "node_modules/@babel/plugin-transform-private-methods": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.24.7.tgz", - "integrity": "sha512-COTCOkG2hn4JKGEKBADkA8WNb35TGkkRbI5iT845dB+NyqgO8Hn+ajPbSnIQznneJTa3d30scb6iz/DhH8GsJQ==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.25.4.tgz", + "integrity": "sha512-ao8BG7E2b/URaUQGqN3Tlsg+M3KlHY6rJ1O1gXAEUnZoyNQnvKyH87Kfg+FoxSeyWUB8ISZZsC91C44ZuBFytw==", "dev": true, "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" + "@babel/helper-create-class-features-plugin": "^7.25.4", + "@babel/helper-plugin-utils": "^7.24.8" }, "engines": { "node": ">=6.9.0" @@ -8853,13 +8872,13 @@ } }, "node_modules/@babel/plugin-transform-unicode-sets-regex": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.24.7.tgz", - "integrity": "sha512-2G8aAvF4wy1w/AGZkemprdGMRg5o6zPNhbHVImRz3lss55TYCBd6xStN19rt8XJHq20sqV0JbyWjOWwQRwV/wg==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.25.4.tgz", + "integrity": "sha512-qesBxiWkgN1Q+31xUE9RcMk79eOXXDCv6tfyGMRSs4RGlioSg2WVyQAm07k726cSE56pa+Kb0y9epX2qaXzTvA==", "dev": true, "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" + "@babel/helper-create-regexp-features-plugin": "^7.25.2", + "@babel/helper-plugin-utils": "^7.24.8" }, "engines": { "node": ">=6.9.0" @@ -8869,12 +8888,12 @@ } }, "node_modules/@babel/preset-env": { - "version": "7.25.3", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.25.3.tgz", - "integrity": "sha512-QsYW7UeAaXvLPX9tdVliMJE7MD7M6MLYVTovRTIwhoYQVFHR1rM4wO8wqAezYi3/BpSD+NzVCZ69R6smWiIi8g==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.25.4.tgz", + "integrity": "sha512-W9Gyo+KmcxjGahtt3t9fb14vFRWvPpu5pT6GBlovAK6BTBcxgjfVMSQCfJl4oi35ODrxP6xx2Wr8LNST57Mraw==", "dev": true, "dependencies": { - "@babel/compat-data": "^7.25.2", + "@babel/compat-data": "^7.25.4", "@babel/helper-compilation-targets": "^7.25.2", "@babel/helper-plugin-utils": "^7.24.8", "@babel/helper-validator-option": "^7.24.8", @@ -8903,13 +8922,13 @@ "@babel/plugin-syntax-top-level-await": "^7.14.5", "@babel/plugin-syntax-unicode-sets-regex": "^7.18.6", "@babel/plugin-transform-arrow-functions": "^7.24.7", - "@babel/plugin-transform-async-generator-functions": "^7.25.0", + "@babel/plugin-transform-async-generator-functions": "^7.25.4", "@babel/plugin-transform-async-to-generator": "^7.24.7", "@babel/plugin-transform-block-scoped-functions": "^7.24.7", "@babel/plugin-transform-block-scoping": "^7.25.0", - "@babel/plugin-transform-class-properties": "^7.24.7", + "@babel/plugin-transform-class-properties": "^7.25.4", "@babel/plugin-transform-class-static-block": "^7.24.7", - "@babel/plugin-transform-classes": "^7.25.0", + "@babel/plugin-transform-classes": "^7.25.4", "@babel/plugin-transform-computed-properties": "^7.24.7", "@babel/plugin-transform-destructuring": "^7.24.8", "@babel/plugin-transform-dotall-regex": "^7.24.7", @@ -8937,7 +8956,7 @@ "@babel/plugin-transform-optional-catch-binding": "^7.24.7", "@babel/plugin-transform-optional-chaining": "^7.24.8", "@babel/plugin-transform-parameters": "^7.24.7", - "@babel/plugin-transform-private-methods": "^7.24.7", + "@babel/plugin-transform-private-methods": "^7.25.4", "@babel/plugin-transform-private-property-in-object": "^7.24.7", "@babel/plugin-transform-property-literals": "^7.24.7", "@babel/plugin-transform-regenerator": "^7.24.7", @@ -8950,10 +8969,10 @@ "@babel/plugin-transform-unicode-escapes": "^7.24.7", "@babel/plugin-transform-unicode-property-regex": "^7.24.7", "@babel/plugin-transform-unicode-regex": "^7.24.7", - "@babel/plugin-transform-unicode-sets-regex": "^7.24.7", + "@babel/plugin-transform-unicode-sets-regex": "^7.25.4", "@babel/preset-modules": "0.1.6-no-external-plugins", "babel-plugin-polyfill-corejs2": "^0.4.10", - "babel-plugin-polyfill-corejs3": "^0.10.4", + "babel-plugin-polyfill-corejs3": "^0.10.6", "babel-plugin-polyfill-regenerator": "^0.6.1", "core-js-compat": "^3.37.1", "semver": "^6.3.1" @@ -9068,15 +9087,15 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.3.tgz", - "integrity": "sha512-HefgyP1x754oGCsKmV5reSmtV7IXj/kpaE1XYY+D9G5PvKKoFfSbiS4M77MdjuwlZKDIKFCffq9rPU+H/s3ZdQ==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.4.tgz", + "integrity": "sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==", "dependencies": { "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.0", - "@babel/parser": "^7.25.3", + "@babel/generator": "^7.25.4", + "@babel/parser": "^7.25.4", "@babel/template": "^7.25.0", - "@babel/types": "^7.25.2", + "@babel/types": "^7.25.4", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -9085,9 +9104,9 @@ } }, "node_modules/@babel/types": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.2.tgz", - "integrity": "sha512-YTnYtra7W9e6/oAZEHj0bJehPRUlLH9/fbpT5LfB0NhQXyALCRkRs3zH9v07IYhkgpqX6Z78FnuccZr/l4Fs4Q==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.4.tgz", + "integrity": "sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==", "dependencies": { "@babel/helper-string-parser": "^7.24.8", "@babel/helper-validator-identifier": "^7.24.7", @@ -10642,9 +10661,9 @@ "integrity": "sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==" }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.0.tgz", - "integrity": "sha512-3sG8Zwa5fMcA9bgqB8AfWPQ+HFke6uD3h1s3RIwUNK8EG7a4buxvuFTs3j1IMs2NXAk9F30C/FF4vxRgQCcmoQ==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", + "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", "cpu": [ "ppc64" ], @@ -10658,9 +10677,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.0.tgz", - "integrity": "sha512-+KuOHTKKyIKgEEqKbGTK8W7mPp+hKinbMBeEnNzjJGyFcWsfrXjSTNluJHCY1RqhxFurdD8uNXQDei7qDlR6+g==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.1.tgz", + "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", "cpu": [ "arm" ], @@ -10674,9 +10693,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.0.tgz", - "integrity": "sha512-EuHFUYkAVfU4qBdyivULuu03FhJO4IJN9PGuABGrFy4vUuzk91P2d+npxHcFdpUnfYKy0PuV+n6bKIpHOB3prQ==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz", + "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", "cpu": [ "arm64" ], @@ -10690,9 +10709,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.0.tgz", - "integrity": "sha512-WRrmKidLoKDl56LsbBMhzTTBxrsVwTKdNbKDalbEZr0tcsBgCLbEtoNthOW6PX942YiYq8HzEnb4yWQMLQuipQ==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.1.tgz", + "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", "cpu": [ "x64" ], @@ -10706,9 +10725,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.0.tgz", - "integrity": "sha512-YLntie/IdS31H54Ogdn+v50NuoWF5BDkEUFpiOChVa9UnKpftgwzZRrI4J132ETIi+D8n6xh9IviFV3eXdxfow==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz", + "integrity": "sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==", "cpu": [ "arm64" ], @@ -10722,9 +10741,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.0.tgz", - "integrity": "sha512-IMQ6eme4AfznElesHUPDZ+teuGwoRmVuuixu7sv92ZkdQcPbsNHzutd+rAfaBKo8YK3IrBEi9SLLKWJdEvJniQ==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz", + "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", "cpu": [ "x64" ], @@ -10738,9 +10757,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.0.tgz", - "integrity": "sha512-0muYWCng5vqaxobq6LB3YNtevDFSAZGlgtLoAc81PjUfiFz36n4KMpwhtAd4he8ToSI3TGyuhyx5xmiWNYZFyw==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz", + "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", "cpu": [ "arm64" ], @@ -10754,9 +10773,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.0.tgz", - "integrity": "sha512-XKDVu8IsD0/q3foBzsXGt/KjD/yTKBCIwOHE1XwiXmrRwrX6Hbnd5Eqn/WvDekddK21tfszBSrE/WMaZh+1buQ==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz", + "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", "cpu": [ "x64" ], @@ -10770,9 +10789,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.0.tgz", - "integrity": "sha512-SEELSTEtOFu5LPykzA395Mc+54RMg1EUgXP+iw2SJ72+ooMwVsgfuwXo5Fn0wXNgWZsTVHwY2cg4Vi/bOD88qw==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz", + "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", "cpu": [ "arm" ], @@ -10786,9 +10805,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.0.tgz", - "integrity": "sha512-j1t5iG8jE7BhonbsEg5d9qOYcVZv/Rv6tghaXM/Ug9xahM0nX/H2gfu6X6z11QRTMT6+aywOMA8TDkhPo8aCGw==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz", + "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", "cpu": [ "arm64" ], @@ -10802,9 +10821,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.0.tgz", - "integrity": "sha512-P7O5Tkh2NbgIm2R6x1zGJJsnacDzTFcRWZyTTMgFdVit6E98LTxO+v8LCCLWRvPrjdzXHx9FEOA8oAZPyApWUA==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz", + "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", "cpu": [ "ia32" ], @@ -10818,9 +10837,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.0.tgz", - "integrity": "sha512-InQwepswq6urikQiIC/kkx412fqUZudBO4SYKu0N+tGhXRWUqAx+Q+341tFV6QdBifpjYgUndV1hhMq3WeJi7A==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz", + "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", "cpu": [ "loong64" ], @@ -10834,9 +10853,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.0.tgz", - "integrity": "sha512-J9rflLtqdYrxHv2FqXE2i1ELgNjT+JFURt/uDMoPQLcjWQA5wDKgQA4t/dTqGa88ZVECKaD0TctwsUfHbVoi4w==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz", + "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", "cpu": [ "mips64el" ], @@ -10850,9 +10869,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.0.tgz", - "integrity": "sha512-cShCXtEOVc5GxU0fM+dsFD10qZ5UpcQ8AM22bYj0u/yaAykWnqXJDpd77ublcX6vdDsWLuweeuSNZk4yUxZwtw==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz", + "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", "cpu": [ "ppc64" ], @@ -10866,9 +10885,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.0.tgz", - "integrity": "sha512-HEtaN7Y5UB4tZPeQmgz/UhzoEyYftbMXrBCUjINGjh3uil+rB/QzzpMshz3cNUxqXN7Vr93zzVtpIDL99t9aRw==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz", + "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", "cpu": [ "riscv64" ], @@ -10882,9 +10901,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.0.tgz", - "integrity": "sha512-WDi3+NVAuyjg/Wxi+o5KPqRbZY0QhI9TjrEEm+8dmpY9Xir8+HE/HNx2JoLckhKbFopW0RdO2D72w8trZOV+Wg==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz", + "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", "cpu": [ "s390x" ], @@ -10898,9 +10917,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.0.tgz", - "integrity": "sha512-a3pMQhUEJkITgAw6e0bWA+F+vFtCciMjW/LPtoj99MhVt+Mfb6bbL9hu2wmTZgNd994qTAEw+U/r6k3qHWWaOQ==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz", + "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", "cpu": [ "x64" ], @@ -10914,9 +10933,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.0.tgz", - "integrity": "sha512-cRK+YDem7lFTs2Q5nEv/HHc4LnrfBCbH5+JHu6wm2eP+d8OZNoSMYgPZJq78vqQ9g+9+nMuIsAO7skzphRXHyw==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", + "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", "cpu": [ "x64" ], @@ -10930,9 +10949,9 @@ } }, "node_modules/@esbuild/openbsd-arm64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.0.tgz", - "integrity": "sha512-suXjq53gERueVWu0OKxzWqk7NxiUWSUlrxoZK7usiF50C6ipColGR5qie2496iKGYNLhDZkPxBI3erbnYkU0rQ==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz", + "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", "cpu": [ "arm64" ], @@ -10946,9 +10965,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.0.tgz", - "integrity": "sha512-6p3nHpby0DM/v15IFKMjAaayFhqnXV52aEmv1whZHX56pdkK+MEaLoQWj+H42ssFarP1PcomVhbsR4pkz09qBg==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz", + "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", "cpu": [ "x64" ], @@ -10962,9 +10981,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.0.tgz", - "integrity": "sha512-BFelBGfrBwk6LVrmFzCq1u1dZbG4zy/Kp93w2+y83Q5UGYF1d8sCzeLI9NXjKyujjBBniQa8R8PzLFAUrSM9OA==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", + "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", "cpu": [ "x64" ], @@ -10978,9 +10997,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.0.tgz", - "integrity": "sha512-lY6AC8p4Cnb7xYHuIxQ6iYPe6MfO2CC43XXKo9nBXDb35krYt7KGhQnOkRGar5psxYkircpCqfbNDB4uJbS2jQ==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz", + "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", "cpu": [ "arm64" ], @@ -10994,9 +11013,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.0.tgz", - "integrity": "sha512-7L1bHlOTcO4ByvI7OXVI5pNN6HSu6pUQq9yodga8izeuB1KcT2UkHaH6118QJwopExPn0rMHIseCTx1CRo/uNA==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz", + "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", "cpu": [ "ia32" ], @@ -11010,9 +11029,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.0.tgz", - "integrity": "sha512-Arm+WgUFLUATuoxCJcahGuk6Yj9Pzxd6l11Zb/2aAuv5kWWvvfhLFo2fni4uSK5vzlUdCGZ/BdV5tH8klj8p8g==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz", + "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", "cpu": [ "x64" ], @@ -13263,6 +13282,15 @@ "@opentelemetry/api": ">=1.0.0 <1.10.0" } }, + "node_modules/@opentelemetry/exporter-zipkin/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.25.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.25.1.tgz", + "integrity": "sha512-ZDjMJJQRlyk8A1KZFCc+bCbsyrn1wTwdNt56F7twdfUfnHUZUq77/WfONCj8p72NZOyP7pNTdUWSTYC3GTbuuQ==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@opentelemetry/otlp-exporter-base": { "version": "0.41.2", "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.41.2.tgz", @@ -13423,6 +13451,15 @@ "@opentelemetry/api": ">=1.0.0 <1.10.0" } }, + "node_modules/@opentelemetry/resources/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.25.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.25.1.tgz", + "integrity": "sha512-ZDjMJJQRlyk8A1KZFCc+bCbsyrn1wTwdNt56F7twdfUfnHUZUq77/WfONCj8p72NZOyP7pNTdUWSTYC3GTbuuQ==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@opentelemetry/sdk-logs": { "version": "0.41.2", "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.41.2.tgz", @@ -13497,6 +13534,15 @@ "@opentelemetry/api": ">=1.0.0 <1.10.0" } }, + "node_modules/@opentelemetry/sdk-metrics/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.25.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.25.1.tgz", + "integrity": "sha512-ZDjMJJQRlyk8A1KZFCc+bCbsyrn1wTwdNt56F7twdfUfnHUZUq77/WfONCj8p72NZOyP7pNTdUWSTYC3GTbuuQ==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@opentelemetry/sdk-trace-base": { "version": "1.25.1", "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.25.1.tgz", @@ -13529,7 +13575,7 @@ "@opentelemetry/api": ">=1.0.0 <1.10.0" } }, - "node_modules/@opentelemetry/semantic-conventions": { + "node_modules/@opentelemetry/sdk-trace-base/node_modules/@opentelemetry/semantic-conventions": { "version": "1.25.1", "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.25.1.tgz", "integrity": "sha512-ZDjMJJQRlyk8A1KZFCc+bCbsyrn1wTwdNt56F7twdfUfnHUZUq77/WfONCj8p72NZOyP7pNTdUWSTYC3GTbuuQ==", @@ -13538,6 +13584,15 @@ "node": ">=14" } }, + "node_modules/@opentelemetry/semantic-conventions": { + "version": "1.26.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.26.0.tgz", + "integrity": "sha512-U9PJlOswJPSgQVPI+XEuNLElyFWkb0hAiMg+DExD9V0St03X2lPHGMdxMY/LrVmoukuIpXJ12oyrOtEZ4uXFkw==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@pdf-lib/standard-fonts": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@pdf-lib/standard-fonts/-/standard-fonts-1.0.0.tgz", @@ -13889,17 +13944,31 @@ } }, "node_modules/@smithy/core": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/@smithy/core/-/core-2.3.2.tgz", - "integrity": "sha512-in5wwt6chDBcUv1Lw1+QzZxN9fBffi+qOixfb65yK4sDuKG7zAUO9HAFqmVzsZM3N+3tTyvZjtnDXePpvp007Q==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@smithy/core/-/core-2.4.0.tgz", + "integrity": "sha512-cHXq+FneIF/KJbt4q4pjN186+Jf4ZB0ZOqEaZMBhT79srEyGDDBV31NqBRBjazz8ppQ1bJbDJMY9ba5wKFV36w==", "dependencies": { "@smithy/middleware-endpoint": "^3.1.0", - "@smithy/middleware-retry": "^3.0.14", + "@smithy/middleware-retry": "^3.0.15", "@smithy/middleware-serde": "^3.0.3", "@smithy/protocol-http": "^4.1.0", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", + "@smithy/util-body-length-browser": "^3.0.0", "@smithy/util-middleware": "^3.0.3", + "@smithy/util-utf8": "^3.0.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@smithy/core/node_modules/@smithy/util-utf8": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-3.0.0.tgz", + "integrity": "sha512-rUeT12bxFnplYDe815GXbq/oixEGHfRFFtcTF3YdDi/JaENIM6aSYYLJydG83UNzLXeRI5K8abYd/8Sp/QM0kA==", + "dependencies": { + "@smithy/util-buffer-from": "^3.0.0", "tslib": "^2.6.2" }, "engines": { @@ -14166,14 +14235,14 @@ } }, "node_modules/@smithy/middleware-retry": { - "version": "3.0.14", - "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-3.0.14.tgz", - "integrity": "sha512-7ZaWZJOjUxa5hgmuMspyt8v/zVsh0GXYuF7OvCmdcbVa/xbnKQoYC+uYKunAqRGTkxjOyuOCw9rmFUFOqqC0eQ==", + "version": "3.0.15", + "resolved": "https://registry.npmjs.org/@smithy/middleware-retry/-/middleware-retry-3.0.15.tgz", + "integrity": "sha512-iTMedvNt1ApdvkaoE8aSDuwaoc+BhvHqttbA/FO4Ty+y/S5hW6Ci/CTScG7vam4RYJWZxdTElc3MEfHRVH6cgQ==", "dependencies": { "@smithy/node-config-provider": "^3.1.4", "@smithy/protocol-http": "^4.1.0", "@smithy/service-error-classification": "^3.0.3", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "@smithy/util-middleware": "^3.0.3", "@smithy/util-retry": "^3.0.3", @@ -14352,9 +14421,9 @@ } }, "node_modules/@smithy/smithy-client": { - "version": "3.1.12", - "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-3.1.12.tgz", - "integrity": "sha512-wtm8JtsycthkHy1YA4zjIh2thJgIQ9vGkoR639DBx5lLlLNU0v4GARpQZkr2WjXue74nZ7MiTSWfVrLkyD8RkA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-3.2.0.tgz", + "integrity": "sha512-pDbtxs8WOhJLJSeaF/eAbPgXg4VVYFlRcL/zoNYA5WbG3wBL06CHtBSg53ppkttDpAJ/hdiede+xApip1CwSLw==", "dependencies": { "@smithy/middleware-endpoint": "^3.1.0", "@smithy/middleware-stack": "^3.0.3", @@ -14456,12 +14525,12 @@ } }, "node_modules/@smithy/util-defaults-mode-browser": { - "version": "3.0.14", - "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-3.0.14.tgz", - "integrity": "sha512-0iwTgKKmAIf+vFLV8fji21Jb2px11ktKVxbX6LIDPAUJyWQqGqBVfwba7xwa1f2FZUoolYQgLvxQEpJycXuQ5w==", + "version": "3.0.15", + "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-3.0.15.tgz", + "integrity": "sha512-FZ4Psa3vjp8kOXcd3HJOiDPBCWtiilLl57r0cnNtq/Ga9RSDrM5ERL6xt+tO43+2af6Pn5Yp92x2n5vPuduNfg==", "dependencies": { "@smithy/property-provider": "^3.1.3", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "bowser": "^2.11.0", "tslib": "^2.6.2" @@ -14471,15 +14540,15 @@ } }, "node_modules/@smithy/util-defaults-mode-node": { - "version": "3.0.14", - "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-3.0.14.tgz", - "integrity": "sha512-e9uQarJKfXApkTMMruIdxHprhcXivH1flYCe8JRDTzkkLx8dA3V5J8GZlST9yfDiRWkJpZJlUXGN9Rc9Ade3OQ==", + "version": "3.0.15", + "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-3.0.15.tgz", + "integrity": "sha512-KSyAAx2q6d0t6f/S4XB2+3+6aQacm3aLMhs9aLMqn18uYGUepbdssfogW5JQZpc6lXNBnp0tEnR5e9CEKmEd7A==", "dependencies": { "@smithy/config-resolver": "^3.0.5", "@smithy/credential-provider-imds": "^3.2.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/property-provider": "^3.1.3", - "@smithy/smithy-client": "^3.1.12", + "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" }, @@ -15346,6 +15415,19 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@tapjs/test/node_modules/typescript": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/@tapjs/typescript": { "version": "1.4.13", "resolved": "https://registry.npmjs.org/@tapjs/typescript/-/typescript-1.4.13.tgz", @@ -15726,9 +15808,9 @@ } }, "node_modules/@types/node": { - "version": "22.4.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.0.tgz", - "integrity": "sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==", + "version": "22.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", + "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", "dependencies": { "undici-types": "~6.19.2" } @@ -15781,9 +15863,9 @@ "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==" }, "node_modules/@types/react": { - "version": "18.3.3", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.3.tgz", - "integrity": "sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==", + "version": "18.3.4", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.4.tgz", + "integrity": "sha512-J7W30FTdfCxDDjmfRM+/JqLHBIyl7xUIp9kwK637FGmY7+mkSFSe6L4jpZzhj5QMfLssSDP4/i75AKkrdC7/Jw==", "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -15928,16 +16010,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.1.0.tgz", - "integrity": "sha512-LlNBaHFCEBPHyD4pZXb35mzjGkuGKXU5eeCA1SxvHfiRES0E82dOounfVpL4DCqYvJEKab0bZIA0gCRpdLKkCw==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.2.0.tgz", + "integrity": "sha512-02tJIs655em7fvt9gps/+4k4OsKULYGtLBPJfOsmOq1+3cdClYiF0+d6mHu6qDnTcg88wJBkcPLpQhq7FyDz0A==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.1.0", - "@typescript-eslint/type-utils": "8.1.0", - "@typescript-eslint/utils": "8.1.0", - "@typescript-eslint/visitor-keys": "8.1.0", + "@typescript-eslint/scope-manager": "8.2.0", + "@typescript-eslint/type-utils": "8.2.0", + "@typescript-eslint/utils": "8.2.0", + "@typescript-eslint/visitor-keys": "8.2.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -15961,15 +16043,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.1.0.tgz", - "integrity": "sha512-U7iTAtGgJk6DPX9wIWPPOlt1gO57097G06gIcl0N0EEnNw8RGD62c+2/DiP/zL7KrkqnnqF7gtFGR7YgzPllTA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.2.0.tgz", + "integrity": "sha512-j3Di+o0lHgPrb7FxL3fdEy6LJ/j2NE8u+AP/5cQ9SKb+JLH6V6UHDqJ+e0hXBkHP1wn1YDFjYCS9LBQsZDlDEg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "8.1.0", - "@typescript-eslint/types": "8.1.0", - "@typescript-eslint/typescript-estree": "8.1.0", - "@typescript-eslint/visitor-keys": "8.1.0", + "@typescript-eslint/scope-manager": "8.2.0", + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/typescript-estree": "8.2.0", + "@typescript-eslint/visitor-keys": "8.2.0", "debug": "^4.3.4" }, "engines": { @@ -15989,13 +16071,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.1.0.tgz", - "integrity": "sha512-DsuOZQji687sQUjm4N6c9xABJa7fjvfIdjqpSIIVOgaENf2jFXiM9hIBZOL3hb6DHK9Nvd2d7zZnoMLf9e0OtQ==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.2.0.tgz", + "integrity": "sha512-OFn80B38yD6WwpoHU2Tz/fTz7CgFqInllBoC3WP+/jLbTb4gGPTy9HBSTsbDWkMdN55XlVU0mMDYAtgvlUspGw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "8.1.0", - "@typescript-eslint/visitor-keys": "8.1.0" + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/visitor-keys": "8.2.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -16006,13 +16088,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.1.0.tgz", - "integrity": "sha512-oLYvTxljVvsMnldfl6jIKxTaU7ok7km0KDrwOt1RHYu6nxlhN3TIx8k5Q52L6wR33nOwDgM7VwW1fT1qMNfFIA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.2.0.tgz", + "integrity": "sha512-g1CfXGFMQdT5S+0PSO0fvGXUaiSkl73U1n9LTK5aRAFnPlJ8dLKkXr4AaLFvPedW8lVDoMgLLE3JN98ZZfsj0w==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "8.1.0", - "@typescript-eslint/utils": "8.1.0", + "@typescript-eslint/typescript-estree": "8.2.0", + "@typescript-eslint/utils": "8.2.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -16030,9 +16112,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.1.0.tgz", - "integrity": "sha512-q2/Bxa0gMOu/2/AKALI0tCKbG2zppccnRIRCW6BaaTlRVaPKft4oVYPp7WOPpcnsgbr0qROAVCVKCvIQ0tbWog==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.2.0.tgz", + "integrity": "sha512-6a9QSK396YqmiBKPkJtxsgZZZVjYQ6wQ/TlI0C65z7vInaETuC6HAHD98AGLC8DyIPqHytvNuS8bBVvNLKyqvQ==", "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -16043,13 +16125,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.1.0.tgz", - "integrity": "sha512-NTHhmufocEkMiAord/g++gWKb0Fr34e9AExBRdqgWdVBaKoei2dIyYKD9Q0jBnvfbEA5zaf8plUFMUH6kQ0vGg==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.2.0.tgz", + "integrity": "sha512-kiG4EDUT4dImplOsbh47B1QnNmXSoUqOjWDvCJw/o8LgfD0yr7k2uy54D5Wm0j4t71Ge1NkynGhpWdS0dEIAUA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "8.1.0", - "@typescript-eslint/visitor-keys": "8.1.0", + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/visitor-keys": "8.2.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -16071,15 +16153,15 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.1.0.tgz", - "integrity": "sha512-ypRueFNKTIFwqPeJBfeIpxZ895PQhNyH4YID6js0UoBImWYoSjBsahUn9KMiJXh94uOjVBgHD9AmkyPsPnFwJA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.2.0.tgz", + "integrity": "sha512-O46eaYKDlV3TvAVDNcoDzd5N550ckSe8G4phko++OCSC1dYIb9LTc3HDGYdWqWIAT5qDUKphO6sd9RrpIJJPfg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.1.0", - "@typescript-eslint/types": "8.1.0", - "@typescript-eslint/typescript-estree": "8.1.0" + "@typescript-eslint/scope-manager": "8.2.0", + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/typescript-estree": "8.2.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -16093,12 +16175,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.1.0.tgz", - "integrity": "sha512-ba0lNI19awqZ5ZNKh6wCModMwoZs457StTebQ0q1NP58zSi2F6MOZRXwfKZy+jB78JNJ/WH8GSh2IQNzXX8Nag==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.2.0.tgz", + "integrity": "sha512-sbgsPMW9yLvS7IhCi8IpuK1oBmtbWUNP+hBdwl/I9nzqVsszGnNGti5r9dUtF5RLivHUFFIdRvLiTsPhzSyJ3Q==", "dev": true, "dependencies": { - "@typescript-eslint/types": "8.1.0", + "@typescript-eslint/types": "8.2.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -16968,13 +17050,13 @@ } }, "node_modules/artillery": { - "version": "2.0.19", - "resolved": "https://registry.npmjs.org/artillery/-/artillery-2.0.19.tgz", - "integrity": "sha512-NeD5+D7U5l8hZ3lHtUseFTwqxILN2qfl4XlQt4cH0PukA/wsOri7cR0Qg2925usCa5EkD240Dfh9r9wYvuHxlw==", + "version": "2.0.20", + "resolved": "https://registry.npmjs.org/artillery/-/artillery-2.0.20.tgz", + "integrity": "sha512-/lC1q786kaUq2fQFsMZf5G8oKtDDmLcfA1OLEiSA2+lJbBSYMCt9rWlRjLCRkVTKCcv4dDZdrhcRYHmPc6PNVQ==", "dev": true, "dependencies": { - "@artilleryio/int-commons": "2.10.0", - "@artilleryio/int-core": "2.14.0", + "@artilleryio/int-commons": "2.11.0", + "@artilleryio/int-core": "2.15.0", "@aws-sdk/credential-providers": "^3.127.0", "@azure/arm-containerinstance": "^9.1.0", "@azure/identity": "^4.2.0", @@ -16984,14 +17066,14 @@ "@oclif/plugin-help": "^5.2.11", "@oclif/plugin-not-found": "^2.3.1", "archiver": "^5.3.1", - "artillery-engine-playwright": "1.16.0", - "artillery-plugin-apdex": "1.10.0", - "artillery-plugin-ensure": "1.13.0", - "artillery-plugin-expect": "2.13.0", - "artillery-plugin-fake-data": "1.10.0", - "artillery-plugin-metrics-by-endpoint": "1.13.0", - "artillery-plugin-publish-metrics": "2.24.0", - "artillery-plugin-slack": "1.8.0", + "artillery-engine-playwright": "1.17.0", + "artillery-plugin-apdex": "1.11.0", + "artillery-plugin-ensure": "1.14.0", + "artillery-plugin-expect": "2.14.0", + "artillery-plugin-fake-data": "1.11.0", + "artillery-plugin-metrics-by-endpoint": "1.14.0", + "artillery-plugin-publish-metrics": "2.25.0", + "artillery-plugin-slack": "1.9.0", "async": "^2.6.4", "aws-sdk": "^2.1338.0", "chalk": "^2.4.2", @@ -17033,9 +17115,9 @@ } }, "node_modules/artillery-engine-playwright": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/artillery-engine-playwright/-/artillery-engine-playwright-1.16.0.tgz", - "integrity": "sha512-90Gka/neaKABygcWANL/wOrI3U75Xll4yAZmBywQiTONorGL3SIizEEujGXosHLUeOgzc+3OEldP5qXfCynMOg==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/artillery-engine-playwright/-/artillery-engine-playwright-1.17.0.tgz", + "integrity": "sha512-sWaQ9OEuvlgVr6ABpAi6gef0c6tDpaqiizg+eeB05TJB0PLyZQoU/0+JQN162Lx3mJW0kiaYNqtot6huxcXK+Q==", "dev": true, "dependencies": { "@playwright/browser-chromium": "1.45.3", @@ -17045,18 +17127,18 @@ } }, "node_modules/artillery-plugin-apdex": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/artillery-plugin-apdex/-/artillery-plugin-apdex-1.10.0.tgz", - "integrity": "sha512-TabM/LXhp5n3AKiCXQHl3ivwCuh7QfdV5vjYpT8di32Rd42f9AahFiOIje4aInW9u5S8qNsB78UU3ov084GxwA==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/artillery-plugin-apdex/-/artillery-plugin-apdex-1.11.0.tgz", + "integrity": "sha512-Gng+T4tCGf0aZiNk071VZ6X69kgz/vtFDLuu11EdlePyC4Q9e4truAnYUC49rXg97i/JyYueTxjGHogefWJlRg==", "dev": true, "dependencies": { "tap": "^19.0.2" } }, "node_modules/artillery-plugin-ensure": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/artillery-plugin-ensure/-/artillery-plugin-ensure-1.13.0.tgz", - "integrity": "sha512-/FwOj4a2npaUkNsB+dtHGa5euRqi1ly0mvcqz2UawNia+5SQXVJauL0ue84uQrU0O8ercH/gzsb7cG2/RKYkwg==", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/artillery-plugin-ensure/-/artillery-plugin-ensure-1.14.0.tgz", + "integrity": "sha512-kK+artqRYRM8uyJVAvyJX1MYT4j2W1FTIU2wIwNSFufTQbjORFoyQbBBaOeoDyao9g3NCcNO3BBHefE0kfVDgw==", "dev": true, "dependencies": { "chalk": "^2.4.2", @@ -17071,9 +17153,9 @@ "dev": true }, "node_modules/artillery-plugin-expect": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/artillery-plugin-expect/-/artillery-plugin-expect-2.13.0.tgz", - "integrity": "sha512-j7beHovPaR9b4tKxn6gq6QXXK+XXtZ2B6DzX3PERqPcZPA07zSPrTJfzmtbwmnAGvQZYLK5jucQ6H+ZzyimiQg==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/artillery-plugin-expect/-/artillery-plugin-expect-2.14.0.tgz", + "integrity": "sha512-E3Z7MyKTG/1DJcfCV8wloLAVbsOy0N6TOE8XdxtqpDklfHD4jXm614FbBULrPaLyfHVca0BrPhsBo6IT3HqFWQ==", "dev": true, "dependencies": { "chalk": "^4.1.2", @@ -17114,27 +17196,27 @@ } }, "node_modules/artillery-plugin-fake-data": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/artillery-plugin-fake-data/-/artillery-plugin-fake-data-1.10.0.tgz", - "integrity": "sha512-EQeeiIGJfxpXszn1zH91EyNprblpkME/HuHYloILExTc6My9+tcY5fezd1SEBbQ+jJ4qKB5KJyqQ6RS6HE+oBQ==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/artillery-plugin-fake-data/-/artillery-plugin-fake-data-1.11.0.tgz", + "integrity": "sha512-UA9lqNknWQd/0tQA2iyv+xDaroAlUKuNkwLWjNfcl9fvJLvISubaVMJwErVhlKETEwLb3FTcinYSfW3iIDusUw==", "dev": true, "dependencies": { "@ngneat/falso": "^7.1.1" } }, "node_modules/artillery-plugin-metrics-by-endpoint": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/artillery-plugin-metrics-by-endpoint/-/artillery-plugin-metrics-by-endpoint-1.13.0.tgz", - "integrity": "sha512-1zKp+kIZusPDLIcYE9Yheua5RYekAMNkJr/fQ2odQaeJdSkWyS/gURvroORhYAv41LKRfAvYazW668uUY6WkKA==", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/artillery-plugin-metrics-by-endpoint/-/artillery-plugin-metrics-by-endpoint-1.14.0.tgz", + "integrity": "sha512-GXnIq0kluQwMelwrcfPOc5hK3Jim4AAFdYsqvmvi4PdEso2MZNdwD2qnrYI4mcxXJBaUMGV+0jva0L+I7RnxNw==", "dev": true, "dependencies": { "debug": "^4.3.2" } }, "node_modules/artillery-plugin-publish-metrics": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/artillery-plugin-publish-metrics/-/artillery-plugin-publish-metrics-2.24.0.tgz", - "integrity": "sha512-7a6vykigjZ5zdk41ma8supGmownU31SdQRD9hxfpKv8gLIOAlTTD25OxnjGmddF4JArhztSAqrPb+J8s/7xXRw==", + "version": "2.25.0", + "resolved": "https://registry.npmjs.org/artillery-plugin-publish-metrics/-/artillery-plugin-publish-metrics-2.25.0.tgz", + "integrity": "sha512-VblhbItYcaN/R35EUasqudwMFdi4Qq+Z/BIBU94UZjxfs794Q96vKE/HV84NHXTbp6EcDd9RXxcis03dWuUHOQ==", "dev": true, "dependencies": { "@aws-sdk/client-cloudwatch": "^3.370.0", @@ -17174,9 +17256,9 @@ } }, "node_modules/artillery-plugin-slack": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/artillery-plugin-slack/-/artillery-plugin-slack-1.8.0.tgz", - "integrity": "sha512-BpZZonGQRBZo1oXw0XNx7itoGKlZDClE+SzNt3SDTTFcQuvdPD6FD05Y9hDfSfG3zdEuuc9joAtCuKMmZALaeg==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/artillery-plugin-slack/-/artillery-plugin-slack-1.9.0.tgz", + "integrity": "sha512-JAwnb+fhwo/Vdr2rWim66Q35MGD1CQetWxuEb6yqYvn7C4RA4F8dWcA9kPW8GQqy73V2LnKuCgl+7+Nu9mVL0g==", "dev": true, "dependencies": { "debug": "^4.3.4", @@ -19588,9 +19670,9 @@ } }, "node_modules/core-js": { - "version": "3.38.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.0.tgz", - "integrity": "sha512-XPpwqEodRljce9KswjZShh95qJ1URisBeKCjUdq27YdenkslVe7OO0ZJhlYXAChW7OhXaRLl8AAba7IBfoIHug==", + "version": "3.38.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.1.tgz", + "integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -21751,9 +21833,9 @@ } }, "node_modules/esbuild": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.0.tgz", - "integrity": "sha512-1lvV17H2bMYda/WaFb2jLPeHU3zml2k4/yagNMG8Q/YtfMjCwEUZa2eXXMgZTVSL5q1n4H7sQ0X6CdJDqqeCFA==", + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", + "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", "dev": true, "hasInstallScript": true, "bin": { @@ -21763,30 +21845,30 @@ "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.23.0", - "@esbuild/android-arm": "0.23.0", - "@esbuild/android-arm64": "0.23.0", - "@esbuild/android-x64": "0.23.0", - "@esbuild/darwin-arm64": "0.23.0", - "@esbuild/darwin-x64": "0.23.0", - "@esbuild/freebsd-arm64": "0.23.0", - "@esbuild/freebsd-x64": "0.23.0", - "@esbuild/linux-arm": "0.23.0", - "@esbuild/linux-arm64": "0.23.0", - "@esbuild/linux-ia32": "0.23.0", - "@esbuild/linux-loong64": "0.23.0", - "@esbuild/linux-mips64el": "0.23.0", - "@esbuild/linux-ppc64": "0.23.0", - "@esbuild/linux-riscv64": "0.23.0", - "@esbuild/linux-s390x": "0.23.0", - "@esbuild/linux-x64": "0.23.0", - "@esbuild/netbsd-x64": "0.23.0", - "@esbuild/openbsd-arm64": "0.23.0", - "@esbuild/openbsd-x64": "0.23.0", - "@esbuild/sunos-x64": "0.23.0", - "@esbuild/win32-arm64": "0.23.0", - "@esbuild/win32-ia32": "0.23.0", - "@esbuild/win32-x64": "0.23.0" + "@esbuild/aix-ppc64": "0.23.1", + "@esbuild/android-arm": "0.23.1", + "@esbuild/android-arm64": "0.23.1", + "@esbuild/android-x64": "0.23.1", + "@esbuild/darwin-arm64": "0.23.1", + "@esbuild/darwin-x64": "0.23.1", + "@esbuild/freebsd-arm64": "0.23.1", + "@esbuild/freebsd-x64": "0.23.1", + "@esbuild/linux-arm": "0.23.1", + "@esbuild/linux-arm64": "0.23.1", + "@esbuild/linux-ia32": "0.23.1", + "@esbuild/linux-loong64": "0.23.1", + "@esbuild/linux-mips64el": "0.23.1", + "@esbuild/linux-ppc64": "0.23.1", + "@esbuild/linux-riscv64": "0.23.1", + "@esbuild/linux-s390x": "0.23.1", + "@esbuild/linux-x64": "0.23.1", + "@esbuild/netbsd-x64": "0.23.1", + "@esbuild/openbsd-arm64": "0.23.1", + "@esbuild/openbsd-x64": "0.23.1", + "@esbuild/sunos-x64": "0.23.1", + "@esbuild/win32-arm64": "0.23.1", + "@esbuild/win32-ia32": "0.23.1", + "@esbuild/win32-x64": "0.23.1" } }, "node_modules/esbuild-css-modules-plugin": { @@ -24807,9 +24889,9 @@ } }, "node_modules/husky": { - "version": "9.1.4", - "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.4.tgz", - "integrity": "sha512-bho94YyReb4JV7LYWRWxZ/xr6TtOTt8cMfmQ39MQYJ7f/YE268s3GdghGwi+y4zAeqewE5zYLvuhV0M0ijsDEA==", + "version": "9.1.5", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.5.tgz", + "integrity": "sha512-rowAVRUBfI0b4+niA4SJMhfQwc107VLkBUgEYYAOQAbqDCnra1nYh83hF/MDmhYs9t9n1E3DuKOrs2LYNC+0Ag==", "dev": true, "bin": { "husky": "bin.js" @@ -33036,9 +33118,9 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/protobufjs": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.3.2.tgz", - "integrity": "sha512-RXyHaACeqXeqAKGLDl68rQKbmObRsTIn4TYVUUug1KfS47YWCo5MacGITEryugIgZqORCvJWEk4l449POg5Txg==", + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.3.3.tgz", + "integrity": "sha512-HaYi2CVjiPoBR1d2zTVKVHXr9IUnpJizCjUu19vxdD3B8o4z+vfOHpIEB1358w8nv8dfUNEfDHFvMsH7QlLt/Q==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -34649,9 +34731,9 @@ } }, "node_modules/sass-loader": { - "version": "16.0.0", - "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-16.0.0.tgz", - "integrity": "sha512-n13Z+3rU9A177dk4888czcVFiC8CL9dii4qpXWUg3YIIgZEvi9TCFKjOQcbK0kJM7DJu9VucrZFddvNfYCPwtw==", + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-16.0.1.tgz", + "integrity": "sha512-xACl1ToTsKnL9Ce5yYpRxrLj9QUDCnwZNhzpC7tKiFyA8zXsd3Ap+HGVnbCgkdQcm43E+i6oKAWBsvGA6ZoiMw==", "dev": true, "dependencies": { "neo-async": "^2.6.2" @@ -36937,21 +37019,21 @@ } }, "node_modules/tldts": { - "version": "6.1.39", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.39.tgz", - "integrity": "sha512-UCGXcPhYIUELc+FifEeDXYkoTWNU6iOEdM/Q5LsvkTz2SnpQ3q5onA+DiiZlR5YDskMhfK1YBQDeWL7PH9/miQ==", + "version": "6.1.41", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.41.tgz", + "integrity": "sha512-RNpUkL5fYD2DTQQCdr8QMDp6UL0ThtpXT3q3+qPE05dIT+RK2I3M0VByVbQN1dEhLUGzimivVwxK2By9epLk6w==", "dev": true, "dependencies": { - "tldts-core": "^6.1.39" + "tldts-core": "^6.1.41" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "6.1.39", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.39.tgz", - "integrity": "sha512-+Qib8VaRq6F56UjP4CJXd30PI4s3hFumDywUlsbiEWoA8+lfAaWNTLr3e6/zZOgHzVyon4snHaybeFHd8C0j/A==", + "version": "6.1.41", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.41.tgz", + "integrity": "sha512-SkwZgo1ZzMp2ziMBwci5VBnLR9VywCi02jSgMX5TO5kf9fdaBsxZkblLff3NlJNTcH0vfvEsgw2B7jVR556Vgw==", "dev": true }, "node_modules/tmp": { @@ -37570,9 +37652,9 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -37619,9 +37701,9 @@ "dev": true }, "node_modules/undici": { - "version": "6.19.7", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.7.tgz", - "integrity": "sha512-HR3W/bMGPSr90i8AAp2C4DM3wChFdJPLrWYpIS++LxS8K+W535qftjt+4MyjNYHeWabMj1nvtmLIi7l++iq91A==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.8.tgz", + "integrity": "sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==", "dev": true, "engines": { "node": ">=18.17" diff --git a/package.json b/package.json index 662a9579aa8..07323f7a2de 100644 --- a/package.json +++ b/package.json @@ -11,34 +11,34 @@ "dependencies": { "@18f/us-federal-holidays": "4.0.0", "@aws-crypto/sha256-browser": "5.2.0", - "@aws-sdk/client-api-gateway": "3.632.0", - "@aws-sdk/client-apigatewaymanagementapi": "3.632.0", - "@aws-sdk/client-apigatewayv2": "3.632.0", - "@aws-sdk/client-cloudfront": "3.632.0", - "@aws-sdk/client-cloudwatch": "3.632.0", - "@aws-sdk/client-cloudwatch-logs": "3.632.0", - "@aws-sdk/client-cognito-identity-provider": "3.632.0", - "@aws-sdk/client-dynamodb": "3.632.0", - "@aws-sdk/client-dynamodb-streams": "3.632.0", - "@aws-sdk/client-glue": "3.632.0", - "@aws-sdk/client-lambda": "3.632.0", - "@aws-sdk/client-opensearch": "3.632.0", - "@aws-sdk/client-route-53": "3.632.0", - "@aws-sdk/client-s3": "3.633.0", - "@aws-sdk/client-ses": "3.632.0", - "@aws-sdk/client-sns": "3.632.0", - "@aws-sdk/client-sqs": "3.632.0", - "@aws-sdk/client-ssm": "3.632.0", + "@aws-sdk/client-api-gateway": "3.635.0", + "@aws-sdk/client-apigatewaymanagementapi": "3.635.0", + "@aws-sdk/client-apigatewayv2": "3.635.0", + "@aws-sdk/client-cloudfront": "3.635.0", + "@aws-sdk/client-cloudwatch": "3.635.0", + "@aws-sdk/client-cloudwatch-logs": "3.635.0", + "@aws-sdk/client-cognito-identity-provider": "3.635.0", + "@aws-sdk/client-dynamodb": "3.635.0", + "@aws-sdk/client-dynamodb-streams": "3.635.0", + "@aws-sdk/client-glue": "3.636.0", + "@aws-sdk/client-lambda": "3.636.0", + "@aws-sdk/client-opensearch": "3.635.0", + "@aws-sdk/client-route-53": "3.635.0", + "@aws-sdk/client-s3": "3.635.0", + "@aws-sdk/client-ses": "3.636.0", + "@aws-sdk/client-sns": "3.635.0", + "@aws-sdk/client-sqs": "3.635.0", + "@aws-sdk/client-ssm": "3.635.0", "@aws-sdk/cloudfront-signer": "3.621.0", - "@aws-sdk/credential-provider-node": "3.632.0", - "@aws-sdk/lib-dynamodb": "3.632.0", - "@aws-sdk/lib-storage": "3.633.0", + "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/lib-dynamodb": "3.635.0", + "@aws-sdk/lib-storage": "3.635.0", "@aws-sdk/node-http-handler": "3.374.0", "@aws-sdk/protocol-http": "3.374.0", - "@aws-sdk/s3-presigned-post": "3.633.0", - "@aws-sdk/s3-request-presigner": "3.633.0", + "@aws-sdk/s3-presigned-post": "3.635.0", + "@aws-sdk/s3-request-presigner": "3.635.0", "@aws-sdk/signature-v4": "3.374.0", - "@aws-sdk/util-dynamodb": "3.632.0", + "@aws-sdk/util-dynamodb": "3.635.0", "@cerebral/react": "4.2.1", "@fortawesome/fontawesome-svg-core": "1.2.36", "@fortawesome/free-regular-svg-icons": "5.15.4", @@ -56,7 +56,7 @@ "cerebral": "5.2.1", "classnames": "2.5.1", "cookie": "0.6.0", - "core-js": "3.38.0", + "core-js": "3.38.1", "cors": "2.8.5", "csv-stringify": "6.5.1", "deep-freeze": "0.0.1", @@ -244,12 +244,12 @@ "ejs": "3.1.10" }, "devDependencies": { - "@aws-sdk/client-iam": "3.632.0", - "@aws-sdk/client-secrets-manager": "3.632.0", + "@aws-sdk/client-iam": "3.635.0", + "@aws-sdk/client-secrets-manager": "3.635.0", "@babel/cli": "7.24.8", "@babel/core": "7.25.2", "@babel/eslint-parser": "7.25.1", - "@babel/preset-env": "7.25.3", + "@babel/preset-env": "7.25.4", "@babel/preset-react": "7.24.7", "@babel/preset-typescript": "7.24.7", "@babel/register": "7.24.6", @@ -260,19 +260,19 @@ "@types/jest": "29.5.12", "@types/lodash": "4.17.7", "@types/luxon": "3.4.2", - "@types/node": "22.4.0", + "@types/node": "22.5.0", "@types/promise-retry": "1.1.6", - "@types/react": "18.3.3", + "@types/react": "18.3.4", "@types/react-dom": "18.3.0", "@types/react-paginate": "7.1.4", "@types/uuid": "10.0.0", "@types/websocket": "1.0.10", - "@typescript-eslint/eslint-plugin": "8.1.0", - "@typescript-eslint/parser": "8.1.0", + "@typescript-eslint/eslint-plugin": "8.2.0", + "@typescript-eslint/parser": "8.2.0", "@vendia/serverless-express": "4.12.6", "ajv": "8.17.1", - "artillery": "2.0.19", - "artillery-plugin-metrics-by-endpoint": "1.13.0", + "artillery": "2.0.20", + "artillery-plugin-metrics-by-endpoint": "1.14.0", "autoprefixer": "10.4.20", "aws-sdk-client-mock": "4.0.1", "axe-core": "4.10.0", @@ -292,7 +292,7 @@ "decimal.js": "10.4.3", "dynamodb-admin": "4.6.1", "dynamodb-streams-readable": "3.0.0", - "esbuild": "0.23.0", + "esbuild": "0.23.1", "esbuild-css-modules-plugin": "3.1.2", "esbuild-plugin-babel-cached": "0.2.3", "esbuild-plugin-clean": "1.0.1", @@ -319,7 +319,7 @@ "eslint-plugin-spellcheck": "0.0.20", "esm": "3.2.25", "file-loader": "6.2.0", - "husky": "9.1.4", + "husky": "9.1.5", "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", "jest-environment-node": "29.7.0", @@ -345,7 +345,7 @@ "readline": "1.3.0", "s3rver": "github:20minutes/s3rver", "sass": "1.77.8", - "sass-loader": "16.0.0", + "sass-loader": "16.0.1", "shuffle-seed": "1.1.6", "stream-browserify": "3.0.0", "style-loader": "4.0.0", @@ -360,7 +360,7 @@ "ts-loader": "9.5.1", "ts-node": "10.9.2", "tsconfig-paths": "4.2.0", - "typescript": "5.4.5", + "typescript": "5.5.4", "utf8": "3.0.0" } } From e82c7924c510ffb9d166a2efe892dbc831212b45 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 22 Aug 2024 14:08:49 -0500 Subject: [PATCH 448/523] deps: update puppeteer, chromium deps: puppeteer and chromium --- docs/dependency-updates.md | 5 -- package-lock.json | 71 +++++++++++--------- package.json | 6 +- web-api/runtimes/puppeteer/package-lock.json | 66 +++++++++--------- web-api/runtimes/puppeteer/package.json | 4 +- 5 files changed, 81 insertions(+), 71 deletions(-) diff --git a/docs/dependency-updates.md b/docs/dependency-updates.md index 592dd546294..530af4114a2 100644 --- a/docs/dependency-updates.md +++ b/docs/dependency-updates.md @@ -77,7 +77,6 @@ Below is a list of dependencies that are locked down due to known issues with se - When updating puppeteer or puppeteer core in the project, make sure to also match versions in `web-api/runtimes/puppeteer/package.json` as this is our lambda layer which we use to generate pdfs. Puppeteer and chromium versions should always match between package.json and web-api/runtimes/puppeteer/package.json. Remember to run `npm install --prefix web-api/runtimes/puppeteer` to install and update the package-lock file. - Puppeteer also has recommended versions of Chromium, so we should make sure to use the recommended version of chromium for the version of puppeteer that we are on. -- As of 8/15/2024, we cannot update puppeteer or puppeteer-core beyond 22.13.1 because the latest release of @sparticuz/chromium only supports version 126 of chromium. - There is a high-severity security issue with ws (ws affected by a DoS when handling a request with many HTTP headers - https://github.com/advisories/GHSA-3h5v-q93c-6h6q); however, we only use ws on the client side, so this should not be an issue. (We tried to upgrade puppeteer anyway, but unsurprisingly the PDF tests failed because there is no newer version of Chromium that supports puppeteer.) ### pdfjs-dist @@ -95,10 +94,6 @@ See: https://github.com/jsx-eslint/eslint-plugin-react/issues/3699 ### ws, 3rd party dependency of Cerebral - When running npm audit, you'll see a high severity issue with ws, 'affected by a DoS when handling a request with many HTTP headers - https://github.com/advisories/GHSA-3h5v-q93c-6h6q'. This doesn't affect us as the vulnerability is on the server side and we're not using this package on the server. We tried to override this to 5.2.4 and 8.18.0 and weren't able to make this work as import paths have changed. In the mean time, we recommend skipping this issue. We could always fork the cerebral repo in the future if needed. -### typescript -- We currently run version 5.4.5; upon upgrading to version 5.5.3 on 6 July 2024, we ran into a series of issues. While the tests passed, we ran into issues linting and type-checking. The recurring issue was a RangeError: Maximum call stack size exceeded, which occurred with our npx tsc command as well as our lint-staged command. We noticed related issues in Github around this release. In order to prevent delaying other devs and ensure the remaining dependency updates are completed, we decided to hold on this update till version 5.5.3+ and/or we can spend more time to determine why this is occurring. -- Update 12 July 2024: There are two new related open issues (https://github.com/microsoft/TypeScript/issues/59255 and https://github.com/microsoft/TypeScript/issues/59253), which provides further evidence for a TS bug. TS is still on version 5.5.3. - ## Incrementing the Node Cache Key Version It's rare to need modify cache key. One reason you may want to do so is if a package fails to install properly, and CircleCI, unaware of the failed installation, stores the corrupted cache. In this case, we will need to increment the cache key version so that CircleCI is forced to reinstall the node dependencies and save them using the new key. To update the cache key, locate `vX-npm` and `vX-cypress` (where X represents the current cache key version) in the config.yml file, and then increment the identified version. diff --git a/package-lock.json b/package-lock.json index 7c5ab29ab42..9b34d05eed8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "@fortawesome/react-fontawesome": "0.2.2", "@joi/date": "2.1.1", "@opensearch-project/opensearch": "2.11.0", - "@sparticuz/chromium": "126.0.0", + "@sparticuz/chromium": "127.0.0", "@uswds/uswds": "3.7.1", "aws-lambda": "1.0.7", "aws-xray-sdk": "3.9.0", @@ -197,8 +197,8 @@ "postcss-preset-env": "10.0.2", "prettier": "3.3.3", "prop-types": "15.8.1", - "puppeteer": "22.13.1", - "puppeteer-core": "22.13.1", + "puppeteer": "23.1.1", + "puppeteer-core": "23.1.1", "react-test-renderer": "18.3.1", "readline": "1.3.0", "s3rver": "github:20minutes/s3rver", @@ -13724,16 +13724,16 @@ "dev": true }, "node_modules/@puppeteer/browsers": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.2.4.tgz", - "integrity": "sha512-BdG2qiI1dn89OTUUsx2GZSpUzW+DRffR1wlMJyKxVHYrhnKoELSDxDd+2XImUkuWPEKk76H5FcM/gPFrEK1Tfw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.3.1.tgz", + "integrity": "sha512-uK7o3hHkK+naEobMSJ+2ySYyXtQkBxIH8Gn4MK9ciePjNV+Pf+PgY/W7iPzn2MTjl3stcYB5AlcTmPYw7AXDwA==", "dev": true, "dependencies": { - "debug": "^4.3.5", + "debug": "^4.3.6", "extract-zip": "^2.0.1", "progress": "^2.0.3", "proxy-agent": "^6.4.0", - "semver": "^7.6.2", + "semver": "^7.6.3", "tar-fs": "^3.0.6", "unbzip2-stream": "^1.4.3", "yargs": "^17.7.2" @@ -14701,9 +14701,9 @@ "dev": true }, "node_modules/@sparticuz/chromium": { - "version": "126.0.0", - "resolved": "https://registry.npmjs.org/@sparticuz/chromium/-/chromium-126.0.0.tgz", - "integrity": "sha512-qqGQmZQj3y0/V2osKswRHbzK4Qe80YHSDnpt6ac51hsY1bMDinMS9Q+eEmcL+re2MEhYN+ykoV9BY8Dyw1Lyjg==", + "version": "127.0.0", + "resolved": "https://registry.npmjs.org/@sparticuz/chromium/-/chromium-127.0.0.tgz", + "integrity": "sha512-3YdElfXb6kqcFtlgaArNZohhZ1gWAiWg5kPYIZbaoHFau7dHZvbYg3EEjeE30bYi6cfOnB8wVpluuasF8Y3QyQ==", "dependencies": { "follow-redirects": "^1.15.6", "tar-fs": "^3.0.6" @@ -19110,9 +19110,9 @@ } }, "node_modules/chromium-bidi": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.1.tgz", - "integrity": "sha512-kSxJRj0VgtUKz6nmzc2JPfyfJGzwzt65u7PqhPHtgGQUZLF5oG+ST6l6e5ONfStUMAlhSutFCjaGKllXZa16jA==", + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.4.tgz", + "integrity": "sha512-8zoq6ogmhQQkAKZVKO2ObFTl4uOkqoX1PlKQX3hZQ5E9cbUotcAb7h4pTNVAGGv8Z36PF3CtdOriEp/Rz82JqQ==", "dev": true, "dependencies": { "mitt": "3.0.1", @@ -21023,9 +21023,9 @@ } }, "node_modules/devtools-protocol": { - "version": "0.0.1299070", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1299070.tgz", - "integrity": "sha512-+qtL3eX50qsJ7c+qVyagqi7AWMoQCBGNfoyJZMwm/NSXVqLYbuitrWEEIzxfUmTNy7//Xe8yhMmQ+elj3uAqSg==", + "version": "0.0.1312386", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1312386.tgz", + "integrity": "sha512-DPnhUXvmvKT2dFA/j7B+riVLUt9Q6RKJlcppojL5CoRywJJKLDYnRlw0gTFKfgDPHP5E04UoB71SxoJlVZy8FA==", "dev": true }, "node_modules/diff": { @@ -33377,34 +33377,37 @@ "dev": true }, "node_modules/puppeteer": { - "version": "22.13.1", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-22.13.1.tgz", - "integrity": "sha512-PwXLDQK5u83Fm5A7TGMq+9BR7iHDJ8a3h21PSsh/E6VfhxiKYkU7+tvGZNSCap6k3pCNDd9oNteVBEctcBalmQ==", + "version": "23.1.1", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.1.1.tgz", + "integrity": "sha512-giN4Ikwl5hkkouH/dVyxIPTPslWuqZ8fjALdSw5Cvt+r0LuDpLdfPxRADlB75YJ2UjPZhgok+xYBYk8ffzv4MA==", "dev": true, "hasInstallScript": true, "dependencies": { - "@puppeteer/browsers": "2.2.4", + "@puppeteer/browsers": "2.3.1", + "chromium-bidi": "0.6.4", "cosmiconfig": "^9.0.0", - "devtools-protocol": "0.0.1299070", - "puppeteer-core": "22.13.1" + "devtools-protocol": "0.0.1312386", + "puppeteer-core": "23.1.1", + "typed-query-selector": "^2.12.0" }, "bin": { - "puppeteer": "lib/esm/puppeteer/node/cli.js" + "puppeteer": "lib/cjs/puppeteer/node/cli.js" }, "engines": { "node": ">=18" } }, "node_modules/puppeteer-core": { - "version": "22.13.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-22.13.1.tgz", - "integrity": "sha512-NmhnASYp51QPRCAf9n0OPxuPMmzkKd8+2sB9Q+BjwwCG25gz6iuNc3LQDWa+cH2tyivmJppLhNNFt6Q3HmoOpw==", + "version": "23.1.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.1.1.tgz", + "integrity": "sha512-OeTqNiYGF9qZtwZU4Yc88DDqFJs4TJ4rnK81jkillh6MwDeQodyisM9xe5lBmPhwiDy92s5J5DQtQLjCKHFQ3g==", "dev": true, "dependencies": { - "@puppeteer/browsers": "2.2.4", - "chromium-bidi": "0.6.1", - "debug": "^4.3.5", - "devtools-protocol": "0.0.1299070", + "@puppeteer/browsers": "2.3.1", + "chromium-bidi": "0.6.4", + "debug": "^4.3.6", + "devtools-protocol": "0.0.1312386", + "typed-query-selector": "^2.12.0", "ws": "^8.18.0" }, "engines": { @@ -37643,6 +37646,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/typed-query-selector": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.0.tgz", + "integrity": "sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==", + "dev": true + }, "node_modules/typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", diff --git a/package.json b/package.json index 07323f7a2de..4f7a66b8c32 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@fortawesome/react-fontawesome": "0.2.2", "@joi/date": "2.1.1", "@opensearch-project/opensearch": "2.11.0", - "@sparticuz/chromium": "126.0.0", + "@sparticuz/chromium": "127.0.0", "@uswds/uswds": "3.7.1", "aws-lambda": "1.0.7", "aws-xray-sdk": "3.9.0", @@ -339,8 +339,8 @@ "postcss-preset-env": "10.0.2", "prettier": "3.3.3", "prop-types": "15.8.1", - "puppeteer": "22.13.1", - "puppeteer-core": "22.13.1", + "puppeteer": "23.1.1", + "puppeteer-core": "23.1.1", "react-test-renderer": "18.3.1", "readline": "1.3.0", "s3rver": "github:20minutes/s3rver", diff --git a/web-api/runtimes/puppeteer/package-lock.json b/web-api/runtimes/puppeteer/package-lock.json index d858efda48b..cdb77425b03 100644 --- a/web-api/runtimes/puppeteer/package-lock.json +++ b/web-api/runtimes/puppeteer/package-lock.json @@ -9,9 +9,9 @@ "version": "0.0.2", "license": "CC0-1.0", "dependencies": { - "@sparticuz/chromium": "126.0.0", + "@sparticuz/chromium": "127.0.0", "pug": "3.0.3", - "puppeteer-core": "22.13.1", + "puppeteer-core": "23.1.1", "sass": "1.77.8" }, "engines": { @@ -64,15 +64,15 @@ } }, "node_modules/@puppeteer/browsers": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.2.4.tgz", - "integrity": "sha512-BdG2qiI1dn89OTUUsx2GZSpUzW+DRffR1wlMJyKxVHYrhnKoELSDxDd+2XImUkuWPEKk76H5FcM/gPFrEK1Tfw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.3.1.tgz", + "integrity": "sha512-uK7o3hHkK+naEobMSJ+2ySYyXtQkBxIH8Gn4MK9ciePjNV+Pf+PgY/W7iPzn2MTjl3stcYB5AlcTmPYw7AXDwA==", "dependencies": { - "debug": "^4.3.5", + "debug": "^4.3.6", "extract-zip": "^2.0.1", "progress": "^2.0.3", "proxy-agent": "^6.4.0", - "semver": "^7.6.2", + "semver": "^7.6.3", "tar-fs": "^3.0.6", "unbzip2-stream": "^1.4.3", "yargs": "^17.7.2" @@ -85,9 +85,9 @@ } }, "node_modules/@sparticuz/chromium": { - "version": "126.0.0", - "resolved": "https://registry.npmjs.org/@sparticuz/chromium/-/chromium-126.0.0.tgz", - "integrity": "sha512-qqGQmZQj3y0/V2osKswRHbzK4Qe80YHSDnpt6ac51hsY1bMDinMS9Q+eEmcL+re2MEhYN+ykoV9BY8Dyw1Lyjg==", + "version": "127.0.0", + "resolved": "https://registry.npmjs.org/@sparticuz/chromium/-/chromium-127.0.0.tgz", + "integrity": "sha512-3YdElfXb6kqcFtlgaArNZohhZ1gWAiWg5kPYIZbaoHFau7dHZvbYg3EEjeE30bYi6cfOnB8wVpluuasF8Y3QyQ==", "dependencies": { "follow-redirects": "^1.15.6", "tar-fs": "^3.0.6" @@ -102,9 +102,9 @@ "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" }, "node_modules/@types/node": { - "version": "22.4.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.0.tgz", - "integrity": "sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==", + "version": "22.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", + "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", "optional": true, "dependencies": { "undici-types": "~6.19.2" @@ -399,9 +399,9 @@ } }, "node_modules/chromium-bidi": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.1.tgz", - "integrity": "sha512-kSxJRj0VgtUKz6nmzc2JPfyfJGzwzt65u7PqhPHtgGQUZLF5oG+ST6l6e5ONfStUMAlhSutFCjaGKllXZa16jA==", + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.4.tgz", + "integrity": "sha512-8zoq6ogmhQQkAKZVKO2ObFTl4uOkqoX1PlKQX3hZQ5E9cbUotcAb7h4pTNVAGGv8Z36PF3CtdOriEp/Rz82JqQ==", "dependencies": { "mitt": "3.0.1", "urlpattern-polyfill": "10.0.0", @@ -505,9 +505,9 @@ } }, "node_modules/devtools-protocol": { - "version": "0.0.1299070", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1299070.tgz", - "integrity": "sha512-+qtL3eX50qsJ7c+qVyagqi7AWMoQCBGNfoyJZMwm/NSXVqLYbuitrWEEIzxfUmTNy7//Xe8yhMmQ+elj3uAqSg==" + "version": "0.0.1312386", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1312386.tgz", + "integrity": "sha512-DPnhUXvmvKT2dFA/j7B+riVLUt9Q6RKJlcppojL5CoRywJJKLDYnRlw0gTFKfgDPHP5E04UoB71SxoJlVZy8FA==" }, "node_modules/doctypes": { "version": "1.1.0", @@ -1322,14 +1322,15 @@ } }, "node_modules/puppeteer-core": { - "version": "22.13.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-22.13.1.tgz", - "integrity": "sha512-NmhnASYp51QPRCAf9n0OPxuPMmzkKd8+2sB9Q+BjwwCG25gz6iuNc3LQDWa+cH2tyivmJppLhNNFt6Q3HmoOpw==", - "dependencies": { - "@puppeteer/browsers": "2.2.4", - "chromium-bidi": "0.6.1", - "debug": "^4.3.5", - "devtools-protocol": "0.0.1299070", + "version": "23.1.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.1.1.tgz", + "integrity": "sha512-OeTqNiYGF9qZtwZU4Yc88DDqFJs4TJ4rnK81jkillh6MwDeQodyisM9xe5lBmPhwiDy92s5J5DQtQLjCKHFQ3g==", + "dependencies": { + "@puppeteer/browsers": "2.3.1", + "chromium-bidi": "0.6.4", + "debug": "^4.3.6", + "devtools-protocol": "0.0.1312386", + "typed-query-selector": "^2.12.0", "ws": "^8.18.0" }, "engines": { @@ -1602,6 +1603,11 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" }, + "node_modules/typed-query-selector": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.0.tgz", + "integrity": "sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==" + }, "node_modules/unbzip2-stream": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", @@ -1612,9 +1618,9 @@ } }, "node_modules/undici-types": { - "version": "6.19.6", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", - "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "optional": true }, "node_modules/universalify": { diff --git a/web-api/runtimes/puppeteer/package.json b/web-api/runtimes/puppeteer/package.json index 1e2ad32ff75..221a59377b6 100644 --- a/web-api/runtimes/puppeteer/package.json +++ b/web-api/runtimes/puppeteer/package.json @@ -8,9 +8,9 @@ "npm": ">=10.2.4 <11.0.0" }, "dependencies": { - "@sparticuz/chromium": "126.0.0", + "@sparticuz/chromium": "127.0.0", "pug": "3.0.3", - "puppeteer-core": "22.13.1", + "puppeteer-core": "23.1.1", "sass": "1.77.8" }, "scripts": {}, From ae1e9176f50ffc1f297a8e16ea156358e0699d9b Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 22 Aug 2024 14:27:54 -0500 Subject: [PATCH 449/523] deps: update terraform version --- Dockerfile | 2 +- scripts/verify-terraform-version.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 91343bb61fa..02e48174640 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,7 +42,7 @@ RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.17.30.zip" -o " ./aws/install && \ rm -rf awscliv2.zip -RUN wget -q -O terraform.zip https://releases.hashicorp.com/terraform/1.9.4/terraform_1.9.4_linux_amd64.zip && \ +RUN wget -q -O terraform.zip https://releases.hashicorp.com/terraform/1.9.5/terraform_1.9.5_linux_amd64.zip && \ unzip -o terraform.zip terraform && \ rm terraform.zip && \ cp terraform /usr/local/bin/ diff --git a/scripts/verify-terraform-version.sh b/scripts/verify-terraform-version.sh index 3fee6bf7376..27bf9bd3a41 100755 --- a/scripts/verify-terraform-version.sh +++ b/scripts/verify-terraform-version.sh @@ -2,7 +2,7 @@ tf_version=$(terraform --version) -if [[ ${tf_version} != *"1.9.4"* ]]; then - echo "Please set your terraform version to 1.9.4 before deploying." +if [[ ${tf_version} != *"1.9.5"* ]]; then + echo "Please set your terraform version to 1.9.5 before deploying." exit 1 fi From 3198a4affa36f208e3c984b8afc289719080ecd5 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 22 Aug 2024 14:31:21 -0500 Subject: [PATCH 450/523] deps: dockerfile upgrades: terraform, cypress, aws cli deps: increment container version --- .circleci/config.yml | 2 +- Dockerfile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2cb918b3207..0ce15e18ce9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: git-shallow-clone: guitarrapc/git-shallow-clone@2.8.0 -efcms-docker-image: &efcms-docker-image $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/ef-cms-us-east-1:4.3.7 +efcms-docker-image: &efcms-docker-image $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/ef-cms-us-east-1:4.3.8 parameters: run_build_and_deploy: diff --git a/Dockerfile b/Dockerfile index 02e48174640..dec65e5cd61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Note: node-20.14.0-chrome-125.0.* is debian 12.5 (bookworm) -FROM cypress/browsers:node-20.16.0-chrome-127.0.6533.88-1-ff-128.0.3-edge-127.0.2651.74-1 +FROM cypress/browsers:node-20.16.0-chrome-127.0.6533.119-1-ff-129.0.1-edge-127.0.2651.98-1 WORKDIR /home/app @@ -37,7 +37,7 @@ RUN apt-get install -y build-essential RUN apt-get install -y libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 -RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.17.30.zip" -o "awscliv2.zip" && \ +RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.17.36.zip" -o "awscliv2.zip" && \ unzip awscliv2.zip && \ ./aws/install && \ rm -rf awscliv2.zip From 0d62a2b21013f2a525674a0addcfb1b26725da1e Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 22 Aug 2024 15:00:05 -0500 Subject: [PATCH 451/523] deps: terraform provider version --- shared/admin-tools/glue/glue_migrations/main.tf | 2 +- shared/admin-tools/glue/remote_role/main.tf | 2 +- .../terraform/applyables/account-specific/account-specific.tf | 2 +- web-api/terraform/applyables/allColors/allColors.tf | 2 +- web-api/terraform/applyables/blue/blue.tf | 2 +- web-api/terraform/applyables/glue-cron/glue-cron-applyable.tf | 2 +- web-api/terraform/applyables/green/green.tf | 2 +- .../applyables/migration-cron/migration-cron-applyable.tf | 2 +- web-api/terraform/applyables/migration/migration-applyable.tf | 2 +- .../terraform/applyables/reindex-cron/reindex-cron-applyable.tf | 2 +- .../switch-colors-cron/switch-colors-cron-applyable.tf | 2 +- .../wait-for-workflow/wait-for-workflow-cron-applyable.tf | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/shared/admin-tools/glue/glue_migrations/main.tf b/shared/admin-tools/glue/glue_migrations/main.tf index 2c4e0d2921d..e2f62af74f1 100644 --- a/shared/admin-tools/glue/glue_migrations/main.tf +++ b/shared/admin-tools/glue/glue_migrations/main.tf @@ -7,7 +7,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/shared/admin-tools/glue/remote_role/main.tf b/shared/admin-tools/glue/remote_role/main.tf index e90e4ba76ea..7e21e12f031 100644 --- a/shared/admin-tools/glue/remote_role/main.tf +++ b/shared/admin-tools/glue/remote_role/main.tf @@ -7,7 +7,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/web-api/terraform/applyables/account-specific/account-specific.tf b/web-api/terraform/applyables/account-specific/account-specific.tf index 2ee73cddd87..245b15fdfc0 100644 --- a/web-api/terraform/applyables/account-specific/account-specific.tf +++ b/web-api/terraform/applyables/account-specific/account-specific.tf @@ -16,7 +16,7 @@ terraform { backend "s3" {} required_providers { - aws = "5.63.0" + aws = "5.63.1" opensearch = { source = "opensearch-project/opensearch" version = "2.2.0" diff --git a/web-api/terraform/applyables/allColors/allColors.tf b/web-api/terraform/applyables/allColors/allColors.tf index 416ff6f5750..3854df0e997 100644 --- a/web-api/terraform/applyables/allColors/allColors.tf +++ b/web-api/terraform/applyables/allColors/allColors.tf @@ -17,7 +17,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/web-api/terraform/applyables/blue/blue.tf b/web-api/terraform/applyables/blue/blue.tf index ada2a903d03..1a28e041279 100644 --- a/web-api/terraform/applyables/blue/blue.tf +++ b/web-api/terraform/applyables/blue/blue.tf @@ -18,7 +18,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/web-api/terraform/applyables/glue-cron/glue-cron-applyable.tf b/web-api/terraform/applyables/glue-cron/glue-cron-applyable.tf index e247b94287e..2b6968d69f2 100644 --- a/web-api/terraform/applyables/glue-cron/glue-cron-applyable.tf +++ b/web-api/terraform/applyables/glue-cron/glue-cron-applyable.tf @@ -7,7 +7,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/web-api/terraform/applyables/green/green.tf b/web-api/terraform/applyables/green/green.tf index 2c6733c8dbb..c216d47a61c 100644 --- a/web-api/terraform/applyables/green/green.tf +++ b/web-api/terraform/applyables/green/green.tf @@ -18,7 +18,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/web-api/terraform/applyables/migration-cron/migration-cron-applyable.tf b/web-api/terraform/applyables/migration-cron/migration-cron-applyable.tf index 55b53b3f66d..b15a70a986f 100644 --- a/web-api/terraform/applyables/migration-cron/migration-cron-applyable.tf +++ b/web-api/terraform/applyables/migration-cron/migration-cron-applyable.tf @@ -7,7 +7,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/web-api/terraform/applyables/migration/migration-applyable.tf b/web-api/terraform/applyables/migration/migration-applyable.tf index 463590ccd65..0fa0921efb8 100644 --- a/web-api/terraform/applyables/migration/migration-applyable.tf +++ b/web-api/terraform/applyables/migration/migration-applyable.tf @@ -7,7 +7,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/web-api/terraform/applyables/reindex-cron/reindex-cron-applyable.tf b/web-api/terraform/applyables/reindex-cron/reindex-cron-applyable.tf index 1ac3a95eda4..4e41970283c 100644 --- a/web-api/terraform/applyables/reindex-cron/reindex-cron-applyable.tf +++ b/web-api/terraform/applyables/reindex-cron/reindex-cron-applyable.tf @@ -7,7 +7,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/web-api/terraform/applyables/switch-colors-cron/switch-colors-cron-applyable.tf b/web-api/terraform/applyables/switch-colors-cron/switch-colors-cron-applyable.tf index ed71f2fb7a8..5987d1dd6b6 100644 --- a/web-api/terraform/applyables/switch-colors-cron/switch-colors-cron-applyable.tf +++ b/web-api/terraform/applyables/switch-colors-cron/switch-colors-cron-applyable.tf @@ -7,7 +7,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } diff --git a/web-api/terraform/applyables/wait-for-workflow/wait-for-workflow-cron-applyable.tf b/web-api/terraform/applyables/wait-for-workflow/wait-for-workflow-cron-applyable.tf index 4ffbfe30cd5..d87de1bbe1f 100644 --- a/web-api/terraform/applyables/wait-for-workflow/wait-for-workflow-cron-applyable.tf +++ b/web-api/terraform/applyables/wait-for-workflow/wait-for-workflow-cron-applyable.tf @@ -7,7 +7,7 @@ terraform { } required_providers { - aws = "5.63.0" + aws = "5.63.1" } } From 4e581531fb3177c3b1028dcc2f07fd986bd50f7f Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 22 Aug 2024 15:29:10 -0500 Subject: [PATCH 452/523] deps: revert ts upgrade deps: revert ts --- docs/dependency-updates.md | 4 ++++ package-lock.json | 21 ++++----------------- package.json | 2 +- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/docs/dependency-updates.md b/docs/dependency-updates.md index 530af4114a2..9a570612ae7 100644 --- a/docs/dependency-updates.md +++ b/docs/dependency-updates.md @@ -94,6 +94,10 @@ See: https://github.com/jsx-eslint/eslint-plugin-react/issues/3699 ### ws, 3rd party dependency of Cerebral - When running npm audit, you'll see a high severity issue with ws, 'affected by a DoS when handling a request with many HTTP headers - https://github.com/advisories/GHSA-3h5v-q93c-6h6q'. This doesn't affect us as the vulnerability is on the server side and we're not using this package on the server. We tried to override this to 5.2.4 and 8.18.0 and weren't able to make this work as import paths have changed. In the mean time, we recommend skipping this issue. We could always fork the cerebral repo in the future if needed. +### typescript +- We currently run version 5.4.5; upon upgrading to version 5.5.3 on 6 July 2024, we ran into a series of issues. While the tests passed, we ran into issues linting and type-checking. The recurring issue was a RangeError: Maximum call stack size exceeded, which occurred with our npx tsc command as well as our lint-staged command. We noticed related issues in Github around this release. In order to prevent delaying other devs and ensure the remaining dependency updates are completed, we decided to hold on this update till version 5.5.3+ and/or we can spend more time to determine why this is occurring. +- Update 12 July 2024: There are two new related open issues (https://github.com/microsoft/TypeScript/issues/59255 and https://github.com/microsoft/TypeScript/issues/59253), which provides further evidence for a TS bug. TS is still on version 5.5.3. + ## Incrementing the Node Cache Key Version It's rare to need modify cache key. One reason you may want to do so is if a package fails to install properly, and CircleCI, unaware of the failed installation, stores the corrupted cache. In this case, we will need to increment the cache key version so that CircleCI is forced to reinstall the node dependencies and save them using the new key. To update the cache key, locate `vX-npm` and `vX-cypress` (where X represents the current cache key version) in the config.yml file, and then increment the identified version. diff --git a/package-lock.json b/package-lock.json index 9b34d05eed8..07b23a997ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -218,7 +218,7 @@ "ts-loader": "9.5.1", "ts-node": "10.9.2", "tsconfig-paths": "4.2.0", - "typescript": "5.5.4", + "typescript": "5.4.5", "utf8": "3.0.0" }, "engines": { @@ -15415,19 +15415,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@tapjs/test/node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/@tapjs/typescript": { "version": "1.4.13", "resolved": "https://registry.npmjs.org/@tapjs/typescript/-/typescript-1.4.13.tgz", @@ -37661,9 +37648,9 @@ } }, "node_modules/typescript": { - "version": "5.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", - "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 4f7a66b8c32..da5588e4996 100644 --- a/package.json +++ b/package.json @@ -360,7 +360,7 @@ "ts-loader": "9.5.1", "ts-node": "10.9.2", "tsconfig-paths": "4.2.0", - "typescript": "5.5.4", + "typescript": "5.4.5", "utf8": "3.0.0" } } From 48146e229f7d4aa51c6bb4818c191a87ce8a0107 Mon Sep 17 00:00:00 2001 From: Christopher Bisom Date: Fri, 23 Aug 2024 09:36:00 -0400 Subject: [PATCH 453/523] 10226-bug: fix accessibility issue and extract PillButton component --- web-client/src/styles/buttons.scss | 2 +- web-client/src/styles/custom.scss | 6 + web-client/src/ustc-ui/Button/PillButton.tsx | 22 ++++ .../CustomCaseReport/CustomCaseReport.tsx | 112 +++++++----------- 4 files changed, 75 insertions(+), 67 deletions(-) create mode 100644 web-client/src/ustc-ui/Button/PillButton.tsx diff --git a/web-client/src/styles/buttons.scss b/web-client/src/styles/buttons.scss index dd32b7688c3..527330a0452 100644 --- a/web-client/src/styles/buttons.scss +++ b/web-client/src/styles/buttons.scss @@ -70,7 +70,7 @@ button:disabled { } } - &.ustc-button--unstyled { + &.ustc-button--unstyled { padding: 0.75rem 0; line-height: normal; text-align: center; diff --git a/web-client/src/styles/custom.scss b/web-client/src/styles/custom.scss index 1fad9c5aee8..c87c44e7a45 100644 --- a/web-client/src/styles/custom.scss +++ b/web-client/src/styles/custom.scss @@ -2199,6 +2199,12 @@ button.change-scanner-button { color: $color-white; font-weight: $font-semibold; text-align: center; + + button { + border: none; + background: none; + color: white; + } } .cursor-pointer { diff --git a/web-client/src/ustc-ui/Button/PillButton.tsx b/web-client/src/ustc-ui/Button/PillButton.tsx new file mode 100644 index 00000000000..adeb64671ec --- /dev/null +++ b/web-client/src/ustc-ui/Button/PillButton.tsx @@ -0,0 +1,22 @@ +import { Icon } from '../../ustc-ui/Icon/Icon'; +import React from 'react'; + +interface PillButtonProps { + text: string; + onRemove: () => void; +} + +export const PillButton = ({ onRemove, text }: PillButtonProps) => { + return ( + + {text} + + + ); +}; diff --git a/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx b/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx index 92db9667ad5..f6507f691c2 100644 --- a/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx +++ b/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx @@ -7,6 +7,7 @@ import { DateRangePickerComponent } from '../../ustc-ui/DateInput/DateRangePicke import { ErrorNotification } from '../ErrorNotification'; import { Icon } from '../../ustc-ui/Icon/Icon'; import { Paginator } from '../../ustc-ui/Pagination/Paginator'; +import { PillButton } from '@web-client/ustc-ui/Button/PillButton'; import { SelectSearch } from '../../ustc-ui/Select/SelectSearch'; import { SuccessNotification } from '../SuccessNotification'; import { connect } from '@web-client/presenter/shared.cerebral'; @@ -359,87 +360,66 @@ export const CustomCaseReport = connect(
{customCaseReportFilters.caseStatuses.map(status => ( - - {status} - { + { + setCustomCaseReportFiltersSequence({ + caseStatuses: { + action: 'remove', + caseStatus: status, + }, + }); + }} + /> + ))} + {customCaseReportFilters.caseTypes.map(caseType => { + return ( + { setCustomCaseReportFiltersSequence({ - caseStatuses: { + caseTypes: { action: 'remove', - caseStatus: status, + caseType, }, }); }} /> - - ))} - - {customCaseReportFilters.caseTypes.map(caseType => { - return ( - - {caseType} - { - setCustomCaseReportFiltersSequence({ - caseTypes: { - action: 'remove', - caseType, - }, - }); - }} - /> - ); })} {customCaseReportFilters.judges.map(judge => { return ( - - {judge} - { - setCustomCaseReportFiltersSequence({ - judges: { - action: 'remove', - judge, - }, - }); - }} - /> - + { + setCustomCaseReportFiltersSequence({ + judges: { + action: 'remove', + judge, + }, + }); + }} + /> ); })} {customCaseReportFilters.preferredTrialCities.map(city => { return ( - - {city} - { - setCustomCaseReportFiltersSequence({ - preferredTrialCities: { - action: 'remove', - preferredTrialCity: city, - }, - }); - }} - /> - + { + setCustomCaseReportFiltersSequence({ + preferredTrialCities: { + action: 'remove', + preferredTrialCity: city, + }, + }); + }} + /> ); })}
From 394a191a5134776fbc481f7beaaf01a3264b2675 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 23 Aug 2024 09:01:19 -0500 Subject: [PATCH 454/523] deps: AWS type updates --- package-lock.json | 1340 ++++++++--------- package.json | 54 +- .../ses/sendBulkTemplatedEmail.test.ts | 2 + 3 files changed, 699 insertions(+), 697 deletions(-) diff --git a/package-lock.json b/package-lock.json index 07b23a997ae..adbb824f0a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,34 +12,34 @@ "dependencies": { "@18f/us-federal-holidays": "4.0.0", "@aws-crypto/sha256-browser": "5.2.0", - "@aws-sdk/client-api-gateway": "3.635.0", - "@aws-sdk/client-apigatewaymanagementapi": "3.635.0", - "@aws-sdk/client-apigatewayv2": "3.635.0", - "@aws-sdk/client-cloudfront": "3.635.0", - "@aws-sdk/client-cloudwatch": "3.635.0", - "@aws-sdk/client-cloudwatch-logs": "3.635.0", - "@aws-sdk/client-cognito-identity-provider": "3.635.0", - "@aws-sdk/client-dynamodb": "3.635.0", - "@aws-sdk/client-dynamodb-streams": "3.635.0", - "@aws-sdk/client-glue": "3.636.0", - "@aws-sdk/client-lambda": "3.636.0", - "@aws-sdk/client-opensearch": "3.635.0", - "@aws-sdk/client-route-53": "3.635.0", - "@aws-sdk/client-s3": "3.635.0", - "@aws-sdk/client-ses": "3.636.0", - "@aws-sdk/client-sns": "3.635.0", - "@aws-sdk/client-sqs": "3.635.0", - "@aws-sdk/client-ssm": "3.635.0", + "@aws-sdk/client-api-gateway": "3.637.0", + "@aws-sdk/client-apigatewaymanagementapi": "3.637.0", + "@aws-sdk/client-apigatewayv2": "3.637.0", + "@aws-sdk/client-cloudfront": "3.637.0", + "@aws-sdk/client-cloudwatch": "3.637.0", + "@aws-sdk/client-cloudwatch-logs": "3.637.0", + "@aws-sdk/client-cognito-identity-provider": "3.637.0", + "@aws-sdk/client-dynamodb": "3.637.0", + "@aws-sdk/client-dynamodb-streams": "3.637.0", + "@aws-sdk/client-glue": "3.637.0", + "@aws-sdk/client-lambda": "3.637.0", + "@aws-sdk/client-opensearch": "3.637.0", + "@aws-sdk/client-route-53": "3.637.0", + "@aws-sdk/client-s3": "3.637.0", + "@aws-sdk/client-ses": "3.637.0", + "@aws-sdk/client-sns": "3.637.0", + "@aws-sdk/client-sqs": "3.637.0", + "@aws-sdk/client-ssm": "3.637.0", "@aws-sdk/cloudfront-signer": "3.621.0", - "@aws-sdk/credential-provider-node": "3.635.0", - "@aws-sdk/lib-dynamodb": "3.635.0", - "@aws-sdk/lib-storage": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", + "@aws-sdk/lib-dynamodb": "3.637.0", + "@aws-sdk/lib-storage": "3.637.0", "@aws-sdk/node-http-handler": "3.374.0", "@aws-sdk/protocol-http": "3.374.0", - "@aws-sdk/s3-presigned-post": "3.635.0", - "@aws-sdk/s3-request-presigner": "3.635.0", + "@aws-sdk/s3-presigned-post": "3.637.0", + "@aws-sdk/s3-request-presigner": "3.637.0", "@aws-sdk/signature-v4": "3.374.0", - "@aws-sdk/util-dynamodb": "3.635.0", + "@aws-sdk/util-dynamodb": "3.637.0", "@cerebral/react": "4.2.1", "@fortawesome/fontawesome-svg-core": "1.2.36", "@fortawesome/free-regular-svg-icons": "5.15.4", @@ -51,7 +51,7 @@ "@uswds/uswds": "3.7.1", "aws-lambda": "1.0.7", "aws-xray-sdk": "3.9.0", - "axios": "1.7.4", + "axios": "1.7.5", "broadcast-channel": "7.0.0", "canvas": "2.11.2", "cerebral": "5.2.1", @@ -102,8 +102,8 @@ "winston": "3.14.2" }, "devDependencies": { - "@aws-sdk/client-iam": "3.635.0", - "@aws-sdk/client-secrets-manager": "3.635.0", + "@aws-sdk/client-iam": "3.637.0", + "@aws-sdk/client-secrets-manager": "3.637.0", "@babel/cli": "7.24.8", "@babel/core": "7.25.2", "@babel/eslint-parser": "7.25.1", @@ -807,24 +807,24 @@ } }, "node_modules/@aws-sdk/client-api-gateway": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-api-gateway/-/client-api-gateway-3.635.0.tgz", - "integrity": "sha512-m9DG4OB0HFm1LMV2b6iz2nCIsOjwEgciy3M02/sNeKLSdUCQZsdUQKXIU7aGIZncZgn5CiV+UN+HvrdOlTYifw==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-api-gateway/-/client-api-gateway-3.637.0.tgz", + "integrity": "sha512-jAdpZj8siCmut2P7rVLZASUmBOQbY2AB7hIlVmlpoZ9TC2mGYMaXbK/swegWS7nf5LyO6xrgcl/463TtR3IbrA==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", "@aws-sdk/middleware-sdk-api-gateway": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -860,21 +860,21 @@ } }, "node_modules/@aws-sdk/client-api-gateway/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -908,26 +908,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-api-gateway/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -982,12 +982,12 @@ } }, "node_modules/@aws-sdk/client-api-gateway/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -997,9 +997,9 @@ } }, "node_modules/@aws-sdk/client-api-gateway/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -1023,23 +1023,23 @@ } }, "node_modules/@aws-sdk/client-apigatewaymanagementapi": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-apigatewaymanagementapi/-/client-apigatewaymanagementapi-3.635.0.tgz", - "integrity": "sha512-WTq1SA2SoRSbMAHrTRTdHokW7U25bVtTe/eeTg/ZJovdbSz6InUc6WosOQ1JTouu3iOLDO4FFElp3pAySvs6+w==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-apigatewaymanagementapi/-/client-apigatewaymanagementapi-3.637.0.tgz", + "integrity": "sha512-MN3b4T4icjfCxNi9iPh3ERsKBzEu4ua3Hoj65MX7hVrnsaPebjZXGw7YAJPe/ugV4SKPyrGAyuno0LLaoFw55g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1074,21 +1074,21 @@ } }, "node_modules/@aws-sdk/client-apigatewaymanagementapi/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1122,26 +1122,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-apigatewaymanagementapi/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1196,12 +1196,12 @@ } }, "node_modules/@aws-sdk/client-apigatewaymanagementapi/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -1211,9 +1211,9 @@ } }, "node_modules/@aws-sdk/client-apigatewaymanagementapi/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -1237,23 +1237,23 @@ } }, "node_modules/@aws-sdk/client-apigatewayv2": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-apigatewayv2/-/client-apigatewayv2-3.635.0.tgz", - "integrity": "sha512-1EvlJm76x+GIrn6xdSaHus21rwGBAqlaBRpjLu06Iyqtkhtl2FzzYRYyy/rY/kznF5pmtnRhQVJPY4QU+vUUTw==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-apigatewayv2/-/client-apigatewayv2-3.637.0.tgz", + "integrity": "sha512-mnqulbdo5t8W9ScFzfsLL5RPE96iSHWB+eAoIllztu+oW1HrRY4w/HcKqEz+5hK4FS+CPaH08ZwCAxVkRJ9biA==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1289,21 +1289,21 @@ } }, "node_modules/@aws-sdk/client-apigatewayv2/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1337,26 +1337,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-apigatewayv2/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1411,12 +1411,12 @@ } }, "node_modules/@aws-sdk/client-apigatewayv2/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -1426,9 +1426,9 @@ } }, "node_modules/@aws-sdk/client-apigatewayv2/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -1452,23 +1452,23 @@ } }, "node_modules/@aws-sdk/client-cloudfront": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudfront/-/client-cloudfront-3.635.0.tgz", - "integrity": "sha512-JHFSh5g/3nj3/Z6Zwll6v2Sgooj5XS9mncmb14BLhIIKg8XJDXMlxsykgCpH7Kf/zpVn3+oufEuz41iX5xQDzQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudfront/-/client-cloudfront-3.637.0.tgz", + "integrity": "sha512-yuKqFTRlRHAA5mVds/ufO8n6ENcCFAW0D6nXldQcMOCXIuz1UQRE5qyEwajIdDGtFnyeZVf5fWRMx3ylWC7h0Q==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@aws-sdk/xml-builder": "3.609.0", @@ -1506,21 +1506,21 @@ } }, "node_modules/@aws-sdk/client-cloudfront/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1554,26 +1554,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-cloudfront/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1628,12 +1628,12 @@ } }, "node_modules/@aws-sdk/client-cloudfront/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -1643,9 +1643,9 @@ } }, "node_modules/@aws-sdk/client-cloudfront/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -1669,23 +1669,23 @@ } }, "node_modules/@aws-sdk/client-cloudwatch": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudwatch/-/client-cloudwatch-3.635.0.tgz", - "integrity": "sha512-49JkjJncrKNwHlHA/KXbeHiHZ1svD38SYuPMcnOXAizqxRwKldyahooFCAaR6LlFzjSktDcABmCdj+IpV4XNWA==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudwatch/-/client-cloudwatch-3.637.0.tgz", + "integrity": "sha512-S6UcU3vCKOAUVLCXTabyUMWAr1e1kHn7Hcy6VZ4sxxu5hQqbSGiety3vrjmPTALlV5rmhu3N+hlRZt2TRXwDRg==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1722,23 +1722,23 @@ } }, "node_modules/@aws-sdk/client-cloudwatch-logs": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudwatch-logs/-/client-cloudwatch-logs-3.635.0.tgz", - "integrity": "sha512-M2SGf0B/WmHYNxUhUWKIYI5NW4Si7cyokB6Lt3RtDof3WVHA8L0LLl+EEo1URUkpxH8/F8VH2fTES7ODm2c+7g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cloudwatch-logs/-/client-cloudwatch-logs-3.637.0.tgz", + "integrity": "sha512-JK9BgR3zHo/3VHSMO5ovDgk95TGEiY1DnlJ1AIPl/t6i87gZojurQFlbVuwzLDMZGoFfH0FuAJTW2+sH6nzh8A==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1777,21 +1777,21 @@ } }, "node_modules/@aws-sdk/client-cloudwatch-logs/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1825,26 +1825,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-cloudwatch-logs/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -1899,12 +1899,12 @@ } }, "node_modules/@aws-sdk/client-cloudwatch-logs/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -1914,9 +1914,9 @@ } }, "node_modules/@aws-sdk/client-cloudwatch-logs/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -1952,21 +1952,21 @@ } }, "node_modules/@aws-sdk/client-cloudwatch/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2000,26 +2000,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-cloudwatch/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2074,12 +2074,12 @@ } }, "node_modules/@aws-sdk/client-cloudwatch/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -2089,9 +2089,9 @@ } }, "node_modules/@aws-sdk/client-cloudwatch/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -2167,23 +2167,23 @@ } }, "node_modules/@aws-sdk/client-cognito-identity-provider": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity-provider/-/client-cognito-identity-provider-3.635.0.tgz", - "integrity": "sha512-PeO+uHkTc73qbaLqLgwEtk32wTAuAjI3KUILRoN40hLpbeKEKjymkL7V8NEP6itePlfjA4Gac1yG29Tzw/dTkg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity-provider/-/client-cognito-identity-provider-3.637.0.tgz", + "integrity": "sha512-udgyXL5ZQPTcXbzCq4plPxCEnYWGnC5+nWpCQAOcCACpA0rtQQ9OKabq/SiNO+6PVUMQFKRrZq6LS2p76mjl1w==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2218,21 +2218,21 @@ } }, "node_modules/@aws-sdk/client-cognito-identity-provider/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2266,26 +2266,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-cognito-identity-provider/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2340,12 +2340,12 @@ } }, "node_modules/@aws-sdk/client-cognito-identity-provider/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -2355,9 +2355,9 @@ } }, "node_modules/@aws-sdk/client-cognito-identity-provider/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -2417,24 +2417,24 @@ } }, "node_modules/@aws-sdk/client-dynamodb": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb/-/client-dynamodb-3.635.0.tgz", - "integrity": "sha512-Nn4aFYkmEKmGqzw+KJHZEDblQZRUx0WcZCIz46iGQO8DXau3dmeRfJEO6HmUpewkvuVP0tQudv1CjgxqnNoKlQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb/-/client-dynamodb-3.637.0.tgz", + "integrity": "sha512-zUneT0yLgJjC69yry2fgYVWkv68OeV3amWaDXHirA8yJgygyc7tBLo+sQmtHczmKt8dBD9bU3OWpbAbtpF9Esw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-endpoint-discovery": "3.620.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2471,23 +2471,23 @@ } }, "node_modules/@aws-sdk/client-dynamodb-streams": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb-streams/-/client-dynamodb-streams-3.635.0.tgz", - "integrity": "sha512-Fg1uJ3m1+lhrxOclLIg1nfSngVzngOKHMFkSuz9iSGtVJVRAQu7rmTiD+GcTNCWOqnleBlMdd2K298I6irtH1w==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-dynamodb-streams/-/client-dynamodb-streams-3.637.0.tgz", + "integrity": "sha512-WBh9Dn2Fm37SAFvWaa2or7NSuxNLJ62cFEVHX+SrKzJxhXSWYs24BoHW4XxMb6jiT0ka3GMctu//7Y1//MBU3A==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2522,21 +2522,21 @@ } }, "node_modules/@aws-sdk/client-dynamodb-streams/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2570,26 +2570,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-dynamodb-streams/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2644,12 +2644,12 @@ } }, "node_modules/@aws-sdk/client-dynamodb-streams/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -2659,9 +2659,9 @@ } }, "node_modules/@aws-sdk/client-dynamodb-streams/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -2685,21 +2685,21 @@ } }, "node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2733,26 +2733,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2807,12 +2807,12 @@ } }, "node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -2822,9 +2822,9 @@ } }, "node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -2860,23 +2860,23 @@ } }, "node_modules/@aws-sdk/client-glue": { - "version": "3.636.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-glue/-/client-glue-3.636.0.tgz", - "integrity": "sha512-xFm/rXjlBDB/IoeeZy/pMXLTwsDWSt8ILQeHNzdBAhmyGEP2xkxT6f54IkxQgosrNpoosfBNANhRNjjlq0xWqQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-glue/-/client-glue-3.637.0.tgz", + "integrity": "sha512-QhkixUI3eTittXRBv43qfh9hEjIPc1IoBmqKAzn8dSA2choX3XxpLvDLKbyv26yCq5QnZIiZ5SzOtr5pTJG/BA==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2911,21 +2911,21 @@ } }, "node_modules/@aws-sdk/client-glue/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -2959,26 +2959,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-glue/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3033,12 +3033,12 @@ } }, "node_modules/@aws-sdk/client-glue/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -3048,9 +3048,9 @@ } }, "node_modules/@aws-sdk/client-glue/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -3074,24 +3074,24 @@ } }, "node_modules/@aws-sdk/client-iam": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-iam/-/client-iam-3.635.0.tgz", - "integrity": "sha512-sflTv6XcwO5UX+U9x31+T6TBEgVIzG61giLgRV51kkFGErni++GpxUcc6O1mpDwb3jpbntJf7QPjrkkj9wsTPA==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-iam/-/client-iam-3.637.0.tgz", + "integrity": "sha512-mo1gCm3yayuiFPCQkY5i5wbL6jjgCprpAfeMP5zFOcDsr7BqX9ijTrRzK+dx0SwiTdRKOW6zJaDiWA1UZgb60A==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3127,22 +3127,22 @@ } }, "node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3176,27 +3176,27 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3252,13 +3252,13 @@ } }, "node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dev": true, "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -3268,9 +3268,9 @@ } }, "node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dev": true, "dependencies": { "@aws-sdk/types": "3.609.0", @@ -3296,23 +3296,23 @@ } }, "node_modules/@aws-sdk/client-lambda": { - "version": "3.636.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-lambda/-/client-lambda-3.636.0.tgz", - "integrity": "sha512-rJitBBQAEVdyf4E6PhwFwD7uIM222dfx2oEIuFKkUb5rMKaFocnJbzvS3yGv/dZwDcUtMV5+5ibMCfgE8gAiJg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-lambda/-/client-lambda-3.637.0.tgz", + "integrity": "sha512-XVQn4p/9XNMEImxCY97WlA83Q63HRrDhks4kby5YGG2fZckaNJxXE+/FFYsznse8hXKLUJ1/aI3hZSnXTthq5g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3352,21 +3352,21 @@ } }, "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3400,26 +3400,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3474,12 +3474,12 @@ } }, "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -3489,9 +3489,9 @@ } }, "node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -3515,23 +3515,23 @@ } }, "node_modules/@aws-sdk/client-opensearch": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-opensearch/-/client-opensearch-3.635.0.tgz", - "integrity": "sha512-hFZlPxUHiaVQJq3QBd8EBwFmP+3iRen22q3YVs44ee6Fi3H7fpwtiq5HLCNO2BF61999OA9PAYF5RrjWorNoYA==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-opensearch/-/client-opensearch-3.637.0.tgz", + "integrity": "sha512-SLmKOVBxImEziHS60hRB1d/pNSJVr+FRSlRSSV5KIEXvWrtrmNAZGly3KnXjPuDUpCflWrpuKX7sm2c9//CANQ==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3566,21 +3566,21 @@ } }, "node_modules/@aws-sdk/client-opensearch/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3614,26 +3614,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-opensearch/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3688,12 +3688,12 @@ } }, "node_modules/@aws-sdk/client-opensearch/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -3703,9 +3703,9 @@ } }, "node_modules/@aws-sdk/client-opensearch/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -3729,24 +3729,24 @@ } }, "node_modules/@aws-sdk/client-route-53": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-route-53/-/client-route-53-3.635.0.tgz", - "integrity": "sha512-SU932rYfL6aVVTCxAR6p7H+l7eh8qyZFp1bprgm4Yciv0bz9B/k1c6Ra48Z0Pt2mCRdnZT1m9Zn+UvgRYrBFhQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-route-53/-/client-route-53-3.637.0.tgz", + "integrity": "sha512-lF73WvWrCmfvmESx397G/GS8ecLIiB7PRy3Cpn1yl8V6LR3Hmuthgd7DbpN1YHtkEnwr0mVQUMy5c2IUD9D3kg==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", "@aws-sdk/middleware-sdk-route53": "3.609.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@aws-sdk/xml-builder": "3.609.0", @@ -3783,21 +3783,21 @@ } }, "node_modules/@aws-sdk/client-route-53/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3831,26 +3831,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-route-53/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -3905,12 +3905,12 @@ } }, "node_modules/@aws-sdk/client-route-53/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -3920,9 +3920,9 @@ } }, "node_modules/@aws-sdk/client-route-53/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -3946,17 +3946,17 @@ } }, "node_modules/@aws-sdk/client-s3": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.635.0.tgz", - "integrity": "sha512-4RP+DJZWqUka1MW2aSEzTzntY3GrDzS26D8dHZvbt2I0x+dSmlnmXiJkCxLjmti2SDVYAGL9gX6e7mLS7W55jA==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.637.0.tgz", + "integrity": "sha512-y6UC94fsMvhKbf0dzfnjVP1HePeGjplfcYfilZU1COIJLyTkMcUv4XcT4I407CGIrvgEafONHkiC09ygqUauNA==", "dependencies": { "@aws-crypto/sha1-browser": "5.2.0", "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-bucket-endpoint": "3.620.0", "@aws-sdk/middleware-expect-continue": "3.620.0", "@aws-sdk/middleware-flexible-checksums": "3.620.0", @@ -3966,11 +3966,11 @@ "@aws-sdk/middleware-recursion-detection": "3.620.0", "@aws-sdk/middleware-sdk-s3": "3.635.0", "@aws-sdk/middleware-ssec": "3.609.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/signature-v4-multi-region": "3.635.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@aws-sdk/xml-builder": "3.609.0", @@ -4014,21 +4014,21 @@ } }, "node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4062,26 +4062,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4136,12 +4136,12 @@ } }, "node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -4151,9 +4151,9 @@ } }, "node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -4177,24 +4177,24 @@ } }, "node_modules/@aws-sdk/client-secrets-manager": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-secrets-manager/-/client-secrets-manager-3.635.0.tgz", - "integrity": "sha512-taa+sa8xFym7ZYzybqkOVy5MAdedcIt2pKEVOReEaNkUuOwMUo+wF4QhJeyhaLPTs2l0rHR1bnwYOG+0fW0Kvg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-secrets-manager/-/client-secrets-manager-3.637.0.tgz", + "integrity": "sha512-4AEV+4yhaFYlnD90MbtOouqTyrPVmD8OeGotsjtWxgnVHk55Vd0/dIWVGjic0YCxH3SNdWqJJ9G8Vd93fWymVA==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4230,22 +4230,22 @@ } }, "node_modules/@aws-sdk/client-secrets-manager/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4279,27 +4279,27 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-secrets-manager/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dev": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4355,13 +4355,13 @@ } }, "node_modules/@aws-sdk/client-secrets-manager/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dev": true, "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -4371,9 +4371,9 @@ } }, "node_modules/@aws-sdk/client-secrets-manager/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dev": true, "dependencies": { "@aws-sdk/types": "3.609.0", @@ -4412,23 +4412,23 @@ } }, "node_modules/@aws-sdk/client-ses": { - "version": "3.636.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-ses/-/client-ses-3.636.0.tgz", - "integrity": "sha512-72LwrowWBR4W6ilkc1AIBJZV7UbA9YvmqfHyh+D+Ek7VK65cW9mskLE9rFX/uI4CzupCSxVvEy2d23M/6w+Saw==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-ses/-/client-ses-3.637.0.tgz", + "integrity": "sha512-pHkI8iMxbdtNeaa0a+c0T29bRZMFu8HQtGtwPlSwvD1elDVFrlWXw74MrlaW0aRPGryF4sHxVHk3YkxhxAS5iw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4464,21 +4464,21 @@ } }, "node_modules/@aws-sdk/client-ses/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4512,26 +4512,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-ses/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4586,12 +4586,12 @@ } }, "node_modules/@aws-sdk/client-ses/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -4601,9 +4601,9 @@ } }, "node_modules/@aws-sdk/client-ses/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -4627,23 +4627,23 @@ } }, "node_modules/@aws-sdk/client-sns": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sns/-/client-sns-3.635.0.tgz", - "integrity": "sha512-jlx6o7sDIX1R07z8+hjqlxaBmaXPDQ2xgU8KD0HtGAAHj+P7oDQypSxorelh3tc+UQdFN4tJ0xBxFRGYejL6lg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sns/-/client-sns-3.637.0.tgz", + "integrity": "sha512-6FDeWqTCeIPgImMyabqoFd9/EFS3XIaMYrqmHUTSPNlrhRkuJWh+3zS/S5a7tPxqkadOIqajf9UCzMCvjJru8g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4678,21 +4678,21 @@ } }, "node_modules/@aws-sdk/client-sns/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4726,26 +4726,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-sns/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4800,12 +4800,12 @@ } }, "node_modules/@aws-sdk/client-sns/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -4815,9 +4815,9 @@ } }, "node_modules/@aws-sdk/client-sns/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -4841,24 +4841,24 @@ } }, "node_modules/@aws-sdk/client-sqs": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sqs/-/client-sqs-3.635.0.tgz", - "integrity": "sha512-0b53yd0oTfR9dCCbBTuoKwslQdAnonkprzKyrrj3vffcnrr+U7fq11OU6WHX0Vu3WxNx1GGMvUnF6SJEsPdBDA==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sqs/-/client-sqs-3.637.0.tgz", + "integrity": "sha512-0slT2OCa8uOottHFjIBD9EuTotu3Qdzp7Z7PqtkSqQdbXxC8CFsDLNfZVqpU8o/+mf79I2fJK21pEPhBnm654g==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", "@aws-sdk/middleware-sdk-sqs": "3.635.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4894,21 +4894,21 @@ } }, "node_modules/@aws-sdk/client-sqs/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -4942,26 +4942,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-sqs/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -5016,12 +5016,12 @@ } }, "node_modules/@aws-sdk/client-sqs/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -5031,9 +5031,9 @@ } }, "node_modules/@aws-sdk/client-sqs/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -5057,23 +5057,23 @@ } }, "node_modules/@aws-sdk/client-ssm": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-ssm/-/client-ssm-3.635.0.tgz", - "integrity": "sha512-8aMG5TN+QgziahHuzZB3MoREVfV4IRIG3+kR55vZCRGUtnwgOdTwrtjKV+VOE2ulAk8WiNHsJyjz1iUXr7bG3g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-ssm/-/client-ssm-3.637.0.tgz", + "integrity": "sha512-cr0/c95KpFIwoCCofXu1Em/Sw8SjIFCZ3X1ji2rW81QdLpw7icP01SMcRTbgtiKeN12fKZDXmrupkI6zhnG0MA==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", - "@aws-sdk/client-sts": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", + "@aws-sdk/client-sts": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -5110,21 +5110,21 @@ } }, "node_modules/@aws-sdk/client-ssm/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -5158,26 +5158,26 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/client-ssm/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -5232,12 +5232,12 @@ } }, "node_modules/@aws-sdk/client-ssm/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -5247,9 +5247,9 @@ } }, "node_modules/@aws-sdk/client-ssm/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -5619,15 +5619,15 @@ } }, "node_modules/@aws-sdk/credential-provider-node": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.635.0.tgz", - "integrity": "sha512-bmd23mnb94S6AxmWPgqJTnvT9ONKlTx7EPafE1RNO+vUl6mHih4iyqX6ZPaRcSfaPx4U1R7H1RM8cSnafXgaBg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.637.0.tgz", + "integrity": "sha512-yoEhoxJJfs7sPVQ6Is939BDQJZpZCoUgKr/ySse4YKOZ24t4VqgHA6+wV7rYh+7IW24Rd91UTvEzSuHYTlxlNA==", "dependencies": { "@aws-sdk/credential-provider-env": "3.620.1", "@aws-sdk/credential-provider-http": "3.635.0", - "@aws-sdk/credential-provider-ini": "3.635.0", + "@aws-sdk/credential-provider-ini": "3.637.0", "@aws-sdk/credential-provider-process": "3.620.1", - "@aws-sdk/credential-provider-sso": "3.635.0", + "@aws-sdk/credential-provider-sso": "3.637.0", "@aws-sdk/credential-provider-web-identity": "3.621.0", "@aws-sdk/types": "3.609.0", "@smithy/credential-provider-imds": "^3.2.0", @@ -5641,9 +5641,9 @@ } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/client-sso": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.635.0.tgz", - "integrity": "sha512-/Hl69+JpFUo9JNVmh2gSvMgYkE4xjd+1okiRoPBbQqjI7YBP2JWCUDP8IoEkNq3wj0vNTq0OWfn6RpZycIkAXQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.637.0.tgz", + "integrity": "sha512-+KjLvgX5yJYROWo3TQuwBJlHCY0zz9PsLuEolmXQn0BVK1L/m9GteZHtd+rEdAoDGBpE0Xqjy1oz5+SmtsaRUw==", "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", @@ -5651,10 +5651,10 @@ "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -5689,22 +5689,22 @@ } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/client-sso-oidc": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.635.0.tgz", - "integrity": "sha512-RIwDlhzAFttB1vbpznewnPqz7h1H/2UhQLwB38yfZBwYQOxyxVfLV5j5VoUUX3jY4i4qH9wiHc7b02qeAOZY6g==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.637.0.tgz", + "integrity": "sha512-27bHALN6Qb6m6KZmPvRieJ/QRlj1lyac/GT2Rn5kJpre8Mpp+yxrtvp3h9PjNBty4lCeFEENfY4dGNSozBuBcw==", "peer": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -5738,27 +5738,27 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/client-sts": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.635.0.tgz", - "integrity": "sha512-Al2ytE69+cbA44qHlelqhzWwbURikfF13Zkal9utIG5Q6T2c7r8p6sePN92n8l/x1v0FhJ5VTxKak+cPTE0CZQ==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.637.0.tgz", + "integrity": "sha512-xUi7x4qDubtA8QREtlblPuAcn91GS/09YVEY/RwU7xCY0aqGuFwgszAANlha4OUIqva8oVj2WO4gJuG+iaSnhw==", "peer": true, "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.635.0", + "@aws-sdk/client-sso-oidc": "3.637.0", "@aws-sdk/core": "3.635.0", - "@aws-sdk/credential-provider-node": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", "@aws-sdk/middleware-host-header": "3.620.0", "@aws-sdk/middleware-logger": "3.609.0", "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.632.0", + "@aws-sdk/middleware-user-agent": "3.637.0", "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@aws-sdk/util-user-agent-browser": "3.609.0", "@aws-sdk/util-user-agent-node": "3.614.0", "@smithy/config-resolver": "^3.0.5", @@ -5832,14 +5832,14 @@ } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-ini": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.635.0.tgz", - "integrity": "sha512-+OqcNhhOFFY08YHLjO9/Y1n37RKAO7LADnsJ7VTXca7IfvYh27BVBn+FdlqnyEb1MQ5ArHTY4pq3pKRIg6RW4Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.637.0.tgz", + "integrity": "sha512-h+PFCWfZ0Q3Dx84SppET/TFpcQHmxFW8/oV9ArEvMilw4EBN+IlxgbL0CnHwjHW64szcmrM0mbebjEfHf4FXmw==", "dependencies": { "@aws-sdk/credential-provider-env": "3.620.1", "@aws-sdk/credential-provider-http": "3.635.0", "@aws-sdk/credential-provider-process": "3.620.1", - "@aws-sdk/credential-provider-sso": "3.635.0", + "@aws-sdk/credential-provider-sso": "3.637.0", "@aws-sdk/credential-provider-web-identity": "3.621.0", "@aws-sdk/types": "3.609.0", "@smithy/credential-provider-imds": "^3.2.0", @@ -5852,15 +5852,15 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-sts": "^3.635.0" + "@aws-sdk/client-sts": "^3.637.0" } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-sso": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.635.0.tgz", - "integrity": "sha512-hO/fKyvUaGpK9zyvCnmJz70EputvGWDr2UTOn/RzvcR6UB4yXoFf0QcCMubEsE3v67EsAv6PadgOeJ0vz6IazA==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.637.0.tgz", + "integrity": "sha512-Mvz+h+e62/tl+dVikLafhv+qkZJ9RUb8l2YN/LeKMWkxQylPT83CPk9aimVhCV89zth1zpREArl97+3xsfgQvA==", "dependencies": { - "@aws-sdk/client-sso": "3.635.0", + "@aws-sdk/client-sso": "3.637.0", "@aws-sdk/token-providers": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/property-provider": "^3.1.3", @@ -5873,12 +5873,12 @@ } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/middleware-user-agent": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.632.0.tgz", - "integrity": "sha512-yY/sFsHKwG9yzSf/DTclqWJaGPI2gPBJDCGBujSqTG1zlS7Ot4fqi91DZ6088BFWzbOorDzJFcAhAEFzc6LuQg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.637.0.tgz", + "integrity": "sha512-EYo0NE9/da/OY8STDsK2LvM4kNa79DBsf4YVtaG4P5pZ615IeFsD8xOHZeuJmUrSMlVQ8ywPRX7WMucUybsKug==", "dependencies": { "@aws-sdk/types": "3.609.0", - "@aws-sdk/util-endpoints": "3.632.0", + "@aws-sdk/util-endpoints": "3.637.0", "@smithy/protocol-http": "^4.1.0", "@smithy/types": "^3.3.0", "tslib": "^2.6.2" @@ -5888,9 +5888,9 @@ } }, "node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/util-endpoints": { - "version": "3.632.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.632.0.tgz", - "integrity": "sha512-LlYMU8pAbcEQphOpE6xaNLJ8kPGhklZZTVzZVpVW477NaaGgoGTMYNXTABYHcxeF5E2lLrxql9OmVpvr8GWN8Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-endpoints/-/util-endpoints-3.637.0.tgz", + "integrity": "sha512-pAqOKUHeVWHEXXDIp/qoMk/6jyxIb6GGjnK1/f8dKHtKIEs4tKsnnL563gceEvdad53OPXIt86uoevCcCzmBnw==", "dependencies": { "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", @@ -6025,11 +6025,11 @@ } }, "node_modules/@aws-sdk/lib-dynamodb": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/lib-dynamodb/-/lib-dynamodb-3.635.0.tgz", - "integrity": "sha512-EEuurFULGzHYA1gk1uNXclkw38TFgFhzO1hKu6FchjeLv7mw1Z9Pj5hkGjmNOqesQDjSfYbEXs3JI2jYWwp7Iw==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/lib-dynamodb/-/lib-dynamodb-3.637.0.tgz", + "integrity": "sha512-jyIZBagxcwrzWdgDZdlqXKWz1uKPNGxFuUODwhRj3337EZz+yVo1qSfs6s9TKO7+nta+kPLg2mo064KXP5XHJw==", "dependencies": { - "@aws-sdk/util-dynamodb": "3.635.0", + "@aws-sdk/util-dynamodb": "3.637.0", "@smithy/core": "^2.4.0", "@smithy/smithy-client": "^3.2.0", "@smithy/types": "^3.3.0", @@ -6039,13 +6039,13 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-dynamodb": "^3.635.0" + "@aws-sdk/client-dynamodb": "^3.637.0" } }, "node_modules/@aws-sdk/lib-storage": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/lib-storage/-/lib-storage-3.635.0.tgz", - "integrity": "sha512-1aLTfCuQijyGefbdn8RHV3uTNKcDMPFMKZBX6C9mSHBpR2lTNNGEyu2/KFKO3wcLXt5fZRQovexlixMx5Tnkyg==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/lib-storage/-/lib-storage-3.637.0.tgz", + "integrity": "sha512-HiNGOP4a1QrCWwO1joKw4mCp19nLXoF9K52PislBaYDI35IlHC3DP6MeOg5zmElwtL1GtEHFBy5olfPWPsLyLg==", "dependencies": { "@smithy/abort-controller": "^3.1.1", "@smithy/middleware-endpoint": "^3.1.0", @@ -6059,7 +6059,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-s3": "^3.635.0" + "@aws-sdk/client-s3": "^3.637.0" } }, "node_modules/@aws-sdk/middleware-bucket-endpoint": { @@ -6472,11 +6472,11 @@ } }, "node_modules/@aws-sdk/s3-presigned-post": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/s3-presigned-post/-/s3-presigned-post-3.635.0.tgz", - "integrity": "sha512-1kYYpnAvNVe/Mrlk06bNie+pWMFu9rZF0zQSfdjWXQPTfYnCJdl79nXoKU1Mlwc5s7YneRwoBJ39KQKrump0/Q==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/s3-presigned-post/-/s3-presigned-post-3.637.0.tgz", + "integrity": "sha512-NlsowCavLXx5OulbD8+tqfXpyxVulI2l/4naBI1i5Vj6M+FMuQvqH1Y5OQBgN42/QZlMLJ5Ff5G3aaoZjrb1pw==", "dependencies": { - "@aws-sdk/client-s3": "3.635.0", + "@aws-sdk/client-s3": "3.637.0", "@aws-sdk/types": "3.609.0", "@aws-sdk/util-format-url": "3.609.0", "@smithy/middleware-endpoint": "^3.1.0", @@ -6503,9 +6503,9 @@ } }, "node_modules/@aws-sdk/s3-request-presigner": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/s3-request-presigner/-/s3-request-presigner-3.635.0.tgz", - "integrity": "sha512-hiAmZvPjNjQA/RXPc0LVc93ytit7PyDswMAPooCS85564lSNCJw+ygP8nnUPGpkjnHkZ9UgjNDc/UQxzwj0eLA==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/s3-request-presigner/-/s3-request-presigner-3.637.0.tgz", + "integrity": "sha512-URRiEDZEICyfAXmXcXREQCsvZrapITAymvg46p1Xjnuv7PTnUB0SF18B2omPL0E5d/X+T3O9NKdtot+BqJbIWw==", "dependencies": { "@aws-sdk/signature-v4-multi-region": "3.635.0", "@aws-sdk/types": "3.609.0", @@ -6729,9 +6729,9 @@ } }, "node_modules/@aws-sdk/util-dynamodb": { - "version": "3.635.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-dynamodb/-/util-dynamodb-3.635.0.tgz", - "integrity": "sha512-j0xMQRgRrdZmdlrFjan5z7eJUcK0TboW2BTMB2TYo/tZw5DT8f7PIs/e3TTndPRGfzTUwggopd9+lAm5Wk4hQA==", + "version": "3.637.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/util-dynamodb/-/util-dynamodb-3.637.0.tgz", + "integrity": "sha512-C2q8HcGRiahtf46Mhaqydh1gofeksj7m74PJXHYKW+pKBMLPlpou1+w2o5QSpVEp0dSBtKw30eRVQzxhqg/ACA==", "dependencies": { "tslib": "^2.6.2" }, @@ -6739,7 +6739,7 @@ "node": ">=16.0.0" }, "peerDependencies": { - "@aws-sdk/client-dynamodb": "^3.635.0" + "@aws-sdk/client-dynamodb": "^3.637.0" } }, "node_modules/@aws-sdk/util-endpoints": { @@ -17677,9 +17677,9 @@ } }, "node_modules/axios": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", - "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz", + "integrity": "sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", diff --git a/package.json b/package.json index da5588e4996..b19461c4678 100644 --- a/package.json +++ b/package.json @@ -11,34 +11,34 @@ "dependencies": { "@18f/us-federal-holidays": "4.0.0", "@aws-crypto/sha256-browser": "5.2.0", - "@aws-sdk/client-api-gateway": "3.635.0", - "@aws-sdk/client-apigatewaymanagementapi": "3.635.0", - "@aws-sdk/client-apigatewayv2": "3.635.0", - "@aws-sdk/client-cloudfront": "3.635.0", - "@aws-sdk/client-cloudwatch": "3.635.0", - "@aws-sdk/client-cloudwatch-logs": "3.635.0", - "@aws-sdk/client-cognito-identity-provider": "3.635.0", - "@aws-sdk/client-dynamodb": "3.635.0", - "@aws-sdk/client-dynamodb-streams": "3.635.0", - "@aws-sdk/client-glue": "3.636.0", - "@aws-sdk/client-lambda": "3.636.0", - "@aws-sdk/client-opensearch": "3.635.0", - "@aws-sdk/client-route-53": "3.635.0", - "@aws-sdk/client-s3": "3.635.0", - "@aws-sdk/client-ses": "3.636.0", - "@aws-sdk/client-sns": "3.635.0", - "@aws-sdk/client-sqs": "3.635.0", - "@aws-sdk/client-ssm": "3.635.0", + "@aws-sdk/client-api-gateway": "3.637.0", + "@aws-sdk/client-apigatewaymanagementapi": "3.637.0", + "@aws-sdk/client-apigatewayv2": "3.637.0", + "@aws-sdk/client-cloudfront": "3.637.0", + "@aws-sdk/client-cloudwatch": "3.637.0", + "@aws-sdk/client-cloudwatch-logs": "3.637.0", + "@aws-sdk/client-cognito-identity-provider": "3.637.0", + "@aws-sdk/client-dynamodb": "3.637.0", + "@aws-sdk/client-dynamodb-streams": "3.637.0", + "@aws-sdk/client-glue": "3.637.0", + "@aws-sdk/client-lambda": "3.637.0", + "@aws-sdk/client-opensearch": "3.637.0", + "@aws-sdk/client-route-53": "3.637.0", + "@aws-sdk/client-s3": "3.637.0", + "@aws-sdk/client-ses": "3.637.0", + "@aws-sdk/client-sns": "3.637.0", + "@aws-sdk/client-sqs": "3.637.0", + "@aws-sdk/client-ssm": "3.637.0", "@aws-sdk/cloudfront-signer": "3.621.0", - "@aws-sdk/credential-provider-node": "3.635.0", - "@aws-sdk/lib-dynamodb": "3.635.0", - "@aws-sdk/lib-storage": "3.635.0", + "@aws-sdk/credential-provider-node": "3.637.0", + "@aws-sdk/lib-dynamodb": "3.637.0", + "@aws-sdk/lib-storage": "3.637.0", "@aws-sdk/node-http-handler": "3.374.0", "@aws-sdk/protocol-http": "3.374.0", - "@aws-sdk/s3-presigned-post": "3.635.0", - "@aws-sdk/s3-request-presigner": "3.635.0", + "@aws-sdk/s3-presigned-post": "3.637.0", + "@aws-sdk/s3-request-presigner": "3.637.0", "@aws-sdk/signature-v4": "3.374.0", - "@aws-sdk/util-dynamodb": "3.635.0", + "@aws-sdk/util-dynamodb": "3.637.0", "@cerebral/react": "4.2.1", "@fortawesome/fontawesome-svg-core": "1.2.36", "@fortawesome/free-regular-svg-icons": "5.15.4", @@ -50,7 +50,7 @@ "@uswds/uswds": "3.7.1", "aws-lambda": "1.0.7", "aws-xray-sdk": "3.9.0", - "axios": "1.7.4", + "axios": "1.7.5", "broadcast-channel": "7.0.0", "canvas": "2.11.2", "cerebral": "5.2.1", @@ -244,8 +244,8 @@ "ejs": "3.1.10" }, "devDependencies": { - "@aws-sdk/client-iam": "3.635.0", - "@aws-sdk/client-secrets-manager": "3.635.0", + "@aws-sdk/client-iam": "3.637.0", + "@aws-sdk/client-secrets-manager": "3.637.0", "@babel/cli": "7.24.8", "@babel/core": "7.25.2", "@babel/eslint-parser": "7.25.1", diff --git a/web-api/src/dispatchers/ses/sendBulkTemplatedEmail.test.ts b/web-api/src/dispatchers/ses/sendBulkTemplatedEmail.test.ts index 7ccf4b12151..03ff8ca5995 100644 --- a/web-api/src/dispatchers/ses/sendBulkTemplatedEmail.test.ts +++ b/web-api/src/dispatchers/ses/sendBulkTemplatedEmail.test.ts @@ -130,6 +130,7 @@ describe('sendBulkTemplatedEmail', () => { await sendWithRetry({ applicationContext, params: { + DefaultTemplateData: undefined, Destinations: [ { Destination: { @@ -200,6 +201,7 @@ describe('sendBulkTemplatedEmail', () => { sendWithRetry({ applicationContext, params: { + DefaultTemplateData: undefined, Destinations: [ { Destination: { From a0842891acfd1b2103e338d704af912239dea240 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 1 Aug 2024 16:37:42 -0500 Subject: [PATCH 455/523] devex - Remove unused oauth flows from cognito --- .../modules/everything-else-deprecated/cognito.tf | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/web-api/terraform/modules/everything-else-deprecated/cognito.tf b/web-api/terraform/modules/everything-else-deprecated/cognito.tf index 6ce88eaa9d9..504e2659250 100644 --- a/web-api/terraform/modules/everything-else-deprecated/cognito.tf +++ b/web-api/terraform/modules/everything-else-deprecated/cognito.tf @@ -162,7 +162,7 @@ resource "aws_cognito_user_pool_client" "client" { explicit_auth_flows = ["ADMIN_NO_SRP_AUTH", "USER_PASSWORD_AUTH"] generate_secret = false - allowed_oauth_flows_user_pool_client = true + allowed_oauth_flows_user_pool_client = false token_validity_units { access_token = "hours" @@ -173,9 +173,6 @@ resource "aws_cognito_user_pool_client" "client" { access_token_validity = 1 id_token_validity = 1 - allowed_oauth_flows = ["code", "implicit"] - allowed_oauth_scopes = ["email", "openid", "profile", "phone", "aws.cognito.signin.user.admin"] - supported_identity_providers = ["COGNITO"] user_pool_id = aws_cognito_user_pool.pool.id @@ -336,7 +333,7 @@ resource "aws_cognito_user_pool_client" "irs_client" { explicit_auth_flows = ["ADMIN_NO_SRP_AUTH", "USER_PASSWORD_AUTH"] generate_secret = false - allowed_oauth_flows_user_pool_client = true + allowed_oauth_flows_user_pool_client = false token_validity_units { access_token = "hours" id_token = "hours" @@ -346,10 +343,6 @@ resource "aws_cognito_user_pool_client" "irs_client" { access_token_validity = 1 id_token_validity = 1 - allowed_oauth_flows = ["code", "implicit"] - allowed_oauth_scopes = ["email", "openid", "profile", "phone", "aws.cognito.signin.user.admin"] - supported_identity_providers = ["COGNITO"] - user_pool_id = aws_cognito_user_pool.irs_pool.id write_attributes = [ From a915d5c3266a10d4862133c749649e17e4aa895b Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Thu, 1 Aug 2024 16:53:43 -0500 Subject: [PATCH 456/523] devex - Replace outdated terraform module --- web-api/terraform/modules/dynamsoft/dynamsoft.tf | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/web-api/terraform/modules/dynamsoft/dynamsoft.tf b/web-api/terraform/modules/dynamsoft/dynamsoft.tf index 09df081dd3c..b35552c2ded 100644 --- a/web-api/terraform/modules/dynamsoft/dynamsoft.tf +++ b/web-api/terraform/modules/dynamsoft/dynamsoft.tf @@ -10,20 +10,14 @@ resource "aws_instance" "dynamsoft" { Name = "dynamsoft-${var.environment}" environment = var.environment } - user_data = data.template_file.setup_dynamsoft.rendered - user_data_replace_on_change = true - - iam_instance_profile = "dynamsoft_s3_download_role" -} - -data "template_file" "setup_dynamsoft" { - template = file("${path.module}/setup_dynamsoft.sh") - - vars = { + user_data = templatefile("${path.module}/setup_dynamsoft.sh", { dynamsoft_s3_zip_path = var.dynamsoft_s3_zip_path dynamsoft_url = var.dynamsoft_url dynamsoft_product_keys = var.dynamsoft_product_keys - } + }) + user_data_replace_on_change = true + + iam_instance_profile = "dynamsoft_s3_download_role" } resource "aws_security_group" "dynamsoft_load_balancer_security_group" { From 956a3236484ef00dbb68ea43ba2eb31a0199564d Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Fri, 23 Aug 2024 15:52:24 -0500 Subject: [PATCH 457/523] Revert "deps: update puppeteer, chromium" This reverts commit e82c7924c510ffb9d166a2efe892dbc831212b45. --- docs/dependency-updates.md | 1 + package-lock.json | 71 +++++++++----------- package.json | 6 +- web-api/runtimes/puppeteer/package-lock.json | 66 +++++++++--------- web-api/runtimes/puppeteer/package.json | 4 +- 5 files changed, 67 insertions(+), 81 deletions(-) diff --git a/docs/dependency-updates.md b/docs/dependency-updates.md index 9a570612ae7..592dd546294 100644 --- a/docs/dependency-updates.md +++ b/docs/dependency-updates.md @@ -77,6 +77,7 @@ Below is a list of dependencies that are locked down due to known issues with se - When updating puppeteer or puppeteer core in the project, make sure to also match versions in `web-api/runtimes/puppeteer/package.json` as this is our lambda layer which we use to generate pdfs. Puppeteer and chromium versions should always match between package.json and web-api/runtimes/puppeteer/package.json. Remember to run `npm install --prefix web-api/runtimes/puppeteer` to install and update the package-lock file. - Puppeteer also has recommended versions of Chromium, so we should make sure to use the recommended version of chromium for the version of puppeteer that we are on. +- As of 8/15/2024, we cannot update puppeteer or puppeteer-core beyond 22.13.1 because the latest release of @sparticuz/chromium only supports version 126 of chromium. - There is a high-severity security issue with ws (ws affected by a DoS when handling a request with many HTTP headers - https://github.com/advisories/GHSA-3h5v-q93c-6h6q); however, we only use ws on the client side, so this should not be an issue. (We tried to upgrade puppeteer anyway, but unsurprisingly the PDF tests failed because there is no newer version of Chromium that supports puppeteer.) ### pdfjs-dist diff --git a/package-lock.json b/package-lock.json index adbb824f0a4..6f8dcde77f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "@fortawesome/react-fontawesome": "0.2.2", "@joi/date": "2.1.1", "@opensearch-project/opensearch": "2.11.0", - "@sparticuz/chromium": "127.0.0", + "@sparticuz/chromium": "126.0.0", "@uswds/uswds": "3.7.1", "aws-lambda": "1.0.7", "aws-xray-sdk": "3.9.0", @@ -197,8 +197,8 @@ "postcss-preset-env": "10.0.2", "prettier": "3.3.3", "prop-types": "15.8.1", - "puppeteer": "23.1.1", - "puppeteer-core": "23.1.1", + "puppeteer": "22.13.1", + "puppeteer-core": "22.13.1", "react-test-renderer": "18.3.1", "readline": "1.3.0", "s3rver": "github:20minutes/s3rver", @@ -13724,16 +13724,16 @@ "dev": true }, "node_modules/@puppeteer/browsers": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.3.1.tgz", - "integrity": "sha512-uK7o3hHkK+naEobMSJ+2ySYyXtQkBxIH8Gn4MK9ciePjNV+Pf+PgY/W7iPzn2MTjl3stcYB5AlcTmPYw7AXDwA==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.2.4.tgz", + "integrity": "sha512-BdG2qiI1dn89OTUUsx2GZSpUzW+DRffR1wlMJyKxVHYrhnKoELSDxDd+2XImUkuWPEKk76H5FcM/gPFrEK1Tfw==", "dev": true, "dependencies": { - "debug": "^4.3.6", + "debug": "^4.3.5", "extract-zip": "^2.0.1", "progress": "^2.0.3", "proxy-agent": "^6.4.0", - "semver": "^7.6.3", + "semver": "^7.6.2", "tar-fs": "^3.0.6", "unbzip2-stream": "^1.4.3", "yargs": "^17.7.2" @@ -14701,9 +14701,9 @@ "dev": true }, "node_modules/@sparticuz/chromium": { - "version": "127.0.0", - "resolved": "https://registry.npmjs.org/@sparticuz/chromium/-/chromium-127.0.0.tgz", - "integrity": "sha512-3YdElfXb6kqcFtlgaArNZohhZ1gWAiWg5kPYIZbaoHFau7dHZvbYg3EEjeE30bYi6cfOnB8wVpluuasF8Y3QyQ==", + "version": "126.0.0", + "resolved": "https://registry.npmjs.org/@sparticuz/chromium/-/chromium-126.0.0.tgz", + "integrity": "sha512-qqGQmZQj3y0/V2osKswRHbzK4Qe80YHSDnpt6ac51hsY1bMDinMS9Q+eEmcL+re2MEhYN+ykoV9BY8Dyw1Lyjg==", "dependencies": { "follow-redirects": "^1.15.6", "tar-fs": "^3.0.6" @@ -19097,9 +19097,9 @@ } }, "node_modules/chromium-bidi": { - "version": "0.6.4", - "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.4.tgz", - "integrity": "sha512-8zoq6ogmhQQkAKZVKO2ObFTl4uOkqoX1PlKQX3hZQ5E9cbUotcAb7h4pTNVAGGv8Z36PF3CtdOriEp/Rz82JqQ==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.1.tgz", + "integrity": "sha512-kSxJRj0VgtUKz6nmzc2JPfyfJGzwzt65u7PqhPHtgGQUZLF5oG+ST6l6e5ONfStUMAlhSutFCjaGKllXZa16jA==", "dev": true, "dependencies": { "mitt": "3.0.1", @@ -21010,9 +21010,9 @@ } }, "node_modules/devtools-protocol": { - "version": "0.0.1312386", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1312386.tgz", - "integrity": "sha512-DPnhUXvmvKT2dFA/j7B+riVLUt9Q6RKJlcppojL5CoRywJJKLDYnRlw0gTFKfgDPHP5E04UoB71SxoJlVZy8FA==", + "version": "0.0.1299070", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1299070.tgz", + "integrity": "sha512-+qtL3eX50qsJ7c+qVyagqi7AWMoQCBGNfoyJZMwm/NSXVqLYbuitrWEEIzxfUmTNy7//Xe8yhMmQ+elj3uAqSg==", "dev": true }, "node_modules/diff": { @@ -33364,37 +33364,34 @@ "dev": true }, "node_modules/puppeteer": { - "version": "23.1.1", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.1.1.tgz", - "integrity": "sha512-giN4Ikwl5hkkouH/dVyxIPTPslWuqZ8fjALdSw5Cvt+r0LuDpLdfPxRADlB75YJ2UjPZhgok+xYBYk8ffzv4MA==", + "version": "22.13.1", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-22.13.1.tgz", + "integrity": "sha512-PwXLDQK5u83Fm5A7TGMq+9BR7iHDJ8a3h21PSsh/E6VfhxiKYkU7+tvGZNSCap6k3pCNDd9oNteVBEctcBalmQ==", "dev": true, "hasInstallScript": true, "dependencies": { - "@puppeteer/browsers": "2.3.1", - "chromium-bidi": "0.6.4", + "@puppeteer/browsers": "2.2.4", "cosmiconfig": "^9.0.0", - "devtools-protocol": "0.0.1312386", - "puppeteer-core": "23.1.1", - "typed-query-selector": "^2.12.0" + "devtools-protocol": "0.0.1299070", + "puppeteer-core": "22.13.1" }, "bin": { - "puppeteer": "lib/cjs/puppeteer/node/cli.js" + "puppeteer": "lib/esm/puppeteer/node/cli.js" }, "engines": { "node": ">=18" } }, "node_modules/puppeteer-core": { - "version": "23.1.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.1.1.tgz", - "integrity": "sha512-OeTqNiYGF9qZtwZU4Yc88DDqFJs4TJ4rnK81jkillh6MwDeQodyisM9xe5lBmPhwiDy92s5J5DQtQLjCKHFQ3g==", + "version": "22.13.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-22.13.1.tgz", + "integrity": "sha512-NmhnASYp51QPRCAf9n0OPxuPMmzkKd8+2sB9Q+BjwwCG25gz6iuNc3LQDWa+cH2tyivmJppLhNNFt6Q3HmoOpw==", "dev": true, "dependencies": { - "@puppeteer/browsers": "2.3.1", - "chromium-bidi": "0.6.4", - "debug": "^4.3.6", - "devtools-protocol": "0.0.1312386", - "typed-query-selector": "^2.12.0", + "@puppeteer/browsers": "2.2.4", + "chromium-bidi": "0.6.1", + "debug": "^4.3.5", + "devtools-protocol": "0.0.1299070", "ws": "^8.18.0" }, "engines": { @@ -37633,12 +37630,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/typed-query-selector": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.0.tgz", - "integrity": "sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==", - "dev": true - }, "node_modules/typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", diff --git a/package.json b/package.json index b19461c4678..b964a073231 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@fortawesome/react-fontawesome": "0.2.2", "@joi/date": "2.1.1", "@opensearch-project/opensearch": "2.11.0", - "@sparticuz/chromium": "127.0.0", + "@sparticuz/chromium": "126.0.0", "@uswds/uswds": "3.7.1", "aws-lambda": "1.0.7", "aws-xray-sdk": "3.9.0", @@ -339,8 +339,8 @@ "postcss-preset-env": "10.0.2", "prettier": "3.3.3", "prop-types": "15.8.1", - "puppeteer": "23.1.1", - "puppeteer-core": "23.1.1", + "puppeteer": "22.13.1", + "puppeteer-core": "22.13.1", "react-test-renderer": "18.3.1", "readline": "1.3.0", "s3rver": "github:20minutes/s3rver", diff --git a/web-api/runtimes/puppeteer/package-lock.json b/web-api/runtimes/puppeteer/package-lock.json index cdb77425b03..d858efda48b 100644 --- a/web-api/runtimes/puppeteer/package-lock.json +++ b/web-api/runtimes/puppeteer/package-lock.json @@ -9,9 +9,9 @@ "version": "0.0.2", "license": "CC0-1.0", "dependencies": { - "@sparticuz/chromium": "127.0.0", + "@sparticuz/chromium": "126.0.0", "pug": "3.0.3", - "puppeteer-core": "23.1.1", + "puppeteer-core": "22.13.1", "sass": "1.77.8" }, "engines": { @@ -64,15 +64,15 @@ } }, "node_modules/@puppeteer/browsers": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.3.1.tgz", - "integrity": "sha512-uK7o3hHkK+naEobMSJ+2ySYyXtQkBxIH8Gn4MK9ciePjNV+Pf+PgY/W7iPzn2MTjl3stcYB5AlcTmPYw7AXDwA==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.2.4.tgz", + "integrity": "sha512-BdG2qiI1dn89OTUUsx2GZSpUzW+DRffR1wlMJyKxVHYrhnKoELSDxDd+2XImUkuWPEKk76H5FcM/gPFrEK1Tfw==", "dependencies": { - "debug": "^4.3.6", + "debug": "^4.3.5", "extract-zip": "^2.0.1", "progress": "^2.0.3", "proxy-agent": "^6.4.0", - "semver": "^7.6.3", + "semver": "^7.6.2", "tar-fs": "^3.0.6", "unbzip2-stream": "^1.4.3", "yargs": "^17.7.2" @@ -85,9 +85,9 @@ } }, "node_modules/@sparticuz/chromium": { - "version": "127.0.0", - "resolved": "https://registry.npmjs.org/@sparticuz/chromium/-/chromium-127.0.0.tgz", - "integrity": "sha512-3YdElfXb6kqcFtlgaArNZohhZ1gWAiWg5kPYIZbaoHFau7dHZvbYg3EEjeE30bYi6cfOnB8wVpluuasF8Y3QyQ==", + "version": "126.0.0", + "resolved": "https://registry.npmjs.org/@sparticuz/chromium/-/chromium-126.0.0.tgz", + "integrity": "sha512-qqGQmZQj3y0/V2osKswRHbzK4Qe80YHSDnpt6ac51hsY1bMDinMS9Q+eEmcL+re2MEhYN+ykoV9BY8Dyw1Lyjg==", "dependencies": { "follow-redirects": "^1.15.6", "tar-fs": "^3.0.6" @@ -102,9 +102,9 @@ "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" }, "node_modules/@types/node": { - "version": "22.5.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", - "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.0.tgz", + "integrity": "sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==", "optional": true, "dependencies": { "undici-types": "~6.19.2" @@ -399,9 +399,9 @@ } }, "node_modules/chromium-bidi": { - "version": "0.6.4", - "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.4.tgz", - "integrity": "sha512-8zoq6ogmhQQkAKZVKO2ObFTl4uOkqoX1PlKQX3hZQ5E9cbUotcAb7h4pTNVAGGv8Z36PF3CtdOriEp/Rz82JqQ==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.1.tgz", + "integrity": "sha512-kSxJRj0VgtUKz6nmzc2JPfyfJGzwzt65u7PqhPHtgGQUZLF5oG+ST6l6e5ONfStUMAlhSutFCjaGKllXZa16jA==", "dependencies": { "mitt": "3.0.1", "urlpattern-polyfill": "10.0.0", @@ -505,9 +505,9 @@ } }, "node_modules/devtools-protocol": { - "version": "0.0.1312386", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1312386.tgz", - "integrity": "sha512-DPnhUXvmvKT2dFA/j7B+riVLUt9Q6RKJlcppojL5CoRywJJKLDYnRlw0gTFKfgDPHP5E04UoB71SxoJlVZy8FA==" + "version": "0.0.1299070", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1299070.tgz", + "integrity": "sha512-+qtL3eX50qsJ7c+qVyagqi7AWMoQCBGNfoyJZMwm/NSXVqLYbuitrWEEIzxfUmTNy7//Xe8yhMmQ+elj3uAqSg==" }, "node_modules/doctypes": { "version": "1.1.0", @@ -1322,15 +1322,14 @@ } }, "node_modules/puppeteer-core": { - "version": "23.1.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.1.1.tgz", - "integrity": "sha512-OeTqNiYGF9qZtwZU4Yc88DDqFJs4TJ4rnK81jkillh6MwDeQodyisM9xe5lBmPhwiDy92s5J5DQtQLjCKHFQ3g==", - "dependencies": { - "@puppeteer/browsers": "2.3.1", - "chromium-bidi": "0.6.4", - "debug": "^4.3.6", - "devtools-protocol": "0.0.1312386", - "typed-query-selector": "^2.12.0", + "version": "22.13.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-22.13.1.tgz", + "integrity": "sha512-NmhnASYp51QPRCAf9n0OPxuPMmzkKd8+2sB9Q+BjwwCG25gz6iuNc3LQDWa+cH2tyivmJppLhNNFt6Q3HmoOpw==", + "dependencies": { + "@puppeteer/browsers": "2.2.4", + "chromium-bidi": "0.6.1", + "debug": "^4.3.5", + "devtools-protocol": "0.0.1299070", "ws": "^8.18.0" }, "engines": { @@ -1603,11 +1602,6 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" }, - "node_modules/typed-query-selector": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.0.tgz", - "integrity": "sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==" - }, "node_modules/unbzip2-stream": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", @@ -1618,9 +1612,9 @@ } }, "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "version": "6.19.6", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", + "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", "optional": true }, "node_modules/universalify": { diff --git a/web-api/runtimes/puppeteer/package.json b/web-api/runtimes/puppeteer/package.json index 221a59377b6..1e2ad32ff75 100644 --- a/web-api/runtimes/puppeteer/package.json +++ b/web-api/runtimes/puppeteer/package.json @@ -8,9 +8,9 @@ "npm": ">=10.2.4 <11.0.0" }, "dependencies": { - "@sparticuz/chromium": "127.0.0", + "@sparticuz/chromium": "126.0.0", "pug": "3.0.3", - "puppeteer-core": "23.1.1", + "puppeteer-core": "22.13.1", "sass": "1.77.8" }, "scripts": {}, From 5dfc9bedaec23c596a074d02ae34807ce7aa3b77 Mon Sep 17 00:00:00 2001 From: Nate Elliott Date: Mon, 26 Aug 2024 08:43:41 -0500 Subject: [PATCH 458/523] deps: remove erroneous package lock file --- .../puppeteer/web-api/runtimes/puppeteer/package-lock.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 web-api/runtimes/puppeteer/web-api/runtimes/puppeteer/package-lock.json diff --git a/web-api/runtimes/puppeteer/web-api/runtimes/puppeteer/package-lock.json b/web-api/runtimes/puppeteer/web-api/runtimes/puppeteer/package-lock.json deleted file mode 100644 index 2f902f11643..00000000000 --- a/web-api/runtimes/puppeteer/web-api/runtimes/puppeteer/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "puppeteer", - "lockfileVersion": 3, - "requires": true, - "packages": {} -} From e921c025dee2bb361c0dbb49e4fc8fe043f05137 Mon Sep 17 00:00:00 2001 From: John Cruz Date: Mon, 26 Aug 2024 08:42:30 -0600 Subject: [PATCH 459/523] 10471: Added unit test to cover order of docket numbers; --- ...rtIssuedOrderPdfFromHtmlInteractor.test.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts index 0d0a263b37d..657210c7a31 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts @@ -144,4 +144,33 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { }), ); }); + + describe('BUG: Order the Docket Numbers', () => { + it('should order the docket numbers correctly by year and index', async () => { + await createCourtIssuedOrderPdfFromHtmlInteractor(applicationContext, { + addedDocketNumbers: [ + '101-24', + '101-19', + '103-19', + '101-26', + '101-16', + '102-19', + '101-20', + ], + } as any); + + const orderCalls = + applicationContext.getDocumentGenerators().order.mock.calls; + expect(orderCalls.length).toEqual(1); + expect(orderCalls[0][0].data.addedDocketNumbers).toEqual([ + '101-16', + '101-19', + '102-19', + '103-19', + '101-20', + '101-24', + '101-26', + ]); + }); + }); }); From e42f308a4ddfc45ce9cad28fec640d08f0057a30 Mon Sep 17 00:00:00 2001 From: John Cruz Date: Mon, 26 Aug 2024 08:51:20 -0600 Subject: [PATCH 460/523] 10471: Implement sorting of the dorcket numbers; Pass array of deocket numbers to interactor; --- ...rtIssuedOrderPdfFromHtmlInteractor.test.ts | 20 ++++++++++--------- ...teCourtIssuedOrderPdfFromHtmlInteractor.ts | 5 ++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts index 657210c7a31..62e21c49133 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.test.ts @@ -48,20 +48,18 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { }); it('fetches the case by id', async () => { - await createCourtIssuedOrderPdfFromHtmlInteractor( - applicationContext, - {} as any, - ); + await createCourtIssuedOrderPdfFromHtmlInteractor(applicationContext, { + addedDocketNumbers: [], + } as any); expect( applicationContext.getPersistenceGateway().getCaseByDocketNumber, ).toHaveBeenCalled(); }); it('calls the pdf document generator function', async () => { - await createCourtIssuedOrderPdfFromHtmlInteractor( - applicationContext, - {} as any, - ); + await createCourtIssuedOrderPdfFromHtmlInteractor(applicationContext, { + addedDocketNumbers: [], + } as any); expect( applicationContext.getDocumentGenerators().order, ).toHaveBeenCalledWith( @@ -76,7 +74,9 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { it('returns the pdf url from the temp documents bucket', async () => { const result = await createCourtIssuedOrderPdfFromHtmlInteractor( applicationContext, - {} as any, + { + addedDocketNumbers: [], + } as any, ); expect( @@ -107,6 +107,7 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { const result = await createCourtIssuedOrderPdfFromHtmlInteractor( applicationContext, { + addedDocketNumbers: [], eventCode: 'NOT', } as any, ); @@ -126,6 +127,7 @@ describe('createCourtIssuedOrderPdfFromHtmlInteractor', () => { it('calls the generate the order pdf WITHOUT a defined name or title of the clerk for non-NOT event codes', async () => { await createCourtIssuedOrderPdfFromHtmlInteractor(applicationContext, { + addedDocketNumbers: [], eventCode: 'O', } as any); diff --git a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts index 91a5238ba8d..71c0aad08e2 100644 --- a/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts +++ b/web-api/src/business/useCases/courtIssuedOrder/createCourtIssuedOrderPdfFromHtmlInteractor.ts @@ -2,6 +2,7 @@ import { CLERK_OF_THE_COURT_CONFIGURATION, NOTICE_EVENT_CODE, } from '@shared/business/entities/EntityConstants'; +import { Case } from '@shared/business/entities/cases/Case'; import { ROLE_PERMISSIONS, isAuthorized, @@ -64,7 +65,9 @@ export const createCourtIssuedOrderPdfFromHtmlInteractor = async ( const orderPdf = await applicationContext.getDocumentGenerators().order({ applicationContext, data: { - addedDocketNumbers, + addedDocketNumbers: addedDocketNumbers.sort((a, b) => + Case.docketNumberSort(a, b), + ), caseCaptionExtension, caseTitle, docketNumberWithSuffix, From c995fc7c62aefb4497eaff55e80ce95092189c3f Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:05:28 -0500 Subject: [PATCH 461/523] 10397: add new custom paginator --- .../src/ustc-ui/Pagination/Paginator.tsx | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index 1013c2f108a..3e66b3f8e67 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -1,51 +1,51 @@ +import { Button } from '@web-client/ustc-ui/Button/Button'; import React from 'react'; -import ReactPaginate from 'react-paginate'; -export const Paginator = ({ - breakClassName, - forcePage, - id, - marginPagesDisplayed = 3, - onPageChange, - pageCount, - pageRangeDisplayed, -}: { - breakClassName?: string; - marginPagesDisplayed?: number; - pageCount: number; - id?: string; - pageRangeDisplayed: number; - onPageChange: (selectedItem: { selected: number }) => void; - forcePage: number; -}) => { +export const Paginator = ({ currentPageIndex, onPageChange, totalPages }) => { + let currentPage = currentPageIndex + 1; + return ( - <> - - + ); }; From a0b1758231338c3749bf204992c0f8e607f09422 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:08:00 -0500 Subject: [PATCH 462/523] 10397: replace paginator in PractitionerSearchResults, ColdCaseReportList, CustomCaseReport --- .../PractitionerSearchResults.tsx | 18 +++++-------- .../ColdCaseReport/ColdCaseReportList.tsx | 22 ++++++---------- .../CustomCaseReport/CustomCaseReport.tsx | 26 +++++++------------ 3 files changed, 24 insertions(+), 42 deletions(-) diff --git a/web-client/src/views/AdvancedSearch/PractitionerSearchResults.tsx b/web-client/src/views/AdvancedSearch/PractitionerSearchResults.tsx index 251ef3d7bb7..b6558a3149f 100644 --- a/web-client/src/views/AdvancedSearch/PractitionerSearchResults.tsx +++ b/web-client/src/views/AdvancedSearch/PractitionerSearchResults.tsx @@ -27,14 +27,11 @@ export const PractitionerSearchResults = connect(
{practitionerSearchHelper.showPaginator && ( { submitPractitionerNameSearchSequence({ - selectedPage: pageChange.selected, + selectedPage: pageChange, }); focusPaginatorTop(paginatorTop); }} @@ -164,14 +161,11 @@ export const PractitionerSearchResults = connect(
{practitionerSearchHelper.showPaginator && ( { submitPractitionerNameSearchSequence({ - selectedPage: pageChange.selected, + selectedPage: pageChange, }); focusPaginatorTop(paginatorTop); }} diff --git a/web-client/src/views/ColdCaseReport/ColdCaseReportList.tsx b/web-client/src/views/ColdCaseReport/ColdCaseReportList.tsx index bf9852f314b..eea560e60f4 100644 --- a/web-client/src/views/ColdCaseReport/ColdCaseReportList.tsx +++ b/web-client/src/views/ColdCaseReport/ColdCaseReportList.tsx @@ -78,13 +78,10 @@ export function ColdCaseReportList({ entries }: { entries: ColdCaseEntry[] }) { {totalPages > 1 && (
{ - setActivePage(pageChange.selected); + currentPageIndex={activePage} + totalPages={totalPages} + onPageChange={pageChange => { + setActivePage(pageChange); focusPaginatorTop(paginatorTop); }} /> @@ -161,13 +158,10 @@ export function ColdCaseReportList({ entries }: { entries: ColdCaseEntry[] }) { {totalPages > 1 && ( { - setActivePage(pageChange.selected); + currentPageIndex={activePage} + totalPages={totalPages} + onPageChange={pageChange => { + setActivePage(pageChange); focusPaginatorTop(paginatorTop); }} /> diff --git a/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx b/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx index 92db9667ad5..e3c772ce3cc 100644 --- a/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx +++ b/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx @@ -468,9 +468,9 @@ export const CustomCaseReport = connect(
diff --git a/web-client/src/views/UserContactEditForm.tsx b/web-client/src/views/UserContactEditForm.tsx index a59cd5fe9c0..3caebda5438 100644 --- a/web-client/src/views/UserContactEditForm.tsx +++ b/web-client/src/views/UserContactEditForm.tsx @@ -62,7 +62,7 @@ export const UserContactEditForm = connect( data-testid="phone-number-input" id="phone" name="contact.phone" - type="tel" + type="text" value={form.contact.phone || ''} onBlur={() => { validateUserContactSequence(); From a6b364dc49da4825a2defeca1296299aa30f0c2e Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Tue, 20 Aug 2024 09:13:00 -0400 Subject: [PATCH 467/523] Remove styling for no-longer-used "tel" input els in forms.scss --- web-client/src/styles/forms.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/web-client/src/styles/forms.scss b/web-client/src/styles/forms.scss index 006921b942d..cbc85c45fab 100644 --- a/web-client/src/styles/forms.scss +++ b/web-client/src/styles/forms.scss @@ -126,7 +126,6 @@ legend { input[type='email'], input[type='number'], -input[type='tel'], input[type='text'], textarea, select { From 66afadf46b8295270f8bb3d17ebc210784256ba8 Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Thu, 22 Aug 2024 14:28:32 -0400 Subject: [PATCH 468/523] 10399-bug: Direct user to the edit-upload-court-issued route if a user edits a draft document that does not have a documentType property --- .../actions/checkDocumentTypeAction.test.ts | 31 +++++++++++++++++ .../actions/checkDocumentTypeAction.ts | 33 +++++++++++-------- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts b/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts index 5ae4ff3b857..eaea703ea8a 100644 --- a/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts +++ b/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts @@ -91,4 +91,35 @@ describe('checkDocumentTypeAction', () => { path: `/case-detail/${mockDocketNumber}/edit-order/${mockDocketEntryId}/${mockParentMessageId}`, }); }); + + it('should return the correct path for a document with an undefined document type without parentMessageId', async () => { + const props = { + ...propsBase, + }; + + await runAction(checkDocumentTypeAction, { + modules: { presenter }, + props, + }); + + expect(pathDocumentTypeMiscellaneousStub).toHaveBeenCalledWith({ + path: `/case-detail/${mockDocketNumber}/edit-upload-court-issued/${mockDocketEntryId}`, + }); + }); + + it('should return the correct path for a document with an undefined document type with parentMessageId', async () => { + const props = { + ...propsBase, + parentMessageId: mockParentMessageId, + }; + + await runAction(checkDocumentTypeAction, { + modules: { presenter }, + props, + }); + + expect(pathDocumentTypeMiscellaneousStub).toHaveBeenCalledWith({ + path: `/case-detail/${mockDocketNumber}/edit-upload-court-issued/${mockDocketEntryId}/${mockParentMessageId}`, + }); + }); }); diff --git a/web-client/src/presenter/actions/checkDocumentTypeAction.ts b/web-client/src/presenter/actions/checkDocumentTypeAction.ts index f911f2a97a4..8fb90be1ce7 100644 --- a/web-client/src/presenter/actions/checkDocumentTypeAction.ts +++ b/web-client/src/presenter/actions/checkDocumentTypeAction.ts @@ -1,15 +1,22 @@ +import { PRACTITIONER_DOCUMENT_TYPES_MAP } from '../../../../shared/src/business/entities/EntityConstants'; + export const checkDocumentTypeAction = ({ path, props }: ActionProps) => { - const parentMessageId = props.parentMessageId - ? `/${props.parentMessageId}` - : ''; - - if (props.documentType === 'Miscellaneous') { - return path.documentTypeMiscellaneous({ - path: `/case-detail/${props.caseDetail.docketNumber}/edit-upload-court-issued/${props.docketEntryIdToEdit}${parentMessageId}`, - }); - } - - return path.documentTypeOrder({ - path: `/case-detail/${props.caseDetail.docketNumber}/edit-order/${props.docketEntryIdToEdit}${parentMessageId}`, - }); + const { caseDetail, docketEntryIdToEdit, documentType, parentMessageId } = + props; + + const parentMessagePath = parentMessageId ? `/${parentMessageId}` : ''; + + const basePath = `/case-detail/${caseDetail.docketNumber}`; + + const isMiscellaneousDocument = + documentType === PRACTITIONER_DOCUMENT_TYPES_MAP.MISCELLANEOUS || + !documentType; + + const documentPath = isMiscellaneousDocument + ? `/edit-upload-court-issued/${docketEntryIdToEdit}${parentMessagePath}` + : `/edit-order/${docketEntryIdToEdit}${parentMessagePath}`; + + return isMiscellaneousDocument + ? path.documentTypeMiscellaneous({ path: `${basePath}${documentPath}` }) + : path.documentTypeOrder({ path: `${basePath}${documentPath}` }); }; From 5ae63ecf2986f4bed3fe1cbefe3f37c38ef0f854 Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Fri, 23 Aug 2024 11:03:40 -0400 Subject: [PATCH 469/523] 10399-bug: handle scenario in which a status report order is in draft and does not have a documentType property defined --- .../actions/checkDocumentTypeAction.test.ts | 53 ++++++++++++++++++- .../actions/checkDocumentTypeAction.ts | 19 ++++++- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts b/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts index eaea703ea8a..3367e8fc138 100644 --- a/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts +++ b/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts @@ -92,7 +92,7 @@ describe('checkDocumentTypeAction', () => { }); }); - it('should return the correct path for a document with an undefined document type without parentMessageId', async () => { + it('should return the correct path for a document that is not a status report order with an undefined document type without parentMessageId', async () => { const props = { ...propsBase, }; @@ -107,7 +107,7 @@ describe('checkDocumentTypeAction', () => { }); }); - it('should return the correct path for a document with an undefined document type with parentMessageId', async () => { + it('should return the correct path for a document that is not a status report order with an undefined document type with parentMessageId', async () => { const props = { ...propsBase, parentMessageId: mockParentMessageId, @@ -122,4 +122,53 @@ describe('checkDocumentTypeAction', () => { path: `/case-detail/${mockDocketNumber}/edit-upload-court-issued/${mockDocketEntryId}/${mockParentMessageId}`, }); }); + + it('should return the correct path for a document that is a status report order with an undefined document type without parentMessageId', async () => { + const props = { + caseDetail: { + ...propsBase.caseDetail, + docketEntries: [ + { + docketEntryId: mockDocketEntryId, + draftOrderState: { orderType: 'statusReport' }, + }, + ], + }, + docketEntryIdToEdit: propsBase.docketEntryIdToEdit, + }; + + await runAction(checkDocumentTypeAction, { + modules: { presenter }, + props, + }); + + expect(pathDocumentTypeOrderStub).toHaveBeenCalledWith({ + path: `/case-detail/${mockDocketNumber}/edit-order/${mockDocketEntryId}`, + }); + }); + + it('should return the correct path for a document that is a status report order with an undefined document type with parentMessageId', async () => { + const props = { + caseDetail: { + ...propsBase.caseDetail, + docketEntries: [ + { + docketEntryId: mockDocketEntryId, + draftOrderState: { orderType: 'statusReport' }, + }, + ], + }, + docketEntryIdToEdit: propsBase.docketEntryIdToEdit, + parentMessageId: mockParentMessageId, + }; + + await runAction(checkDocumentTypeAction, { + modules: { presenter }, + props, + }); + + expect(pathDocumentTypeOrderStub).toHaveBeenCalledWith({ + path: `/case-detail/${mockDocketNumber}/edit-order/${mockDocketEntryId}/${mockParentMessageId}`, + }); + }); }); diff --git a/web-client/src/presenter/actions/checkDocumentTypeAction.ts b/web-client/src/presenter/actions/checkDocumentTypeAction.ts index 8fb90be1ce7..0a50dde93c5 100644 --- a/web-client/src/presenter/actions/checkDocumentTypeAction.ts +++ b/web-client/src/presenter/actions/checkDocumentTypeAction.ts @@ -1,4 +1,7 @@ -import { PRACTITIONER_DOCUMENT_TYPES_MAP } from '../../../../shared/src/business/entities/EntityConstants'; +import { + PRACTITIONER_DOCUMENT_TYPES_MAP, + STATUS_REPORT_ORDER_OPTIONS, +} from '../../../../shared/src/business/entities/EntityConstants'; export const checkDocumentTypeAction = ({ path, props }: ActionProps) => { const { caseDetail, docketEntryIdToEdit, documentType, parentMessageId } = @@ -8,9 +11,21 @@ export const checkDocumentTypeAction = ({ path, props }: ActionProps) => { const basePath = `/case-detail/${caseDetail.docketNumber}`; + const [docketEntry] = (props.caseDetail.docketEntries || []).filter( + de => de.docketEntryId === docketEntryIdToEdit, + ); + + const draftStatusReportOrderTypes = Object.values( + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions, + ); + + const isDraftStatusReportOrder = draftStatusReportOrderTypes.includes( + docketEntry?.draftOrderState.orderType || '', + ); + const isMiscellaneousDocument = documentType === PRACTITIONER_DOCUMENT_TYPES_MAP.MISCELLANEOUS || - !documentType; + (!isDraftStatusReportOrder && !documentType); const documentPath = isMiscellaneousDocument ? `/edit-upload-court-issued/${docketEntryIdToEdit}${parentMessagePath}` From ea3563cd019fd166610615da2e7d694d65da25ea Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Fri, 23 Aug 2024 15:59:27 -0400 Subject: [PATCH 470/523] Isolate logic to determine if a docket entry is miscellaneous --- shared/src/business/entities/DocketEntry.ts | 22 ++++- .../utilities/getFormattedCaseDetail.test.ts | 82 +++++++++++++----- .../utilities/getFormattedCaseDetail.ts | 25 ++---- .../isMiscellaneousDocketEntry.test.ts | 84 +++++++++++++++++++ .../utilities/isMiscellaneousDocketEntry.ts | 22 +++++ .../actions/checkDocumentTypeAction.test.ts | 63 ++++++++++++-- .../actions/checkDocumentTypeAction.ts | 38 +++------ 7 files changed, 263 insertions(+), 73 deletions(-) create mode 100644 shared/src/business/utilities/isMiscellaneousDocketEntry.test.ts create mode 100644 shared/src/business/utilities/isMiscellaneousDocketEntry.ts diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index 3dd6f85b278..4a4e83de17b 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -93,7 +93,7 @@ export class DocketEntry extends JoiValidationEntity { public documentContentsId?: string; public documentIdBeforeSignature?: string; public documentTitle: string; - public documentType: string; + public documentType?: string; public eventCode: string; public filedBy?: string; public filedByRole?: string; @@ -142,7 +142,25 @@ export class DocketEntry extends JoiValidationEntity { public privatePractitioners?: any[]; public servedParties?: any[]; public signedAt?: string; - public draftOrderState?: object; + public draftOrderState?: { + additionalOrderText?: string; + docketNumber?: string; + documentTitle?: string; + documentType?: string; + dueDate?: string; + eventCode?: string; + freeText?: string; + generatedDocumentTitle?: string; + issueOrder?: string; + jurisdiction?: string; + orderType?: string; + primaryDocumentFileSize?: number; + richText?: string; + scenario?: string; + statusReportFilingDate?: string; + statusReportIndex?: string; + strickenFromTrialSessions?: boolean; + }; public stampData!: object; public isDraft?: boolean; public redactionAcknowledgement?: boolean; diff --git a/shared/src/business/utilities/getFormattedCaseDetail.test.ts b/shared/src/business/utilities/getFormattedCaseDetail.test.ts index 9bc7b1cb9d6..bdf1440a6a0 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.test.ts +++ b/shared/src/business/utilities/getFormattedCaseDetail.test.ts @@ -430,32 +430,62 @@ describe('getFormattedCaseDetail', () => { }); it('should format draft documents', () => { + const orderDocketEntry = { + archived: false, + createdAt: getDateISO(), + docketEntryId: 'd-1-2-3', + docketNumber: '101-18', + documentType: 'Order', + isDraft: true, + }; + + const stipulatedDecisionDocketEntry = { + archived: false, + createdAt: getDateISO(), + docketEntryId: 'd-2-3-4', + docketNumber: '101-18', + documentType: 'Stipulated Decision', + isDraft: true, + }; + + const miscellaneousDocketEntry = { + archived: false, + createdAt: getDateISO(), + docketEntryId: 'd-3-4-5', + docketNumber: '101-18', + documentType: 'Miscellaneous', + isDraft: true, + }; + + const miscellaneousDocketEntryWithUndefinedDocumentType = { + archived: false, + createdAt: getDateISO(), + docketEntryId: 'd-3-4-5', + docketNumber: '101-18', + isDraft: true, + }; + + const statusReportOrderDocketEntry = { + archived: false, + createdAt: getDateISO(), + docketEntryId: 'd-3-4-5', + docketNumber: '101-18', + draftOrderState: { + orderType: 'statusReport', + }, + isDraft: true, + }; + const result = getFormattedCaseDetail({ applicationContext, caseDetail: { ...MOCK_CASE, docketEntries: [ - { - archived: false, - createdAt: getDateISO(), - docketEntryId: 'd-1-2-3', - documentType: 'Order', - isDraft: true, - }, - { - archived: false, - createdAt: getDateISO(), - docketEntryId: 'd-2-3-4', - documentType: 'Stipulated Decision', - isDraft: true, - }, - { - archived: false, - createdAt: getDateISO(), - docketEntryId: 'd-3-4-5', - documentType: 'Miscellaneous', - isDraft: true, - }, + orderDocketEntry, + stipulatedDecisionDocketEntry, + miscellaneousDocketEntry, + miscellaneousDocketEntryWithUndefinedDocumentType, + statusReportOrderDocketEntry, ], }, docketRecordSort: 'byDate', @@ -477,6 +507,16 @@ describe('getFormattedCaseDetail', () => { signUrl: `/case-detail/${MOCK_CASE.docketNumber}/edit-order/d-3-4-5/sign`, signedAtFormatted: '', }, + { + editUrl: `/case-detail/${MOCK_CASE.docketNumber}/edit-upload-court-issued/d-3-4-5`, + signUrl: `/case-detail/${MOCK_CASE.docketNumber}/edit-order/d-3-4-5/sign`, + signedAtFormatted: '', + }, + { + editUrl: `/case-detail/${MOCK_CASE.docketNumber}/edit-order/d-3-4-5`, + signUrl: `/case-detail/${MOCK_CASE.docketNumber}/edit-order/d-3-4-5/sign`, + signedAtFormatted: '', + }, ]); }); diff --git a/shared/src/business/utilities/getFormattedCaseDetail.ts b/shared/src/business/utilities/getFormattedCaseDetail.ts index 0b7fb461e04..edab016398c 100644 --- a/shared/src/business/utilities/getFormattedCaseDetail.ts +++ b/shared/src/business/utilities/getFormattedCaseDetail.ts @@ -16,6 +16,7 @@ import { formatDateString, } from './DateHandler'; import { cloneDeep, isEmpty, sortBy } from 'lodash'; +import { isMiscellaneousDocketEntry } from '@shared/business/utilities/isMiscellaneousDocketEntry'; const computeIsInProgress = ({ formattedEntry }) => { return ( @@ -248,18 +249,12 @@ const formatTrialSessionScheduling = ({ } }; -const getEditUrl = ({ - docketEntryId, - docketNumber, - documentType, -}: { - docketNumber: string; - documentType: string; - docketEntryId: string; -}) => { - return documentType === 'Miscellaneous' - ? `/case-detail/${docketNumber}/edit-upload-court-issued/${docketEntryId}` - : `/case-detail/${docketNumber}/edit-order/${docketEntryId}`; +const getEditUrl = (docketEntry: RawDocketEntry): string => { + const routeToEditUploadCourtIssued = isMiscellaneousDocketEntry(docketEntry); + + return routeToEditUploadCourtIssued + ? `/case-detail/${docketEntry.docketNumber}/edit-upload-court-issued/${docketEntry.docketEntryId}` + : `/case-detail/${docketEntry.docketNumber}/edit-order/${docketEntry.docketEntryId}`; }; export const formatCase = (applicationContext, caseDetail) => { @@ -273,11 +268,7 @@ export const formatCase = (applicationContext, caseDetail) => { .filter(docketEntry => docketEntry.isDraft && !docketEntry.archived) .map(docketEntry => ({ ...formatDocketEntry(applicationContext, docketEntry), - editUrl: getEditUrl({ - docketEntryId: docketEntry.docketEntryId, - docketNumber: caseDetail.docketNumber, - documentType: docketEntry.documentType, - }), + editUrl: getEditUrl(docketEntry), signUrl: `/case-detail/${caseDetail.docketNumber}/edit-order/${docketEntry.docketEntryId}/sign`, signedAtFormatted: applicationContext .getUtilities() diff --git a/shared/src/business/utilities/isMiscellaneousDocketEntry.test.ts b/shared/src/business/utilities/isMiscellaneousDocketEntry.test.ts new file mode 100644 index 00000000000..c5ce8d3eb47 --- /dev/null +++ b/shared/src/business/utilities/isMiscellaneousDocketEntry.test.ts @@ -0,0 +1,84 @@ +import { isMiscellaneousDocketEntry } from './isMiscellaneousDocketEntry'; + +describe('isMiscellaneousDocument', () => { + it("should return true when passed a docket entry that has a document type of 'Miscellaneous'", () => { + const result = isMiscellaneousDocketEntry({ + createdAt: '2019-11-21T21:49:28.192Z', + docketEntryId: '062c9a5d-1a65-4273-965e-25d41607bc98', + docketNumber: '101-18', + documentTitle: 'Attachment to Petition', + documentType: 'Miscellaneous', + entityName: 'DocketEntry', + eventCode: 'ATP', + filers: [], + filingDate: '2017-03-01T09:00:00.000Z', + isOnDocketRecord: true, + processingStatus: 'pending', + receivedAt: '2018-03-01T05:00:00.000Z', + stampData: {}, + }); + + expect(result).toBe(true); + }); + + it('should return true when passed a docket entry that has an undefined document type and that is not a draft status report order', () => { + const result = isMiscellaneousDocketEntry({ + createdAt: '2019-11-21T21:49:28.192Z', + docketEntryId: '062c9a5d-1a65-4273-965e-25d41607bc98', + docketNumber: '101-18', + documentTitle: 'Attachment to Petition', + entityName: 'DocketEntry', + eventCode: 'ATP', + filers: [], + filingDate: '2017-03-01T09:00:00.000Z', + isOnDocketRecord: true, + processingStatus: 'pending', + receivedAt: '2018-03-01T05:00:00.000Z', + stampData: {}, + }); + + expect(result).toEqual(true); + }); + + it('should return false when passed a docket entry is a draft status report order', () => { + const result = isMiscellaneousDocketEntry({ + createdAt: '2019-11-21T21:49:28.192Z', + docketEntryId: '062c9a5d-1a65-4273-965e-25d41607bc98', + docketNumber: '101-18', + documentTitle: 'Attachment to Petition', + draftOrderState: { + orderType: 'statusReport', + }, + entityName: 'DocketEntry', + eventCode: 'ATP', + filers: [], + filingDate: '2017-03-01T09:00:00.000Z', + isOnDocketRecord: true, + processingStatus: 'pending', + receivedAt: '2018-03-01T05:00:00.000Z', + stampData: {}, + }); + + expect(result).toEqual(false); + }); + + it('should return false when passed a docket entry is not a draft status report order', () => { + const result = isMiscellaneousDocketEntry({ + createdAt: '2019-11-21T21:49:28.192Z', + docketEntryId: '062c9a5d-1a65-4273-965e-25d41607bc98', + docketNumber: '101-18', + documentTitle: 'Attachment to Petition', + documentType: 'Order', + entityName: 'DocketEntry', + eventCode: 'ATP', + filers: [], + filingDate: '2017-03-01T09:00:00.000Z', + isOnDocketRecord: true, + processingStatus: 'pending', + receivedAt: '2018-03-01T05:00:00.000Z', + stampData: {}, + }); + + expect(result).toEqual(false); + }); +}); diff --git a/shared/src/business/utilities/isMiscellaneousDocketEntry.ts b/shared/src/business/utilities/isMiscellaneousDocketEntry.ts new file mode 100644 index 00000000000..4768e1f80de --- /dev/null +++ b/shared/src/business/utilities/isMiscellaneousDocketEntry.ts @@ -0,0 +1,22 @@ +import { + PRACTITIONER_DOCUMENT_TYPES_MAP, + STATUS_REPORT_ORDER_OPTIONS, +} from '../entities/EntityConstants'; + +export const isMiscellaneousDocketEntry = ( + docketEntry: RawDocketEntry, +): boolean => { + const draftStatusReportOrderTypes = Object.values( + STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions, + ); + + const isDraftStatusReportOrder = draftStatusReportOrderTypes.includes( + docketEntry?.draftOrderState?.orderType || '', + ); + + return ( + docketEntry.documentType === + PRACTITIONER_DOCUMENT_TYPES_MAP.MISCELLANEOUS || + (!isDraftStatusReportOrder && !docketEntry.documentType) + ); +}; diff --git a/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts b/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts index 3367e8fc138..d2b494f20bf 100644 --- a/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts +++ b/web-client/src/presenter/actions/checkDocumentTypeAction.test.ts @@ -9,7 +9,6 @@ describe('checkDocumentTypeAction', () => { const mockDocketEntryId = '67890'; const mockParentMessageId = 'abcdef'; const propsBase = { - caseDetail: { docketNumber: mockDocketNumber }, docketEntryIdToEdit: mockDocketEntryId, }; @@ -29,7 +28,15 @@ describe('checkDocumentTypeAction', () => { it('should return the correct path for Miscellaneous document type without parentMessageId', async () => { const props = { ...propsBase, - documentType: 'Miscellaneous', + caseDetail: { + docketEntries: [ + { + docketEntryId: mockDocketEntryId, + documentType: 'Miscellaneous', + }, + ], + docketNumber: mockDocketNumber, + }, }; await runAction(checkDocumentTypeAction, { @@ -45,6 +52,16 @@ describe('checkDocumentTypeAction', () => { it('should return the correct path for Miscellaneous document type with parentMessageId', async () => { const props = { ...propsBase, + caseDetail: { + docketEntries: [ + { + docketEntryId: mockDocketEntryId, + documentType: 'Miscellaneous', + }, + ], + docketNumber: mockDocketNumber, + }, + documentType: 'Miscellaneous', parentMessageId: mockParentMessageId, }; @@ -62,7 +79,15 @@ describe('checkDocumentTypeAction', () => { it('should return the correct path for Order document type without parentMessageId', async () => { const props = { ...propsBase, - documentType: 'Order', + caseDetail: { + docketEntries: [ + { + docketEntryId: mockDocketEntryId, + documentType: 'Order', + }, + ], + docketNumber: mockDocketNumber, + }, }; await runAction(checkDocumentTypeAction, { @@ -78,7 +103,15 @@ describe('checkDocumentTypeAction', () => { it('should return the correct path for Order document type with parentMessageId', async () => { const props = { ...propsBase, - documentType: 'Order', + caseDetail: { + docketEntries: [ + { + docketEntryId: mockDocketEntryId, + documentType: 'Order', + }, + ], + docketNumber: mockDocketNumber, + }, parentMessageId: mockParentMessageId, }; @@ -95,6 +128,14 @@ describe('checkDocumentTypeAction', () => { it('should return the correct path for a document that is not a status report order with an undefined document type without parentMessageId', async () => { const props = { ...propsBase, + caseDetail: { + docketEntries: [ + { + docketEntryId: mockDocketEntryId, + }, + ], + docketNumber: mockDocketNumber, + }, }; await runAction(checkDocumentTypeAction, { @@ -110,6 +151,14 @@ describe('checkDocumentTypeAction', () => { it('should return the correct path for a document that is not a status report order with an undefined document type with parentMessageId', async () => { const props = { ...propsBase, + caseDetail: { + docketEntries: [ + { + docketEntryId: mockDocketEntryId, + }, + ], + docketNumber: mockDocketNumber, + }, parentMessageId: mockParentMessageId, }; @@ -125,14 +174,15 @@ describe('checkDocumentTypeAction', () => { it('should return the correct path for a document that is a status report order with an undefined document type without parentMessageId', async () => { const props = { + ...propsBase, caseDetail: { - ...propsBase.caseDetail, docketEntries: [ { docketEntryId: mockDocketEntryId, draftOrderState: { orderType: 'statusReport' }, }, ], + docketNumber: mockDocketNumber, }, docketEntryIdToEdit: propsBase.docketEntryIdToEdit, }; @@ -149,14 +199,15 @@ describe('checkDocumentTypeAction', () => { it('should return the correct path for a document that is a status report order with an undefined document type with parentMessageId', async () => { const props = { + ...propsBase, caseDetail: { - ...propsBase.caseDetail, docketEntries: [ { docketEntryId: mockDocketEntryId, draftOrderState: { orderType: 'statusReport' }, }, ], + docketNumber: mockDocketNumber, }, docketEntryIdToEdit: propsBase.docketEntryIdToEdit, parentMessageId: mockParentMessageId, diff --git a/web-client/src/presenter/actions/checkDocumentTypeAction.ts b/web-client/src/presenter/actions/checkDocumentTypeAction.ts index 0a50dde93c5..e636d1cc3a8 100644 --- a/web-client/src/presenter/actions/checkDocumentTypeAction.ts +++ b/web-client/src/presenter/actions/checkDocumentTypeAction.ts @@ -1,37 +1,21 @@ -import { - PRACTITIONER_DOCUMENT_TYPES_MAP, - STATUS_REPORT_ORDER_OPTIONS, -} from '../../../../shared/src/business/entities/EntityConstants'; +import { isMiscellaneousDocketEntry } from '@shared/business/utilities/isMiscellaneousDocketEntry'; export const checkDocumentTypeAction = ({ path, props }: ActionProps) => { - const { caseDetail, docketEntryIdToEdit, documentType, parentMessageId } = - props; - - const parentMessagePath = parentMessageId ? `/${parentMessageId}` : ''; - - const basePath = `/case-detail/${caseDetail.docketNumber}`; + const { caseDetail, docketEntryIdToEdit, parentMessageId } = props; const [docketEntry] = (props.caseDetail.docketEntries || []).filter( de => de.docketEntryId === docketEntryIdToEdit, ); - const draftStatusReportOrderTypes = Object.values( - STATUS_REPORT_ORDER_OPTIONS.orderTypeOptions, - ); - - const isDraftStatusReportOrder = draftStatusReportOrderTypes.includes( - docketEntry?.draftOrderState.orderType || '', - ); - - const isMiscellaneousDocument = - documentType === PRACTITIONER_DOCUMENT_TYPES_MAP.MISCELLANEOUS || - (!isDraftStatusReportOrder && !documentType); + const routeToEditUploadCourtIssued = isMiscellaneousDocketEntry(docketEntry); - const documentPath = isMiscellaneousDocument - ? `/edit-upload-court-issued/${docketEntryIdToEdit}${parentMessagePath}` - : `/edit-order/${docketEntryIdToEdit}${parentMessagePath}`; + const parentMessagePath = parentMessageId ? `/${parentMessageId}` : ''; - return isMiscellaneousDocument - ? path.documentTypeMiscellaneous({ path: `${basePath}${documentPath}` }) - : path.documentTypeOrder({ path: `${basePath}${documentPath}` }); + return routeToEditUploadCourtIssued + ? path.documentTypeMiscellaneous({ + path: `/case-detail/${caseDetail.docketNumber}/edit-upload-court-issued/${docketEntryIdToEdit}${parentMessagePath}`, + }) + : path.documentTypeOrder({ + path: `/case-detail/${caseDetail.docketNumber}/edit-order/${docketEntryIdToEdit}${parentMessagePath}`, + }); }; From b37cbe173eabee15464ec72d489f34e1a16156cf Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Fri, 23 Aug 2024 16:15:51 -0400 Subject: [PATCH 471/523] Fix type errors that popped up as a result of making documentType an optional property of the DocketEntry entity --- shared/src/business/entities/DocketEntry.ts | 11 ++++++----- shared/src/business/utilities/formatPendingItem.ts | 2 +- .../docketEntry/completeDocketEntryQCInteractor.ts | 4 +++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index 4a4e83de17b..7263982e245 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -521,15 +521,16 @@ export class DocketEntry extends JoiValidationEntity { * otherwise false */ isAutoServed() { - const isExternalDocumentType = EXTERNAL_DOCUMENT_TYPES.includes( - this.documentType, - ); + const documentType = this.documentType as string; + + const isExternalDocumentType = + EXTERNAL_DOCUMENT_TYPES.includes(documentType); const isPractitionerAssociationDocumentType = - PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES.includes(this.documentType); + PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES.includes(documentType); // if fully concatenated document title includes the word Simultaneous, do not auto-serve - const isSimultaneous = (this.documentTitle || this.documentType).includes( + const isSimultaneous = (this.documentTitle || documentType).includes( 'Simultaneous', ); diff --git a/shared/src/business/utilities/formatPendingItem.ts b/shared/src/business/utilities/formatPendingItem.ts index 74dbec9b71d..3c36b4cb0cb 100644 --- a/shared/src/business/utilities/formatPendingItem.ts +++ b/shared/src/business/utilities/formatPendingItem.ts @@ -33,7 +33,7 @@ export const formatPendingItem = ( .getUtilities() .formatJudgeName(item.associatedJudge); - const formattedName = item.documentTitle || item.documentType; + const formattedName = item.documentTitle || item.documentType || ''; const formattedStatus: string = applicationContext .getUtilities() diff --git a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts index f4ad5cbb587..acfbc306a70 100644 --- a/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts +++ b/web-api/src/business/useCases/docketEntry/completeDocketEntryQCInteractor.ts @@ -216,7 +216,9 @@ const completeDocketEntryQC = async ( if ( overridePaperServiceAddress || - CONTACT_CHANGE_DOCUMENT_TYPES.includes(updatedDocketEntry.documentType) + CONTACT_CHANGE_DOCUMENT_TYPES.includes( + updatedDocketEntry.documentType || '', + ) ) { if (servedParties.paper.length > 0) { const pdfData = await applicationContext From 3d30e0334c125c8f1bd652855e3b5c3ed4a47eff Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Fri, 23 Aug 2024 16:27:06 -0400 Subject: [PATCH 472/523] Fix more type errors --- shared/src/business/entities/DocketEntry.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index 7263982e245..7e1a5338874 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -629,7 +629,10 @@ export class DocketEntry extends JoiValidationEntity { return true; } - if (!rootDocument || !DocketEntry.isBriefType(rootDocument.documentType)) { + if ( + !rootDocument || + !DocketEntry.isBriefType(rootDocument.documentType || '') + ) { return false; } From 02f7affe1c28bf01cc7339f86797dc02e52c93de Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Sun, 25 Aug 2024 14:37:27 -0400 Subject: [PATCH 473/523] Work on end-to-end tests --- ...-and-edits-court-issued-docket-entry.cy.ts | 60 +++++++++++++++++++ .../EditUploadCourtIssuedDocument.tsx | 3 + 2 files changed, 63 insertions(+) create mode 100644 cypress/local-only/tests/integration/caseDetail/docketRecord/courtIssuedFiling/docket-clerk-uploads-and-edits-court-issued-docket-entry.cy.ts diff --git a/cypress/local-only/tests/integration/caseDetail/docketRecord/courtIssuedFiling/docket-clerk-uploads-and-edits-court-issued-docket-entry.cy.ts b/cypress/local-only/tests/integration/caseDetail/docketRecord/courtIssuedFiling/docket-clerk-uploads-and-edits-court-issued-docket-entry.cy.ts new file mode 100644 index 00000000000..4e3e6da774e --- /dev/null +++ b/cypress/local-only/tests/integration/caseDetail/docketRecord/courtIssuedFiling/docket-clerk-uploads-and-edits-court-issued-docket-entry.cy.ts @@ -0,0 +1,60 @@ +import { faker } from '@faker-js/faker'; +import { goToCase } from '../../../../../../helpers/caseDetail/go-to-case'; +import { loginAsDocketClerk1 } from '../../../../../../helpers/authentication/login-as-helpers'; + +describe('Docket clerk uploads and edits court-issued docket entries', () => { + it('should let a docket clerk upload a court-issued docket entry and the edit it while it is unsigned', () => { + const leadCase = '111-19'; + + loginAsDocketClerk1(); + goToCase(leadCase); + + // Arrange: create the docket entry + cy.get('[data-testid="case-detail-menu-button"]').click(); + cy.get('[data-testid="menu-button-upload-pdf"]').click(); + const title = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').type(title); + cy.readFile('cypress/helpers/file/sample.pdf', null).then(fileContent => { + cy.get('[data-testid="primary-document-file"]').attachFile({ + fileContent, + fileName: 'sample.pdf', + mimeType: 'application/pdf', + }); + cy.get('[data-testid="save-uploaded-pdf-button"]').click(); + }); + + // Act: edit the docket entry + cy.get('[data-testid="tab-drafts"').click(); + cy.get('[data-testid="draft-edit-button-not-signed"]').click(); + const newTitle = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').clear(); + cy.get('[data-testid="upload-description"]').type(newTitle); + cy.get('[data-testid="save-edited-pdf-button"]').click(); + + // Assert: the new description should display for the edited docket entry + cy.get('[data-testid^="docket-entry-description-"]').then($els => { + const matchingElements = $els.filter((index, el) => { + return Cypress.$(el).text().includes(newTitle); + }); + + expect( + matchingElements.length, + `Expected to find "${newTitle}" in at least one element`, + ).to.be.greaterThan(0); + }); + + // TODO: the above assertion fails because the updated document title does not display in the draft menu + }); + + it('should let a docket clerk upload a court-issued docket entry and the edit it after it is signed', () => { + const leadCase = '111-19'; + + loginAsDocketClerk1(); + goToCase(leadCase); + + cy.get('data-testid=[docket-entry-description-0').click(); + cy.get('data-testid="edit-order-button"').click(); + cy.get('data-testid="modal-button-confirm"').click(); + // TODO: the call to `/remove-signature` on the backend throws a 400 error + }); +}); diff --git a/web-client/src/views/EditUploadCourtIssuedDocument/EditUploadCourtIssuedDocument.tsx b/web-client/src/views/EditUploadCourtIssuedDocument/EditUploadCourtIssuedDocument.tsx index 8c6067289b3..7f3d9ad136c 100644 --- a/web-client/src/views/EditUploadCourtIssuedDocument/EditUploadCourtIssuedDocument.tsx +++ b/web-client/src/views/EditUploadCourtIssuedDocument/EditUploadCourtIssuedDocument.tsx @@ -78,6 +78,7 @@ export const EditUploadCourtIssuedDocument = connect( aria-labelledby="upload-description-label" autoCapitalize="none" className="usa-input" + data-testid="upload-description" id="upload-description" name="freeText" type="text" @@ -175,6 +176,8 @@ export const EditUploadCourtIssuedDocument = connect(
From 70a393e7863b30459047ab745907553d56385a19 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Tue, 27 Aug 2024 11:25:48 -0500 Subject: [PATCH 481/523] 10397: currentPage is a number, not a string --- web-client/src/ustc-ui/Pagination/Paginator.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index ee8fc54a244..42c07ffb7f7 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -8,7 +8,7 @@ export const Paginator = ({ }: { totalPages: number; currentPageIndex: number; - onPageChange: (currentPage: string) => void; + onPageChange: (currentPage: number) => void; }) => { let currentPage = currentPageIndex + 1; From 94ad95c223581f2aeb693ec5f1a844c247dcf6c5 Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Tue, 27 Aug 2024 11:55:07 -0500 Subject: [PATCH 482/523] 10397: hide unused paginator buttons rather than not rendering them --- .../src/ustc-ui/Pagination/Paginator.tsx | 62 +++++++++++-------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index 42c07ffb7f7..392a65046b0 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -1,5 +1,6 @@ import { Button } from '@web-client/ustc-ui/Button/Button'; import React from 'react'; +import classNames from 'classnames'; export const Paginator = ({ currentPageIndex, @@ -12,6 +13,9 @@ export const Paginator = ({ }) => { let currentPage = currentPageIndex + 1; + const nextDisabled = currentPage >= totalPages; + const previousDisabled = currentPage <= 1; + return ( ); From 8747ecc73b3335580c7ecfaf75ce56aa08f91834 Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Tue, 27 Aug 2024 13:23:16 -0400 Subject: [PATCH 483/523] 10399-bug: add test cases for editing a court issued docket entry from the message view --- ...-and-edits-court-issued-docket-entry.cy.ts | 254 +++++++++++++----- .../Messages/MessageModalAttachments.tsx | 1 + 2 files changed, 185 insertions(+), 70 deletions(-) diff --git a/cypress/local-only/tests/integration/caseDetail/docketRecord/courtIssuedFiling/docket-clerk-uploads-and-edits-court-issued-docket-entry.cy.ts b/cypress/local-only/tests/integration/caseDetail/docketRecord/courtIssuedFiling/docket-clerk-uploads-and-edits-court-issued-docket-entry.cy.ts index e314b81e953..4093553e71f 100644 --- a/cypress/local-only/tests/integration/caseDetail/docketRecord/courtIssuedFiling/docket-clerk-uploads-and-edits-court-issued-docket-entry.cy.ts +++ b/cypress/local-only/tests/integration/caseDetail/docketRecord/courtIssuedFiling/docket-clerk-uploads-and-edits-court-issued-docket-entry.cy.ts @@ -3,88 +3,202 @@ import { goToCase } from '../../../../../../helpers/caseDetail/go-to-case'; import { loginAsDocketClerk1 } from '../../../../../../helpers/authentication/login-as-helpers'; describe('Docket clerk uploads and edits court-issued docket entries', () => { - it('should let a docket clerk upload a court-issued docket entry and the edit it while it is unsigned', () => { - const leadCase = '111-19'; - - loginAsDocketClerk1(); - goToCase(leadCase); - - // Arrange: create the docket entry - cy.get('[data-testid="case-detail-menu-button"]').click(); - cy.get('[data-testid="menu-button-upload-pdf"]').click(); - const title = `${faker.word.adjective()} ${faker.word.noun()}`; - cy.get('[data-testid="upload-description"]').type(title); - cy.readFile('cypress/helpers/file/sample.pdf', null).then(fileContent => { - cy.get('[data-testid="primary-document-file"]').attachFile({ - fileContent, - fileName: 'sample.pdf', - mimeType: 'application/pdf', + describe('uploads and edits a court-issued docket entry from draft documents view', () => { + it('should let a docket clerk upload a court-issued docket entry and the edit it while it is unsigned', () => { + const leadCase = '111-19'; + + loginAsDocketClerk1(); + goToCase(leadCase); + + // Arrange: create the docket entry + cy.get('[data-testid="case-detail-menu-button"]').click(); + cy.get('[data-testid="menu-button-upload-pdf"]').click(); + const title = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').type(title); + cy.readFile('cypress/helpers/file/sample.pdf', null).then(fileContent => { + cy.get('[data-testid="primary-document-file"]').attachFile({ + fileContent, + fileName: 'sample.pdf', + mimeType: 'application/pdf', + }); + cy.get('[data-testid="save-uploaded-pdf-button"]').click(); + }); + + // Act: edit the docket entry + cy.get('[data-testid="tab-drafts"').click(); + cy.get('[data-testid="draft-edit-button-not-signed"]').click(); + const newTitle = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').clear(); + cy.get('[data-testid="upload-description"]').type(newTitle); + cy.get('[data-testid="save-edited-pdf-button"]').click(); + + // Assert: the new description should display for the edited docket entry + cy.contains('Draft saved.').should('exist'); + cy.get('[data-testid^="docket-entry-description-"]').then($els => { + const matchingElements = $els.filter((index, el) => { + return Cypress.$(el).text().includes(newTitle); + }); + + expect( + matchingElements.length, + `Expected to find "${newTitle}" in at least one element`, + ).to.be.greaterThan(0); }); - cy.get('[data-testid="save-uploaded-pdf-button"]').click(); }); - // Act: edit the docket entry - cy.get('[data-testid="tab-drafts"').click(); - cy.get('[data-testid="draft-edit-button-not-signed"]').click(); - const newTitle = `${faker.word.adjective()} ${faker.word.noun()}`; - cy.get('[data-testid="upload-description"]').clear(); - cy.get('[data-testid="upload-description"]').type(newTitle); - cy.get('[data-testid="save-edited-pdf-button"]').click(); - - // Assert: the new description should display for the edited docket entry - cy.get('[data-testid^="docket-entry-description-"]').then($els => { - const matchingElements = $els.filter((index, el) => { - return Cypress.$(el).text().includes(newTitle); + it('should let a docket clerk upload a court-issued docket entry and the edit it after it is signed', () => { + const leadCase = '111-19'; + + loginAsDocketClerk1(); + goToCase(leadCase); + + // Arrange: create the docket entry and sign it + cy.get('[data-testid="case-detail-menu-button"]').click(); + cy.get('[data-testid="menu-button-upload-pdf"]').click(); + const title = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').type(title); + cy.readFile('cypress/helpers/file/sample.pdf', null).then(fileContent => { + cy.get('[data-testid="primary-document-file"]').attachFile({ + fileContent, + fileName: 'sample.pdf', + mimeType: 'application/pdf', + }); + cy.get('[data-testid="save-uploaded-pdf-button"]').click(); }); + cy.get('#apply-signature').click(); + cy.get('[data-testid="sign-pdf-canvas"]').click(); + cy.get('[data-testid="save-signature-button"]').click(); + + // Act: edit the docket entry + cy.get('[data-testid="edit-order-button"]').click(); + cy.get('[data-testid="modal-button-confirm"]').click(); + const newTitle = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').clear(); + cy.get('[data-testid="upload-description"]').type(newTitle); + cy.get('[data-testid="save-edited-pdf-button"]').click(); - expect( - matchingElements.length, - `Expected to find "${newTitle}" in at least one element`, - ).to.be.greaterThan(0); + // Assert: the new description should display for the edited docket entry + cy.contains('Draft saved.').should('exist'); + cy.get('[data-testid^="docket-entry-description-"]').then($els => { + const matchingElements = $els.filter((index, el) => { + return Cypress.$(el).text().includes(newTitle); + }); + + expect( + matchingElements.length, + `Expected to find "${newTitle}" in at least one element`, + ).to.be.greaterThan(0); + }); }); }); - it('should let a docket clerk upload a court-issued docket entry and the edit it after it is signed', () => { - const leadCase = '111-19'; - - loginAsDocketClerk1(); - goToCase(leadCase); - - // Arrange: create the docket entry and sign it - cy.get('[data-testid="case-detail-menu-button"]').click(); - cy.get('[data-testid="menu-button-upload-pdf"]').click(); - const title = `${faker.word.adjective()} ${faker.word.noun()}`; - cy.get('[data-testid="upload-description"]').type(title); - cy.readFile('cypress/helpers/file/sample.pdf', null).then(fileContent => { - cy.get('[data-testid="primary-document-file"]').attachFile({ - fileContent, - fileName: 'sample.pdf', - mimeType: 'application/pdf', + describe('uploads and edits a court-issued docket entry from message view', () => { + it('should let a docket clerk upload a court-issued docket entry and the edit it while it is unsigned', () => { + const leadCase = '111-19'; + const caseServicesSupervisorId = '35959d1a-0981-40b2-a93d-f65c7977db52'; + + loginAsDocketClerk1(); + goToCase(leadCase); + + // Arrange: create the docket entry, sign it, and associate it with a new message + cy.get('[data-testid="case-detail-menu-button"]').click(); + cy.get('[data-testid="menu-button-upload-pdf"]').click(); + const title = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').type(title); + cy.readFile('cypress/helpers/file/sample.pdf', null).then(fileContent => { + cy.get('[data-testid="primary-document-file"]').attachFile({ + fileContent, + fileName: 'sample.pdf', + mimeType: 'application/pdf', + }); + cy.get('[data-testid="save-uploaded-pdf-button"]').click(); }); - cy.get('[data-testid="save-uploaded-pdf-button"]').click(); + + cy.get('#apply-signature').click(); + cy.get('[data-testid="sign-pdf-canvas"]').click(); + cy.get('[data-testid="save-signature-button"]').click(); + + cy.get('[data-testid="case-detail-menu-button"]').click(); + cy.get('[data-testid="menu-button-add-new-message"]').click(); + cy.get('[data-testid="message-to-section"]').select('docket'); + cy.get('[data-testid="message-to-user-id"]').select( + caseServicesSupervisorId, + ); + const messageTitle = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="message-subject"]').type(messageTitle); + cy.get('[data-testid="message-body"]').type('This is a message.'); + cy.get('[data-testid="select-document"]') + .contains('option', title) + .invoke('val') + .then(value => { + cy.get('[data-testid="select-document"]').select(value as string); + }); + cy.get('[data-testid="modal-confirm"]').click(); + cy.get('#tab-case-messages').click(); + cy.contains('a', title).click(); + + // Act: edit the docket entry from the messages view + cy.get('[data-testid="edit-signed-document-button"]').click(); + cy.get('[data-testid="modal-button-confirm"]').click(); + const newTitle = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').clear(); + cy.get('[data-testid="upload-description"]').type(newTitle); + cy.get('[data-testid="save-edited-pdf-button"]').click(); + + // Assert: the new description should display for the edited docket entry + cy.contains('Draft saved.').should('exist'); + cy.contains('.attachment-viewer-button', newTitle).should('exist'); }); - cy.get('#apply-signature').click(); - cy.get('[data-testid="sign-pdf-canvas"]').click(); - cy.get('[data-testid="save-signature-button"]').click(); - - // Act: edit the docket entry - cy.get('[data-testid="edit-order-button"]').click(); - cy.get('[data-testid="modal-button-confirm"]').click(); - const newTitle = `${faker.word.adjective()} ${faker.word.noun()}`; - cy.get('[data-testid="upload-description"]').clear(); - cy.get('[data-testid="upload-description"]').type(newTitle); - cy.get('[data-testid="save-edited-pdf-button"]').click(); - - // Assert: the new description should display for the edited docket entry - cy.get('[data-testid^="docket-entry-description-"]').then($els => { - const matchingElements = $els.filter((index, el) => { - return Cypress.$(el).text().includes(newTitle); + + it('should let a docket clerk upload a court-issued docket entry and the edit it after it is signed', () => { + const leadCase = '111-19'; + const caseServicesSupervisorId = '35959d1a-0981-40b2-a93d-f65c7977db52'; + + loginAsDocketClerk1(); + goToCase(leadCase); + + // Arrange: create the docket entry and associate it with a new message + cy.get('[data-testid="case-detail-menu-button"]').click(); + cy.get('[data-testid="menu-button-upload-pdf"]').click(); + const title = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').type(title); + cy.readFile('cypress/helpers/file/sample.pdf', null).then(fileContent => { + cy.get('[data-testid="primary-document-file"]').attachFile({ + fileContent, + fileName: 'sample.pdf', + mimeType: 'application/pdf', + }); + cy.get('[data-testid="save-uploaded-pdf-button"]').click(); }); + cy.get('[data-testid="case-detail-menu-button"]').click(); + cy.get('[data-testid="menu-button-add-new-message"]').click(); + cy.get('[data-testid="message-to-section"]').select('docket'); + cy.get('[data-testid="message-to-user-id"]').select( + caseServicesSupervisorId, + ); + const messageTitle = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="message-subject"]').type(messageTitle); + cy.get('[data-testid="message-body"]').type('This is a message.'); + cy.get('[data-testid="select-document"]') + .contains('option', title) + .invoke('val') + .then(value => { + cy.get('[data-testid="select-document"]').select(value as string); + }); + cy.get('[data-testid="modal-confirm"]').click(); + cy.get('#tab-case-messages').click(); + cy.contains('a', title).click(); + + // Act: edit the docket entry from the messages view + cy.get('[data-testid="edit-unsigned-document-button"]').click(); + const newTitle = `${faker.word.adjective()} ${faker.word.noun()}`; + cy.get('[data-testid="upload-description"]').clear(); + cy.get('[data-testid="upload-description"]').type(newTitle); + cy.get('[data-testid="save-edited-pdf-button"]').click(); - expect( - matchingElements.length, - `Expected to find "${newTitle}" in at least one element`, - ).to.be.greaterThan(0); + // Assert: the new description should display for the edited docket entry + cy.contains('Draft saved.').should('exist'); + cy.contains('.attachment-viewer-button', newTitle).should('exist'); }); }); }); diff --git a/web-client/src/views/Messages/MessageModalAttachments.tsx b/web-client/src/views/Messages/MessageModalAttachments.tsx index 714ebe0a609..09801e30bf6 100644 --- a/web-client/src/views/Messages/MessageModalAttachments.tsx +++ b/web-client/src/views/Messages/MessageModalAttachments.tsx @@ -108,6 +108,7 @@ export const MessageModalAttachments = connect( { - updateTrialSessionFormDataSequence({ - key: e.target.name, - value: e.target.value, - }); - validateTrialSessionSequence(); - }} - /> - -
- ))} + {addTrialSessionInformationHelper + .getSessionTypes(user) + .map(option => ( +
+ { + updateTrialSessionFormDataSequence({ + key: e.target.name, + value: e.target.value, + }); + validateTrialSessionSequence(); + }} + /> + +
+ ))} {!addTrialSessionInformationHelper.isStandaloneSession && ( From eeafed927b3cd43d12b95ab48a0006b96a1f353d Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Wed, 21 Aug 2024 21:30:53 -0400 Subject: [PATCH 509/523] 10439 add unit test for docketclerk sessionTypes filter --- .../addTrialSessionInformationHelper.test.ts | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts index c94868e43cc..9594ff7368a 100644 --- a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts +++ b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts @@ -115,13 +115,15 @@ describe('addTrialSessionInformationHelper', () => { describe('sessionTypes', () => { it(`should NOT include 'Special' or 'Motion/Hearing' when form.sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.standaloneRemote}`, () => { + const user = { role: 'clerkofclerk' }; const result = runCompute(addTrialSessionInformationHelper, { state: { form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote }, + user, }, }); - expect(result.sessionTypes).toEqual([ + expect(result.getSessionTypes(user)).toEqual([ 'Regular', 'Small', 'Hybrid', @@ -130,13 +132,15 @@ describe('addTrialSessionInformationHelper', () => { }); it(`should include 'Special' and 'Motion/Hearing' when form.sessionScope is ${TRIAL_SESSION_SCOPE_TYPES.locationBased}`, () => { + const user = { role: 'clerkofclerk' }; const result = runCompute(addTrialSessionInformationHelper, { state: { form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased }, + user, }, }); - expect(result.sessionTypes).toEqual([ + expect(result.getSessionTypes(user)).toEqual([ 'Regular', 'Small', 'Hybrid', @@ -145,5 +149,20 @@ describe('addTrialSessionInformationHelper', () => { 'Motion/Hearing', ]); }); + + it("should ONLY include 'Special' or 'Motion/Hearing' trial sessions when role is docketclerk}", () => { + const user = { role: 'docketclerk' }; + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote }, + user, + }, + }); + + expect(result.getSessionTypes(user)).toEqual([ + 'Special', + 'Motion/Hearing', + ]); + }); }); }); From 7fe0bd3a33098cd1d32d305a36c25e7958f0bdc1 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 29 Aug 2024 11:09:23 -0400 Subject: [PATCH 510/523] add tests for docketClerkUser edit perms --- .../addTrialSessionInformationHelper.ts | 1 + .../formattedTrialSessionDetails.test.ts | 114 ++++++++++++++---- .../computeds/formattedTrialSessionDetails.ts | 9 +- 3 files changed, 97 insertions(+), 27 deletions(-) diff --git a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts index 37998ab662c..59a0f817e02 100644 --- a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts +++ b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts @@ -34,6 +34,7 @@ export const addTrialSessionInformationHelper = ( // NOTE: what happens if isStandaloneSession is true and user is docketclerk? const getSessionTypes = (user: AuthUser) => { + console.log('user: ', user); return user.role === 'docketclerk' ? ['Special', 'Motion/Hearing'] : sessionTypes; diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts index 93b4509897f..c9ceaa07529 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts @@ -8,7 +8,7 @@ import { import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { colvinsChambersUser, - docketClerk1User, + docketClerkUser, } from '../../../../shared/src/test/mockUsers'; import { formattedTrialSessionDetails as formattedTrialSessionDetailsComputed } from './formattedTrialSessionDetails'; import { omit } from 'lodash'; @@ -63,7 +63,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -78,7 +78,7 @@ describe('formattedTrialSessionDetails', () => { let result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -91,7 +91,7 @@ describe('formattedTrialSessionDetails', () => { result = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -123,7 +123,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -138,7 +138,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -151,7 +151,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -169,7 +169,7 @@ describe('formattedTrialSessionDetails', () => { isCalendared: false, startDate: PAST_DATE, }, - user: docketClerk1User, + user: docketClerkUser, }, }); expect(result).toMatchObject({ @@ -187,7 +187,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -206,7 +206,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -225,7 +225,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -244,7 +244,7 @@ describe('formattedTrialSessionDetails', () => { sessionStatus: SESSION_STATUS_GROUPS.open, startDate: PAST_DATE, }, - user: docketClerk1User, + user: docketClerkUser, }, }); expect(result).toMatchObject({ @@ -262,7 +262,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -281,7 +281,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -290,6 +290,68 @@ describe('formattedTrialSessionDetails', () => { }); }); + describe('docketClerk user canEdit', () => { + it('should be true when canEdit is true and docketClerk user is editing a Special TrialSession', () => { + mockTrialSession = { + ...TRIAL_SESSION, + sessionStatus: SESSION_STATUS_GROUPS.open, + sessionType: SESSION_TYPES.special, + startDate: FUTURE_DATE, + }; + + const result: any = runCompute(formattedTrialSessionDetails, { + state: { + trialSession: {}, + user: docketClerkUser, + }, + }); + + expect(result).toMatchObject({ + canEdit: true, + }); + }); + + it('should be true when canEdit is true and docketClerk user is editing a Motion/Hearing TrialSession', () => { + mockTrialSession = { + ...TRIAL_SESSION, + sessionStatus: SESSION_STATUS_GROUPS.open, + sessionType: SESSION_TYPES.motionHearing, + startDate: FUTURE_DATE, + }; + + const result: any = runCompute(formattedTrialSessionDetails, { + state: { + trialSession: {}, + user: docketClerkUser, + }, + }); + + expect(result).toMatchObject({ + canEdit: true, + }); + }); + + it('should be false when docketClerk user sees a non- Motion/Hearing or Special TrialSession', () => { + mockTrialSession = { + ...TRIAL_SESSION, + sessionStatus: SESSION_STATUS_GROUPS.open, + sessionType: SESSION_TYPES.hybrid, + startDate: FUTURE_DATE, + }; + + const result: any = runCompute(formattedTrialSessionDetails, { + state: { + trialSession: {}, + user: docketClerkUser, + }, + }); + + expect(result).toMatchObject({ + canEdit: false, + }); + }); + }); + it('should be false when trial session start date is in the future, it is NOT closed, the user is a chambers role', () => { mockTrialSession = { ...TRIAL_SESSION, @@ -319,7 +381,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -341,7 +403,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -359,7 +421,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -377,7 +439,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); expect(result.canClose).toBe(false); @@ -394,7 +456,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -412,7 +474,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -430,7 +492,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -450,7 +512,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -472,7 +534,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -494,7 +556,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -514,7 +576,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerk1User, + user: docketClerkUser, }, }); @@ -535,7 +597,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerk1User, + user: docketClerkUser, }, }, ); diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts index 8f9ec569885..f4f17cbfb68 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts @@ -88,8 +88,11 @@ export const formattedTrialSessionDetails = ( const user = get(state.user); const isChambersUser = user.role === USER_ROLES.chambers; - const trialDateInFuture = trialDateFormatted > nowDateFormatted; + const docketClerkCanEditCheck = sessionType => { + const editableSessionTypes = ['Special', 'Motion/Hearing']; + return editableSessionTypes.includes(sessionType); + }; canDelete = trialDateInFuture && !formattedTrialSession.isCalendared; canEdit = @@ -97,6 +100,10 @@ export const formattedTrialSessionDetails = ( formattedTrialSession.sessionStatus !== SESSION_STATUS_GROUPS.closed && !isChambersUser; + if (user.role === USER_ROLES.docketClerk && canEdit) { + canEdit = docketClerkCanEditCheck(formattedTrialSession.sessionType); + } + const allCases = formattedTrialSession.caseOrder || []; const inactiveCases = allCases.filter( sessionCase => sessionCase.removedFromTrial === true, From 4e283b1a89580e957d808011a040ce570b3a6bf2 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Wed, 21 Aug 2024 23:11:55 -0400 Subject: [PATCH 511/523] rm debug log statement --- .../computeds/TrialSession/addTrialSessionInformationHelper.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts index 59a0f817e02..37998ab662c 100644 --- a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts +++ b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts @@ -34,7 +34,6 @@ export const addTrialSessionInformationHelper = ( // NOTE: what happens if isStandaloneSession is true and user is docketclerk? const getSessionTypes = (user: AuthUser) => { - console.log('user: ', user); return user.role === 'docketclerk' ? ['Special', 'Motion/Hearing'] : sessionTypes; From fb2af59ce1daca7b1501f72b4431acdcc0c63e1a Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Mon, 26 Aug 2024 10:19:17 -0400 Subject: [PATCH 512/523] 10439 use declared constants for sessionTypes addresses PR Feedback --- .../TrialSession/addTrialSessionInformationHelper.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts index 37998ab662c..f4762da0487 100644 --- a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts +++ b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts @@ -24,18 +24,21 @@ export const addTrialSessionInformationHelper = ( proceedingType === TRIAL_SESSION_PROCEEDING_TYPES.remote || isStandaloneSession; + const DISALLOWED_STANDALONE_SESSION_TYPES = ['Special', 'Motion/Hearing']; + const DOCKETCLERK_EDITABLE_SESSION_TYPES = ['Special', 'Motion/Hearing']; + let sessionTypes = Object.values(SESSION_TYPES); if (isStandaloneSession) { sessionTypes = sessionTypes.filter(type => { - return !['Special', 'Motion/Hearing'].includes(type); + return !DISALLOWED_STANDALONE_SESSION_TYPES.includes(type); }); } // NOTE: what happens if isStandaloneSession is true and user is docketclerk? const getSessionTypes = (user: AuthUser) => { return user.role === 'docketclerk' - ? ['Special', 'Motion/Hearing'] + ? DOCKETCLERK_EDITABLE_SESSION_TYPES : sessionTypes; }; const today = applicationContext.getUtilities().formatNow(FORMATS.YYYYMMDD); From fdef4e21c7eefb79417320e67352948dc5648281 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Mon, 26 Aug 2024 12:19:32 -0400 Subject: [PATCH 513/523] devex add loginAsUser function to fix race conditions in cypress tests --- cypress/helpers/authentication/login-as-helpers.ts | 6 +++++- ...n-user-can-see-un-served-petition-document.cy.ts | 13 +++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cypress/helpers/authentication/login-as-helpers.ts b/cypress/helpers/authentication/login-as-helpers.ts index 77d6e1234c9..b3dad8be792 100644 --- a/cypress/helpers/authentication/login-as-helpers.ts +++ b/cypress/helpers/authentication/login-as-helpers.ts @@ -61,7 +61,11 @@ export function loginAsIrsPractitioner1() { } export function loginAsPetitioner( - petitionerUser: 'petitioner' | 'petitioner1' | 'petitioner7' = 'petitioner1', + petitionerUser: + | 'petitioner' + | 'petitioner1' + | 'petitioner2' + | 'petitioner7' = 'petitioner1', ) { cy.login(petitionerUser); cy.get('[data-testid="file-a-petition"]').should('exist'); diff --git a/cypress/local-only/tests/integration/caseDetail/docketRecord/electronicFiling/logged-in-user-can-see-un-served-petition-document.cy.ts b/cypress/local-only/tests/integration/caseDetail/docketRecord/electronicFiling/logged-in-user-can-see-un-served-petition-document.cy.ts index 6fd23258bc2..82f7e668dcb 100644 --- a/cypress/local-only/tests/integration/caseDetail/docketRecord/electronicFiling/logged-in-user-can-see-un-served-petition-document.cy.ts +++ b/cypress/local-only/tests/integration/caseDetail/docketRecord/electronicFiling/logged-in-user-can-see-un-served-petition-document.cy.ts @@ -1,5 +1,6 @@ import { externalUserSearchesDocketNumber } from '../../../../../../helpers/advancedSearch/external-user-searches-docket-number'; import { + loginAsDocketClerk1, loginAsPetitioner, loginAsPrivatePractitioner, } from '../../../../../../helpers/authentication/login-as-helpers'; @@ -13,7 +14,7 @@ describe('Logged In User Can See Un-Served Petition Document', () => { loginAsPetitioner(); petitionerCreatesElectronicCaseForBusiness().as('DOCKET_NUMBER'); - cy.login('petitioner1'); + loginAsPetitioner('petitioner1'); cy.get('@DOCKET_NUMBER').then(docketNumber => { externalUserSearchesDocketNumber(docketNumber); }); @@ -23,7 +24,7 @@ describe('Logged In User Can See Un-Served Petition Document', () => { cy.get('[data-testid="document-download-link-DISC"]').should('exist'); cy.get('[data-testid="document-download-link-ATP"]').should('exist'); - cy.login('petitioner2'); + loginAsPetitioner('petitioner2'); cy.get('@DOCKET_NUMBER').then(docketNumber => { externalUserSearchesDocketNumber(docketNumber); }); @@ -33,7 +34,7 @@ describe('Logged In User Can See Un-Served Petition Document', () => { cy.get('[data-testid="document-download-link-DISC"]').should('not.exist'); cy.get('[data-testid="document-download-link-ATP"]').should('not.exist'); - cy.login('docketClerk1'); + loginAsDocketClerk1(); cy.get('@DOCKET_NUMBER').then(docketNumber => { cy.get('[data-testid="docket-number-search-input"]').type(docketNumber); cy.get('[data-testid="search-docket-number"]').click(); @@ -49,7 +50,7 @@ describe('Logged In User Can See Un-Served Petition Document', () => { loginAsPrivatePractitioner(); privatePractitionerCreatesElectronicCaseForBusiness().as('DOCKET_NUMBER'); - cy.login('privatePractitioner1'); + loginAsPrivatePractitioner('privatePractitioner1'); cy.get('@DOCKET_NUMBER').then(docketNumber => { externalUserSearchesDocketNumber(docketNumber); }); @@ -59,7 +60,7 @@ describe('Logged In User Can See Un-Served Petition Document', () => { cy.get('[data-testid="document-download-link-DISC"]').should('exist'); cy.get('[data-testid="document-download-link-ATP"]').should('exist'); - cy.login('privatePractitioner2'); + loginAsPrivatePractitioner('privatePractitioner2'); cy.get('@DOCKET_NUMBER').then(docketNumber => { externalUserSearchesDocketNumber(docketNumber); }); @@ -69,7 +70,7 @@ describe('Logged In User Can See Un-Served Petition Document', () => { cy.get('[data-testid="document-download-link-DISC"]').should('not.exist'); cy.get('[data-testid="document-download-link-ATP"]').should('not.exist'); - cy.login('docketClerk1'); + loginAsDocketClerk1(); cy.get('@DOCKET_NUMBER').then(docketNumber => { cy.get('[data-testid="docket-number-search-input"]').type(docketNumber); cy.get('[data-testid="search-docket-number"]').click(); From b30923fe5956bd6d2955752cae884f444d7f5689 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Mon, 26 Aug 2024 12:57:43 -0400 Subject: [PATCH 514/523] rm logic from tsx file and fix type errors --- .../addTrialSessionInformationHelper.ts | 10 +- .../views/TrialSessions/EditTrialSession.tsx | 2 +- .../TrialSessions/SessionInformationForm.tsx | 94 ++++++++++--------- 3 files changed, 58 insertions(+), 48 deletions(-) diff --git a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts index f4762da0487..053875fd7db 100644 --- a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts +++ b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts @@ -8,7 +8,13 @@ import { state } from '@web-client/presenter/app.cerebral'; export const addTrialSessionInformationHelper = ( get: Get, applicationContext: ClientApplicationContext, -): any => { +): { + displayRemoteProceedingForm: boolean; + isStandaloneSession: boolean; + sessionTypes: string[]; + title: string; + today: string; +} => { const { SESSION_TYPES, TRIAL_SESSION_PROCEEDING_TYPES } = applicationContext.getConstants(); @@ -45,8 +51,8 @@ export const addTrialSessionInformationHelper = ( return { displayRemoteProceedingForm, - getSessionTypes, isStandaloneSession, + sessionTypes: getSessionTypes(get(state.user)), title, today, }; diff --git a/web-client/src/views/TrialSessions/EditTrialSession.tsx b/web-client/src/views/TrialSessions/EditTrialSession.tsx index 28c5eee0993..1d736668b27 100644 --- a/web-client/src/views/TrialSessions/EditTrialSession.tsx +++ b/web-client/src/views/TrialSessions/EditTrialSession.tsx @@ -48,7 +48,7 @@ export const EditTrialSession = connect( All fields required unless otherwise noted

- + diff --git a/web-client/src/views/TrialSessions/SessionInformationForm.tsx b/web-client/src/views/TrialSessions/SessionInformationForm.tsx index b6fda2099f4..7e529d4dcc5 100644 --- a/web-client/src/views/TrialSessions/SessionInformationForm.tsx +++ b/web-client/src/views/TrialSessions/SessionInformationForm.tsx @@ -6,21 +6,28 @@ import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; import classNames from 'classnames'; -export const SessionInformationForm = connect( - { - DATE_FORMATS: state.constants.DATE_FORMATS, - TRIAL_SESSION_SCOPE_TYPES: state.constants.TRIAL_SESSION_SCOPE_TYPES, - addTrialSessionInformationHelper: state.addTrialSessionInformationHelper, - form: state.form, - formatAndUpdateDateFromDatePickerSequence: - sequences.formatAndUpdateDateFromDatePickerSequence, - formattedTrialSessions: state.formattedTrialSessions, - updateTrialSessionFormDataSequence: - sequences.updateTrialSessionFormDataSequence, - user: state.user, - validateTrialSessionSequence: sequences.validateTrialSessionSequence, - validationErrors: state.validationErrors, - }, +type SessionInformationFormProps = { addingTrialSession: boolean }; + +const sessionInformationDeps = { + DATE_FORMATS: state.constants.DATE_FORMATS, + TRIAL_SESSION_SCOPE_TYPES: state.constants.TRIAL_SESSION_SCOPE_TYPES, + addTrialSessionInformationHelper: state.addTrialSessionInformationHelper, + form: state.form, + formatAndUpdateDateFromDatePickerSequence: + sequences.formatAndUpdateDateFromDatePickerSequence, + formattedTrialSessions: state.formattedTrialSessions, + updateTrialSessionFormDataSequence: + sequences.updateTrialSessionFormDataSequence, + user: state.user, + validateTrialSessionSequence: sequences.validateTrialSessionSequence, + validationErrors: state.validationErrors, +}; + +export const SessionInformationForm = connect< + SessionInformationFormProps, + typeof sessionInformationDeps +>( + sessionInformationDeps, function SessionInformationForm({ addingTrialSession, addTrialSessionInformationHelper, @@ -30,7 +37,6 @@ export const SessionInformationForm = connect( formattedTrialSessions, TRIAL_SESSION_SCOPE_TYPES, updateTrialSessionFormDataSequence, - user, validateTrialSessionSequence, validationErrors, }) { @@ -291,35 +297,33 @@ export const SessionInformationForm = connect( Session type - {addTrialSessionInformationHelper - .getSessionTypes(user) - .map(option => ( -
- { - updateTrialSessionFormDataSequence({ - key: e.target.name, - value: e.target.value, - }); - validateTrialSessionSequence(); - }} - /> - -
- ))} + {addTrialSessionInformationHelper.sessionTypes.map(option => ( +
+ { + updateTrialSessionFormDataSequence({ + key: e.target.name, + value: e.target.value, + }); + validateTrialSessionSequence(); + }} + /> + +
+ ))} {!addTrialSessionInformationHelper.isStandaloneSession && ( From f8c8f48764ae75b727f68400c56938d5f613255c Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Mon, 26 Aug 2024 17:09:16 -0400 Subject: [PATCH 515/523] 10439 fix tests after refactor --- .../addTrialSessionInformationHelper.test.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts index 9594ff7368a..dbc6603e246 100644 --- a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts +++ b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts @@ -20,6 +20,7 @@ describe('addTrialSessionInformationHelper', () => { const result = runCompute(addTrialSessionInformationHelper, { state: { form: { proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote }, + user: { role: 'docketclerk' }, }, }); @@ -30,6 +31,7 @@ describe('addTrialSessionInformationHelper', () => { const result = runCompute(addTrialSessionInformationHelper, { state: { form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote }, + user: { role: 'docketclerk' }, }, }); @@ -40,6 +42,7 @@ describe('addTrialSessionInformationHelper', () => { const result = runCompute(addTrialSessionInformationHelper, { state: { form: { proceedingType: 'def', sessionScope: 'abc' }, + user: { role: 'docketclerk' }, }, }); @@ -52,6 +55,7 @@ describe('addTrialSessionInformationHelper', () => { const result = runCompute(addTrialSessionInformationHelper, { state: { form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote }, + user: { role: 'docketclerk' }, }, }); @@ -62,6 +66,7 @@ describe('addTrialSessionInformationHelper', () => { const result = runCompute(addTrialSessionInformationHelper, { state: { form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased }, + user: { role: 'docketclerk' }, }, }); @@ -74,6 +79,7 @@ describe('addTrialSessionInformationHelper', () => { const result = runCompute(addTrialSessionInformationHelper, { state: { form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote }, + user: { role: 'docketclerk' }, }, }); @@ -84,6 +90,7 @@ describe('addTrialSessionInformationHelper', () => { const result = runCompute(addTrialSessionInformationHelper, { state: { form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased }, + user: { role: 'docketclerk' }, }, }); @@ -96,6 +103,7 @@ describe('addTrialSessionInformationHelper', () => { const result = runCompute(addTrialSessionInformationHelper, { state: { form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote }, + user: { role: 'docketclerk' }, }, }); @@ -106,6 +114,7 @@ describe('addTrialSessionInformationHelper', () => { const result = runCompute(addTrialSessionInformationHelper, { state: { form: { sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased }, + user: { role: 'docketclerk' }, }, }); @@ -123,7 +132,7 @@ describe('addTrialSessionInformationHelper', () => { }, }); - expect(result.getSessionTypes(user)).toEqual([ + expect(result.sessionTypes).toEqual([ 'Regular', 'Small', 'Hybrid', @@ -140,7 +149,7 @@ describe('addTrialSessionInformationHelper', () => { }, }); - expect(result.getSessionTypes(user)).toEqual([ + expect(result.sessionTypes).toEqual([ 'Regular', 'Small', 'Hybrid', @@ -159,10 +168,7 @@ describe('addTrialSessionInformationHelper', () => { }, }); - expect(result.getSessionTypes(user)).toEqual([ - 'Special', - 'Motion/Hearing', - ]); + expect(result.sessionTypes).toEqual(['Special', 'Motion/Hearing']); }); }); }); From 2b75d8e1c2b25e5ac6727a1c380e3fe6139ad6db Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 29 Aug 2024 11:15:07 -0400 Subject: [PATCH 516/523] 10439 merge and test fixes --- .../formattedTrialSessionDetails.test.ts | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts index c9ceaa07529..5f7ac902ce3 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts @@ -9,6 +9,7 @@ import { applicationContextForClient as applicationContext } from '@web-client/t import { colvinsChambersUser, docketClerkUser, + trialClerkUser, } from '../../../../shared/src/test/mockUsers'; import { formattedTrialSessionDetails as formattedTrialSessionDetailsComputed } from './formattedTrialSessionDetails'; import { omit } from 'lodash'; @@ -63,7 +64,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -78,7 +79,7 @@ describe('formattedTrialSessionDetails', () => { let result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -91,7 +92,7 @@ describe('formattedTrialSessionDetails', () => { result = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -123,7 +124,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -138,7 +139,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -151,7 +152,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -169,7 +170,7 @@ describe('formattedTrialSessionDetails', () => { isCalendared: false, startDate: PAST_DATE, }, - user: docketClerkUser, + user: trialClerkUser, }, }); expect(result).toMatchObject({ @@ -187,7 +188,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -206,7 +207,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -225,7 +226,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -244,7 +245,7 @@ describe('formattedTrialSessionDetails', () => { sessionStatus: SESSION_STATUS_GROUPS.open, startDate: PAST_DATE, }, - user: docketClerkUser, + user: trialClerkUser, }, }); expect(result).toMatchObject({ @@ -262,7 +263,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -281,7 +282,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -381,7 +382,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -403,7 +404,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -421,7 +422,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -439,7 +440,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); expect(result.canClose).toBe(false); @@ -456,7 +457,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -474,7 +475,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -492,7 +493,7 @@ describe('formattedTrialSessionDetails', () => { const result: any = runCompute(formattedTrialSessionDetails, { state: { trialSession: {}, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -512,7 +513,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -534,7 +535,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -556,7 +557,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -576,7 +577,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerkUser, + user: trialClerkUser, }, }); @@ -597,7 +598,7 @@ describe('formattedTrialSessionDetails', () => { trialSession: { ...mockTrialSession, }, - user: docketClerkUser, + user: trialClerkUser, }, }, ); From 54e1effdf68c9b7c7d9528b6e8474a5d28ea53fb Mon Sep 17 00:00:00 2001 From: John Cruz Date: Thu, 29 Aug 2024 09:42:34 -0600 Subject: [PATCH 517/523] 10377: Remove default debounce logic; --- web-client/src/ustc-ui/Button/Button.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-client/src/ustc-ui/Button/Button.tsx b/web-client/src/ustc-ui/Button/Button.tsx index 7fc968fd830..38b4da3abf5 100644 --- a/web-client/src/ustc-ui/Button/Button.tsx +++ b/web-client/src/ustc-ui/Button/Button.tsx @@ -9,7 +9,7 @@ function getUpdatedOnClick( setDisableButton: React.Dispatch>, ) { if (!onClick) return onClick; - if (!disableOnClick) return debounce(onClick, 500); + if (!disableOnClick) return onClick; const debouncedWrapper = debounce(async (...args) => { const results = onClick(...args); From b5f93734bf2e8840aba5b866c3ab6f23ec5e5ac7 Mon Sep 17 00:00:00 2001 From: John Cruz Date: Thu, 29 Aug 2024 09:44:26 -0600 Subject: [PATCH 518/523] 10377: Merge if conditions; --- web-client/src/ustc-ui/Button/Button.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web-client/src/ustc-ui/Button/Button.tsx b/web-client/src/ustc-ui/Button/Button.tsx index 38b4da3abf5..0a174db8238 100644 --- a/web-client/src/ustc-ui/Button/Button.tsx +++ b/web-client/src/ustc-ui/Button/Button.tsx @@ -8,8 +8,7 @@ function getUpdatedOnClick( disableOnClick: boolean | undefined, setDisableButton: React.Dispatch>, ) { - if (!onClick) return onClick; - if (!disableOnClick) return onClick; + if (!onClick || !disableOnClick) return onClick; const debouncedWrapper = debounce(async (...args) => { const results = onClick(...args); From 828950a86190ba84bcf7d94d5dc6a7f9bc14dedc Mon Sep 17 00:00:00 2001 From: TomElliottFlexion <66225176+TomElliottFlexion@users.noreply.github.com> Date: Thu, 29 Aug 2024 12:09:24 -0500 Subject: [PATCH 519/523] 10397: fix typo --- web-client/src/ustc-ui/Pagination/Paginator.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index 392a65046b0..1beb6346bc7 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -46,7 +46,7 @@ export const Paginator = ({ > + +
+
@@ -128,28 +155,6 @@ export const EditCorrespondenceDocument = connect( )}
- -
-
- - -
-
diff --git a/web-client/src/views/EditUploadCourtIssuedDocument/EditUploadCourtIssuedDocument.tsx b/web-client/src/views/EditUploadCourtIssuedDocument/EditUploadCourtIssuedDocument.tsx index 7f3d9ad136c..c5ffe364751 100644 --- a/web-client/src/views/EditUploadCourtIssuedDocument/EditUploadCourtIssuedDocument.tsx +++ b/web-client/src/views/EditUploadCourtIssuedDocument/EditUploadCourtIssuedDocument.tsx @@ -5,7 +5,7 @@ import { ErrorNotification } from '../ErrorNotification'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FormCancelModalDialog } from '../FormCancelModalDialog'; import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; -import { Hint } from '../../ustc-ui/Hint/Hint'; +import { InfoNotificationComponent } from '../InfoNotification'; import { StateDrivenFileInput } from '../FileDocument/StateDrivenFileInput'; import { SuccessNotification } from '../SuccessNotification'; import { connect } from '@web-client/presenter/shared.cerebral'; @@ -54,7 +54,13 @@ export const EditUploadCourtIssuedDocument = connect( {screenMetadata.documentReset && ( - When you submit it will overwrite the previous document + )}
@@ -93,6 +99,29 @@ export const EditUploadCourtIssuedDocument = connect( />
+
+
+ + +
+
@@ -172,30 +201,6 @@ export const EditUploadCourtIssuedDocument = connect( )}
- -
-
- - -
-
From 9c638997df31e2a85debe2fe61ea55fb1cfe70bb Mon Sep 17 00:00:00 2001 From: Andy Kuny Date: Fri, 30 Aug 2024 11:08:22 -0400 Subject: [PATCH 522/523] Revert "10399-refactor: move docket entry-related entities and tests in docketEntry directory" This reverts commit ad167b33dc3b9647a63f26598f345659291b4ec5. --- .../{docketEntry => }/DocketEntry.archive.test.ts | 2 +- .../DocketEntry.fetchRootDocument.test.ts | 0 .../DocketEntry.generateFiledBy.test.ts | 6 +++--- .../DocketEntry.getServedPartiesCode.test.ts | 2 +- .../{docketEntry => }/DocketEntry.isAutoServed.test.ts | 4 ++-- .../DocketEntry.isCourtIssued.test.ts | 2 +- .../DocketEntry.isMinuteEntry.test.ts | 4 ++-- .../{docketEntry => }/DocketEntry.isPending.test.ts | 0 .../DocketEntry.isPendingOnCreation.test.ts | 2 +- .../{docketEntry => }/DocketEntry.isPublic.test.ts | 4 ++-- .../{docketEntry => }/DocketEntry.isServed.test.ts | 2 +- .../DocketEntry.isTranscriptOldEnoughToUnseal.test.ts | 2 +- .../{docketEntry => }/DocketEntry.isUnservable.test.ts | 4 ++-- .../{docketEntry => }/DocketEntry.sealEntry.test.ts | 4 ++-- ...ocketEntry.setAsProcessingStatusAsCompleted.test.ts | 4 ++-- .../{docketEntry => }/DocketEntry.setAsServed.test.ts | 2 +- .../DocketEntry.setNumberOfPages.test.ts | 2 +- .../{docketEntry => }/DocketEntry.setQCed.test.ts | 2 +- .../{docketEntry => }/DocketEntry.setWorkItem.test.ts | 6 +++--- .../DocketEntry.shouldAutoGenerateDeadline.test.ts | 4 ++-- .../{docketEntry => }/DocketEntry.strikeEntry.test.ts | 2 +- .../entities/{docketEntry => }/DocketEntry.test.ts | 4 ++-- .../business/entities/{docketEntry => }/DocketEntry.ts | 10 +++++----- .../{docketEntry => }/DocketEntry.unsealEntry.test.ts | 4 ++-- .../DocketEntry.unsignDocument.test.ts | 2 +- .../{docketEntry => }/DocketEntry.validate.test.ts | 4 ++-- .../Docketentry.isDownloadable.test.ts | 2 +- 27 files changed, 43 insertions(+), 43 deletions(-) rename shared/src/business/entities/{docketEntry => }/DocketEntry.archive.test.ts (87%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.fetchRootDocument.test.ts (100%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.generateFiledBy.test.ts (97%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.getServedPartiesCode.test.ts (96%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.isAutoServed.test.ts (96%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.isCourtIssued.test.ts (87%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.isMinuteEntry.test.ts (92%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.isPending.test.ts (100%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.isPendingOnCreation.test.ts (96%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.isPublic.test.ts (99%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.isServed.test.ts (92%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.isTranscriptOldEnoughToUnseal.test.ts (98%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.isUnservable.test.ts (85%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.sealEntry.test.ts (85%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.setAsProcessingStatusAsCompleted.test.ts (85%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.setAsServed.test.ts (96%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.setNumberOfPages.test.ts (85%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.setQCed.test.ts (89%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.setWorkItem.test.ts (84%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.shouldAutoGenerateDeadline.test.ts (83%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.strikeEntry.test.ts (95%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.test.ts (99%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.ts (99%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.unsealEntry.test.ts (88%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.unsignDocument.test.ts (91%) rename shared/src/business/entities/{docketEntry => }/DocketEntry.validate.test.ts (99%) rename shared/src/business/entities/{docketEntry => }/Docketentry.isDownloadable.test.ts (99%) diff --git a/shared/src/business/entities/docketEntry/DocketEntry.archive.test.ts b/shared/src/business/entities/DocketEntry.archive.test.ts similarity index 87% rename from shared/src/business/entities/docketEntry/DocketEntry.archive.test.ts rename to shared/src/business/entities/DocketEntry.archive.test.ts index a95c6e9a9a8..cc99e7d6298 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.archive.test.ts +++ b/shared/src/business/entities/DocketEntry.archive.test.ts @@ -1,6 +1,6 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('archive', () => { it('archives the document', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.fetchRootDocument.test.ts b/shared/src/business/entities/DocketEntry.fetchRootDocument.test.ts similarity index 100% rename from shared/src/business/entities/docketEntry/DocketEntry.fetchRootDocument.test.ts rename to shared/src/business/entities/DocketEntry.fetchRootDocument.test.ts diff --git a/shared/src/business/entities/docketEntry/DocketEntry.generateFiledBy.test.ts b/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts similarity index 97% rename from shared/src/business/entities/docketEntry/DocketEntry.generateFiledBy.test.ts rename to shared/src/business/entities/DocketEntry.generateFiledBy.test.ts index 824e4b2941f..d9189a0ea78 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.generateFiledBy.test.ts +++ b/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts @@ -1,7 +1,7 @@ import { DocketEntry } from './DocketEntry'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; -import { NOTICE_OF_CHANGE_CONTACT_INFORMATION_MAP } from './../EntityConstants'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { MOCK_DOCUMENTS } from '../../test/mockDocketEntry'; +import { NOTICE_OF_CHANGE_CONTACT_INFORMATION_MAP } from './EntityConstants'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('generateFiledBy', () => { let mockDocketEntry; diff --git a/shared/src/business/entities/docketEntry/DocketEntry.getServedPartiesCode.test.ts b/shared/src/business/entities/DocketEntry.getServedPartiesCode.test.ts similarity index 96% rename from shared/src/business/entities/docketEntry/DocketEntry.getServedPartiesCode.test.ts rename to shared/src/business/entities/DocketEntry.getServedPartiesCode.test.ts index d3f474cbf5d..d5fc29cc0ef 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.getServedPartiesCode.test.ts +++ b/shared/src/business/entities/DocketEntry.getServedPartiesCode.test.ts @@ -1,4 +1,4 @@ -import { PARTIES_CODES, ROLES } from '../EntityConstants'; +import { PARTIES_CODES, ROLES } from './EntityConstants'; import { getServedPartiesCode } from './DocketEntry'; describe('getServedPartiesCode', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.isAutoServed.test.ts b/shared/src/business/entities/DocketEntry.isAutoServed.test.ts similarity index 96% rename from shared/src/business/entities/docketEntry/DocketEntry.isAutoServed.test.ts rename to shared/src/business/entities/DocketEntry.isAutoServed.test.ts index 31622a82a52..2b3eee9437c 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.isAutoServed.test.ts +++ b/shared/src/business/entities/DocketEntry.isAutoServed.test.ts @@ -3,8 +3,8 @@ import { DocketEntry } from './DocketEntry'; import { EXTERNAL_DOCUMENT_TYPES, SIMULTANEOUS_DOCUMENT_EVENT_CODES, -} from '../EntityConstants'; -import { applicationContext } from '../../test/createTestApplicationContext'; +} from './EntityConstants'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('isAutoServed', () => { it('should return true if the documentType is an external document and the document is not a Simultaneous Document', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.isCourtIssued.test.ts b/shared/src/business/entities/DocketEntry.isCourtIssued.test.ts similarity index 87% rename from shared/src/business/entities/docketEntry/DocketEntry.isCourtIssued.test.ts rename to shared/src/business/entities/DocketEntry.isCourtIssued.test.ts index d980a7eb560..b5476dad2b7 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.isCourtIssued.test.ts +++ b/shared/src/business/entities/DocketEntry.isCourtIssued.test.ts @@ -1,5 +1,5 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('isCourtIssued', () => { it('should return false when the docketEntry.eventCode is NOT in the list of court issued documents', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.isMinuteEntry.test.ts b/shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts similarity index 92% rename from shared/src/business/entities/docketEntry/DocketEntry.isMinuteEntry.test.ts rename to shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts index ad2eba2e56f..eac084fa798 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.isMinuteEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts @@ -1,6 +1,6 @@ import { DocketEntry } from './DocketEntry'; -import { MINUTE_ENTRIES_MAP } from '../EntityConstants'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { MINUTE_ENTRIES_MAP } from './EntityConstants'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('isMinuteEntry', () => { describe('non RQT event codes', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.isPending.test.ts b/shared/src/business/entities/DocketEntry.isPending.test.ts similarity index 100% rename from shared/src/business/entities/docketEntry/DocketEntry.isPending.test.ts rename to shared/src/business/entities/DocketEntry.isPending.test.ts diff --git a/shared/src/business/entities/docketEntry/DocketEntry.isPendingOnCreation.test.ts b/shared/src/business/entities/DocketEntry.isPendingOnCreation.test.ts similarity index 96% rename from shared/src/business/entities/docketEntry/DocketEntry.isPendingOnCreation.test.ts rename to shared/src/business/entities/DocketEntry.isPendingOnCreation.test.ts index 0a5089327a5..5e0230f145e 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.isPendingOnCreation.test.ts +++ b/shared/src/business/entities/DocketEntry.isPendingOnCreation.test.ts @@ -1,5 +1,5 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('isPendingOnCreation', () => { beforeAll(() => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.isPublic.test.ts b/shared/src/business/entities/DocketEntry.isPublic.test.ts similarity index 99% rename from shared/src/business/entities/docketEntry/DocketEntry.isPublic.test.ts rename to shared/src/business/entities/DocketEntry.isPublic.test.ts index fa989c4605b..840c0b4a28f 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.isPublic.test.ts +++ b/shared/src/business/entities/DocketEntry.isPublic.test.ts @@ -5,9 +5,9 @@ import { ORDER_EVENT_CODES, POLICY_DATE_IMPACTED_EVENTCODES, ROLES, -} from '../EntityConstants'; +} from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { createISODateString } from '../../utilities/DateHandler'; +import { createISODateString } from '../utilities/DateHandler'; describe('DocketEntry isPublic', () => { const visibilityChangeDate = createISODateString('2023-08-01', 'yyyy-MM-dd'); diff --git a/shared/src/business/entities/docketEntry/DocketEntry.isServed.test.ts b/shared/src/business/entities/DocketEntry.isServed.test.ts similarity index 92% rename from shared/src/business/entities/docketEntry/DocketEntry.isServed.test.ts rename to shared/src/business/entities/DocketEntry.isServed.test.ts index a9b21d77a35..9012e6415f1 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.isServed.test.ts +++ b/shared/src/business/entities/DocketEntry.isServed.test.ts @@ -1,5 +1,5 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('isServed', () => { it('should return false when servedAt is undefined and isLegacyServed is false', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.isTranscriptOldEnoughToUnseal.test.ts b/shared/src/business/entities/DocketEntry.isTranscriptOldEnoughToUnseal.test.ts similarity index 98% rename from shared/src/business/entities/docketEntry/DocketEntry.isTranscriptOldEnoughToUnseal.test.ts rename to shared/src/business/entities/DocketEntry.isTranscriptOldEnoughToUnseal.test.ts index 0e12c2c530a..6264ecf0f83 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.isTranscriptOldEnoughToUnseal.test.ts +++ b/shared/src/business/entities/DocketEntry.isTranscriptOldEnoughToUnseal.test.ts @@ -2,7 +2,7 @@ import { CORRECTED_TRANSCRIPT_EVENT_CODE, REVISED_TRANSCRIPT_EVENT_CODE, TRANSCRIPT_EVENT_CODE, -} from '../EntityConstants'; +} from './EntityConstants'; import { DocketEntry } from './DocketEntry'; import { calculateISODate, diff --git a/shared/src/business/entities/docketEntry/DocketEntry.isUnservable.test.ts b/shared/src/business/entities/DocketEntry.isUnservable.test.ts similarity index 85% rename from shared/src/business/entities/docketEntry/DocketEntry.isUnservable.test.ts rename to shared/src/business/entities/DocketEntry.isUnservable.test.ts index e29f3969400..e422b8b9b78 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.isUnservable.test.ts +++ b/shared/src/business/entities/DocketEntry.isUnservable.test.ts @@ -1,6 +1,6 @@ import { DocketEntry } from './DocketEntry'; -import { UNSERVABLE_EVENT_CODES } from '../EntityConstants'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { UNSERVABLE_EVENT_CODES } from './EntityConstants'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('isUnservable', () => { UNSERVABLE_EVENT_CODES.forEach(eventCode => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.sealEntry.test.ts b/shared/src/business/entities/DocketEntry.sealEntry.test.ts similarity index 85% rename from shared/src/business/entities/docketEntry/DocketEntry.sealEntry.test.ts rename to shared/src/business/entities/DocketEntry.sealEntry.test.ts index 0cec698a81a..4f6a13566f1 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.sealEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.sealEntry.test.ts @@ -1,7 +1,7 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; -import { DOCKET_ENTRY_SEALED_TO_TYPES } from '../EntityConstants'; +import { DOCKET_ENTRY_SEALED_TO_TYPES } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('sealEntry', () => { it('should set the sealedTo property of the docket entry', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.setAsProcessingStatusAsCompleted.test.ts b/shared/src/business/entities/DocketEntry.setAsProcessingStatusAsCompleted.test.ts similarity index 85% rename from shared/src/business/entities/docketEntry/DocketEntry.setAsProcessingStatusAsCompleted.test.ts rename to shared/src/business/entities/DocketEntry.setAsProcessingStatusAsCompleted.test.ts index affe0dab8de..523a01fb485 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.setAsProcessingStatusAsCompleted.test.ts +++ b/shared/src/business/entities/DocketEntry.setAsProcessingStatusAsCompleted.test.ts @@ -1,7 +1,7 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; -import { DOCUMENT_PROCESSING_STATUS_OPTIONS } from '../EntityConstants'; +import { DOCUMENT_PROCESSING_STATUS_OPTIONS } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('setAsProcessingStatusAsCompleted', () => { it('sets the docket entry processing status as completed', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.setAsServed.test.ts b/shared/src/business/entities/DocketEntry.setAsServed.test.ts similarity index 96% rename from shared/src/business/entities/docketEntry/DocketEntry.setAsServed.test.ts rename to shared/src/business/entities/DocketEntry.setAsServed.test.ts index ece37376ec7..08861c7f366 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.setAsServed.test.ts +++ b/shared/src/business/entities/DocketEntry.setAsServed.test.ts @@ -4,7 +4,7 @@ import { PARTIES_CODES, ROLES, } from '@shared/business/entities/EntityConstants'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('setAsServed', () => { it('sets the Document as served', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.setNumberOfPages.test.ts b/shared/src/business/entities/DocketEntry.setNumberOfPages.test.ts similarity index 85% rename from shared/src/business/entities/docketEntry/DocketEntry.setNumberOfPages.test.ts rename to shared/src/business/entities/DocketEntry.setNumberOfPages.test.ts index 24dff33d97c..e13a3a5f938 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.setNumberOfPages.test.ts +++ b/shared/src/business/entities/DocketEntry.setNumberOfPages.test.ts @@ -1,5 +1,5 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('setNumberOfPages', () => { it('sets the number of pages', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.setQCed.test.ts b/shared/src/business/entities/DocketEntry.setQCed.test.ts similarity index 89% rename from shared/src/business/entities/docketEntry/DocketEntry.setQCed.test.ts rename to shared/src/business/entities/DocketEntry.setQCed.test.ts index 5185510ad33..e29c888729b 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.setQCed.test.ts +++ b/shared/src/business/entities/DocketEntry.setQCed.test.ts @@ -1,6 +1,6 @@ import { A_VALID_DOCKET_ENTRY, MOCK_PETITIONERS } from './DocketEntry.test'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('setQCed', () => { it('updates the document QC information with user name, id, and date', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.setWorkItem.test.ts b/shared/src/business/entities/DocketEntry.setWorkItem.test.ts similarity index 84% rename from shared/src/business/entities/docketEntry/DocketEntry.setWorkItem.test.ts rename to shared/src/business/entities/DocketEntry.setWorkItem.test.ts index 38f2a9ed896..e8d0316644e 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.setWorkItem.test.ts +++ b/shared/src/business/entities/DocketEntry.setWorkItem.test.ts @@ -1,8 +1,8 @@ import { A_VALID_DOCKET_ENTRY, MOCK_PETITIONERS } from './DocketEntry.test'; -import { CASE_STATUS_TYPES, PETITIONS_SECTION } from '../EntityConstants'; +import { CASE_STATUS_TYPES, PETITIONS_SECTION } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { WorkItem } from '../WorkItem'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { WorkItem } from './WorkItem'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('setWorkItem', () => { it('should set work item on docket entry to the passed in work item and validate the nested work item', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.shouldAutoGenerateDeadline.test.ts b/shared/src/business/entities/DocketEntry.shouldAutoGenerateDeadline.test.ts similarity index 83% rename from shared/src/business/entities/docketEntry/DocketEntry.shouldAutoGenerateDeadline.test.ts rename to shared/src/business/entities/DocketEntry.shouldAutoGenerateDeadline.test.ts index 5772e313020..59aae802596 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.shouldAutoGenerateDeadline.test.ts +++ b/shared/src/business/entities/DocketEntry.shouldAutoGenerateDeadline.test.ts @@ -1,6 +1,6 @@ -import { AUTO_GENERATED_DEADLINE_DOCUMENT_TYPES } from '../EntityConstants'; +import { AUTO_GENERATED_DEADLINE_DOCUMENT_TYPES } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('shouldAutoGenerateDeadline', () => { AUTO_GENERATED_DEADLINE_DOCUMENT_TYPES.forEach(item => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.strikeEntry.test.ts b/shared/src/business/entities/DocketEntry.strikeEntry.test.ts similarity index 95% rename from shared/src/business/entities/docketEntry/DocketEntry.strikeEntry.test.ts rename to shared/src/business/entities/DocketEntry.strikeEntry.test.ts index e43e1fc9532..4610f39a4bf 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.strikeEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.strikeEntry.test.ts @@ -1,5 +1,5 @@ import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('strikeEntry', () => { it('strikes a document if isOnDocketRecord is true', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.test.ts b/shared/src/business/entities/DocketEntry.test.ts similarity index 99% rename from shared/src/business/entities/docketEntry/DocketEntry.test.ts rename to shared/src/business/entities/DocketEntry.test.ts index 6adfd966032..ac23fceaca9 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.test.ts @@ -2,11 +2,11 @@ import { DOCUMENT_RELATIONSHIPS, INITIAL_DOCUMENT_TYPES, ROLES, -} from '../EntityConstants'; +} from './EntityConstants'; import { DocketEntry } from './DocketEntry'; import { MOCK_WORK_ITEM } from '@shared/test/mockWorkItem'; import { WorkItem } from '@shared/business/entities/WorkItem'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; import { mockDocketClerkUser, mockPetitionerUser, diff --git a/shared/src/business/entities/docketEntry/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts similarity index 99% rename from shared/src/business/entities/docketEntry/DocketEntry.ts rename to shared/src/business/entities/DocketEntry.ts index fbc50261677..afde1c46cac 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -26,22 +26,22 @@ import { TRACKED_DOCUMENT_TYPES_EVENT_CODES, TRANSCRIPT_EVENT_CODE, UNSERVABLE_EVENT_CODES, -} from '../EntityConstants'; +} from './EntityConstants'; import { Case, getPetitionDocketEntry, isSealedCase, } from '@shared/business/entities/cases/Case'; -import { DOCKET_ENTRY_VALIDATION_RULES } from '../EntityValidationConstants'; +import { DOCKET_ENTRY_VALIDATION_RULES } from './EntityValidationConstants'; import { JoiValidationEntity } from '@shared/business/entities/JoiValidationEntity'; -import { RawUser, User } from '../User'; +import { RawUser, User } from './User'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; -import { WorkItem } from '../WorkItem'; +import { WorkItem } from './WorkItem'; import { calculateISODate, createISODateAtStartOfDayEST, createISODateString, -} from '../../utilities/DateHandler'; +} from '../utilities/DateHandler'; type PractitionerRole = 'irsPractitioner' | 'privatePractitioner'; diff --git a/shared/src/business/entities/docketEntry/DocketEntry.unsealEntry.test.ts b/shared/src/business/entities/DocketEntry.unsealEntry.test.ts similarity index 88% rename from shared/src/business/entities/docketEntry/DocketEntry.unsealEntry.test.ts rename to shared/src/business/entities/DocketEntry.unsealEntry.test.ts index 36889aa344d..e88c1ba7a18 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.unsealEntry.test.ts +++ b/shared/src/business/entities/DocketEntry.unsealEntry.test.ts @@ -1,7 +1,7 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; -import { DOCKET_ENTRY_SEALED_TO_TYPES } from '../EntityConstants'; +import { DOCKET_ENTRY_SEALED_TO_TYPES } from './EntityConstants'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('unsealEntry', () => { it('should clear the sealedTo property from the docket entry', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.unsignDocument.test.ts b/shared/src/business/entities/DocketEntry.unsignDocument.test.ts similarity index 91% rename from shared/src/business/entities/docketEntry/DocketEntry.unsignDocument.test.ts rename to shared/src/business/entities/DocketEntry.unsignDocument.test.ts index d8c00af30f9..1d774a14eb2 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.unsignDocument.test.ts +++ b/shared/src/business/entities/DocketEntry.unsignDocument.test.ts @@ -1,6 +1,6 @@ import { A_VALID_DOCKET_ENTRY } from './DocketEntry.test'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('unsignDocument', () => { it('signs and unsigns the document', () => { diff --git a/shared/src/business/entities/docketEntry/DocketEntry.validate.test.ts b/shared/src/business/entities/DocketEntry.validate.test.ts similarity index 99% rename from shared/src/business/entities/docketEntry/DocketEntry.validate.test.ts rename to shared/src/business/entities/DocketEntry.validate.test.ts index 880a17296ed..ef0a5631d08 100644 --- a/shared/src/business/entities/docketEntry/DocketEntry.validate.test.ts +++ b/shared/src/business/entities/DocketEntry.validate.test.ts @@ -7,7 +7,7 @@ import { OPINION_DOCUMENT_TYPES, ORDER_TYPES, TRANSCRIPT_EVENT_CODE, -} from '../EntityConstants'; +} from './EntityConstants'; import { A_VALID_DOCKET_ENTRY, MOCK_PETITIONERS, @@ -15,7 +15,7 @@ import { mockSecondaryId, } from './DocketEntry.test'; import { DocketEntry } from './DocketEntry'; -import { applicationContext } from '../../test/createTestApplicationContext'; +import { applicationContext } from '../test/createTestApplicationContext'; describe('validate', () => { const mockUserId = applicationContext.getUniqueId(); diff --git a/shared/src/business/entities/docketEntry/Docketentry.isDownloadable.test.ts b/shared/src/business/entities/Docketentry.isDownloadable.test.ts similarity index 99% rename from shared/src/business/entities/docketEntry/Docketentry.isDownloadable.test.ts rename to shared/src/business/entities/Docketentry.isDownloadable.test.ts index 6713095c79c..3962297ae01 100644 --- a/shared/src/business/entities/docketEntry/Docketentry.isDownloadable.test.ts +++ b/shared/src/business/entities/Docketentry.isDownloadable.test.ts @@ -15,7 +15,7 @@ import { petitionerUser, } from '@shared/test/mockUsers'; import { cloneDeep } from 'lodash'; -import { getPetitionDocketEntry } from '../cases/Case'; +import { getPetitionDocketEntry } from './cases/Case'; let baseDocketEntry: RawDocketEntry; let rawCase: RawCase; From 98401f2e7783fceeda5b3dd6fb9a848f4835b09c Mon Sep 17 00:00:00 2001 From: John Cruz Date: Fri, 30 Aug 2024 10:14:03 -0600 Subject: [PATCH 523/523] 10377: Extract debounce constant to constant variable; --- shared/src/business/entities/EntityConstants.ts | 2 ++ web-client/src/ustc-ui/Button/Button.tsx | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/shared/src/business/entities/EntityConstants.ts b/shared/src/business/entities/EntityConstants.ts index 102e40adc07..b72fb1c20c3 100644 --- a/shared/src/business/entities/EntityConstants.ts +++ b/shared/src/business/entities/EntityConstants.ts @@ -6,6 +6,8 @@ import courtIssuedEventCodesJson from '../../tools/courtIssuedEventCodes.json'; import externalFilingEventsJson from '../../tools/externalFilingEvents.json'; import internalFilingEventsJson from '../../tools/internalFilingEvents.json'; +export const DEBOUNCE_TIME_MILLISECONDS = 500; + // if repeatedly using the same rules to validate how an input should be formatted, capture it here. // a number (100 to 99999) followed by a - and a 2 digit year export const DOCUMENT_INTERNAL_CATEGORIES_MAP = internalFilingEventsJson; diff --git a/web-client/src/ustc-ui/Button/Button.tsx b/web-client/src/ustc-ui/Button/Button.tsx index 0a174db8238..e5ff5241bfc 100644 --- a/web-client/src/ustc-ui/Button/Button.tsx +++ b/web-client/src/ustc-ui/Button/Button.tsx @@ -1,3 +1,4 @@ +import { DEBOUNCE_TIME_MILLISECONDS } from '@shared/business/entities/EntityConstants'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { debounce } from 'lodash'; import React, { useState } from 'react'; @@ -18,7 +19,7 @@ function getUpdatedOnClick( await results.finally(() => { setDisableButton(false); }); - }, 500); + }, DEBOUNCE_TIME_MILLISECONDS); return async (...args) => { setDisableButton(true);