Skip to content

Commit 32765cb

Browse files
[CVE-2608] use formData fullName for statement of truth signature (#44153)
* use formData fullName for statement of truth signature * remove unused prop
1 parent 080cb73 commit 32765cb

2 files changed

Lines changed: 9 additions & 40 deletions

File tree

src/applications/lgy/coe/form/components/PreSubmitInfo2.jsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,18 @@ import {
1010
const STATEMENT_OF_TRUTH = {
1111
body:
1212
'I confirm that the identifying information in this form is accurate and has been represented correctly.',
13+
fullNamePath: 'fullName',
1314
useProfileFullName: true,
1415
};
1516

16-
export const PreSubmitInfo2 = ({
17-
formData,
18-
showError,
19-
user,
20-
onSectionComplete,
21-
}) => {
17+
export const PreSubmitInfo2 = ({ formData, showError, onSectionComplete }) => {
2218
const [signature, setSignature] = useState('');
2319
const [certified, setCertified] = useState(false);
2420
const [signatureBlurred, setSignatureBlurred] = useState(false);
2521

2622
const expectedFullName = statementOfTruthFullName(
2723
formData,
2824
STATEMENT_OF_TRUTH,
29-
user?.profile?.userFullName,
3025
);
3126

3227
const signatureMismatch =
@@ -65,7 +60,5 @@ export const PreSubmitInfo2 = ({
6560
PreSubmitInfo2.propTypes = {
6661
formData: PropTypes.object,
6762
onSectionComplete: PropTypes.func,
68-
preSubmitInfo: PropTypes.object,
6963
showError: PropTypes.bool,
70-
user: PropTypes.object,
7164
};

src/applications/lgy/coe/form/tests/unit/components/PreSubmitInfo2.unit.spec.jsx

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@ import sinon from 'sinon';
44
import { fireEvent, render, waitFor } from '@testing-library/react';
55
import { PreSubmitInfo2 } from '../../../components/PreSubmitInfo2';
66

7-
const buildUser = (fullName = { first: 'John', last: 'Doe' }) => ({
8-
profile: { userFullName: fullName },
9-
});
10-
117
describe('COE PreSubmitInfo2', () => {
128
it('renders a va-statement-of-truth with the expected heading and input label', () => {
139
const { container } = render(
1410
<PreSubmitInfo2
1511
formData={{}}
1612
showError={false}
17-
user={buildUser()}
1813
onSectionComplete={() => {}}
1914
/>,
2015
);
@@ -30,7 +25,6 @@ describe('COE PreSubmitInfo2', () => {
3025
<PreSubmitInfo2
3126
formData={{}}
3227
showError={false}
33-
user={buildUser()}
3428
onSectionComplete={() => {}}
3529
/>,
3630
);
@@ -44,7 +38,6 @@ describe('COE PreSubmitInfo2', () => {
4438
<PreSubmitInfo2
4539
formData={{}}
4640
showError={false}
47-
user={buildUser()}
4841
onSectionComplete={() => {}}
4942
/>,
5043
);
@@ -59,7 +52,6 @@ describe('COE PreSubmitInfo2', () => {
5952
<PreSubmitInfo2
6053
formData={{}}
6154
showError={false}
62-
user={buildUser()}
6355
onSectionComplete={onSectionComplete}
6456
/>,
6557
);
@@ -78,12 +70,7 @@ describe('COE PreSubmitInfo2', () => {
7870

7971
it('shows a checkbox error when showError is true and the box is unchecked', async () => {
8072
const { container } = render(
81-
<PreSubmitInfo2
82-
formData={{}}
83-
showError
84-
user={buildUser()}
85-
onSectionComplete={() => {}}
86-
/>,
73+
<PreSubmitInfo2 formData={{}} showError onSectionComplete={() => {}} />,
8774
);
8875
await waitFor(() => {
8976
const sot = container.querySelector('va-statement-of-truth');
@@ -95,12 +82,7 @@ describe('COE PreSubmitInfo2', () => {
9582

9683
it('clears the checkbox error after the box is checked', async () => {
9784
const { container } = render(
98-
<PreSubmitInfo2
99-
formData={{}}
100-
showError
101-
user={buildUser()}
102-
onSectionComplete={() => {}}
103-
/>,
85+
<PreSubmitInfo2 formData={{}} showError onSectionComplete={() => {}} />,
10486
);
10587
const sot = container.querySelector('va-statement-of-truth');
10688
fireEvent(
@@ -112,12 +94,11 @@ describe('COE PreSubmitInfo2', () => {
11294
});
11395
});
11496

115-
it('shows a signature mismatch error after blur when the signature does not match the profile name', async () => {
97+
it('shows a signature mismatch error after blur when the signature does not match the expected name', async () => {
11698
const { container } = render(
11799
<PreSubmitInfo2
118-
formData={{}}
100+
formData={{ fullName: { first: 'John', last: 'Doe' } }}
119101
showError={false}
120-
user={buildUser({ first: 'John', last: 'Doe' })}
121102
onSectionComplete={() => {}}
122103
/>,
123104
);
@@ -143,7 +124,6 @@ describe('COE PreSubmitInfo2', () => {
143124
<PreSubmitInfo2
144125
formData={{}}
145126
showError={false}
146-
user={buildUser()}
147127
onSectionComplete={() => {}}
148128
/>,
149129
);
@@ -159,12 +139,11 @@ describe('COE PreSubmitInfo2', () => {
159139
expect(sot.getAttribute('input-error')).to.be.null;
160140
});
161141

162-
it('does not show a mismatch error when the signature matches the profile name (case/whitespace insensitive)', async () => {
142+
it('does not show a mismatch error when the signature matches the expected name (case/whitespace insensitive)', async () => {
163143
const { container } = render(
164144
<PreSubmitInfo2
165-
formData={{}}
145+
formData={{ fullName: { first: 'John', last: 'Doe' } }}
166146
showError
167-
user={buildUser({ first: 'John', last: 'Doe' })}
168147
onSectionComplete={() => {}}
169148
/>,
170149
);
@@ -184,13 +163,11 @@ describe('COE PreSubmitInfo2', () => {
184163
it('shows a mismatch error when showError is true even if the input has not been blurred', async () => {
185164
const { container } = render(
186165
<PreSubmitInfo2
187-
formData={{}}
166+
formData={{ fullName: { first: 'John', last: 'Doe' } }}
188167
showError
189-
user={buildUser()}
190168
onSectionComplete={() => {}}
191169
/>,
192170
);
193-
// empty signature mismatches profile name -> should surface the input error
194171
const sot = container.querySelector('va-statement-of-truth');
195172
await waitFor(() => {
196173
expect(sot.getAttribute('input-error')).to.include('John Doe');
@@ -202,7 +179,6 @@ describe('COE PreSubmitInfo2', () => {
202179
<PreSubmitInfo2
203180
formData={{}}
204181
showError={false}
205-
user={buildUser()}
206182
onSectionComplete={() => {}}
207183
/>,
208184
);

0 commit comments

Comments
 (0)