Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(encrypt-submission): add missing ndi response fields #7425

Merged

Conversation

g-tejas
Copy link
Contributor

@g-tejas g-tejas commented Jun 21, 2024

Problem

Previously for email notifications for storage mode forms, for MyInfo fields, only the [MyInfo] Name gets added, and not the "sgID Validate NRIC". This PR adds them.

Closes FRM-1752

Breaking Changes

  • No - this PR is backwards compatible

Screenshot 2024-06-21 at 3.50.31 PM.png

Tests

Without NRIC Masking

  • 1. Create storage mode form, and add admin emails.
  • 2. Add my info fields and make form public
  • 3. Fill in a form and submit
  • 4. Receive email and observe that the sgID Validated NRIC field exists. The NRIC must be unmasked

With NRIC Masking

  • 1. Create storage mode form, and add admin emails.
  • 2. Enable NRIC Masking
  • 3. Add my info fields and make form public
  • 4. Fill in a form and submit
  • 5. Receive email and observe that the sgID Validated NRIC field exists. The NRIC in the email must be masked

@g-tejas g-tejas marked this pull request as ready for review June 21, 2024 07:48
Copy link
Contributor Author

g-tejas commented Jun 21, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @g-tejas and the rest of your teammates on Graphite Graphite

@g-tejas g-tejas marked this pull request as draft June 21, 2024 07:48
@g-tejas g-tejas marked this pull request as ready for review June 21, 2024 07:48
@g-tejas g-tejas requested a review from KenLSM June 21, 2024 07:48
@g-tejas g-tejas force-pushed the 06-21-fix_encrypt-submission_add_missing_ndi_response_fields branch from 8ed3504 to 66d2d9d Compare June 21, 2024 09:18
@g-tejas g-tejas requested a review from kevin9foong June 21, 2024 09:22
KenLSM
KenLSM previously approved these changes Jun 23, 2024
Copy link
Contributor

@KenLSM KenLSM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. How did we miss this 🙈

@kevin9foong
Copy link
Contributor

kevin9foong commented Jun 23, 2024

hi @g-tejas @KenLSM

just a small thing to point out, it seems that if we add the ndi responses to the response object
then the sdID validate NRIC will be stored twice in the submission's database entry.
once under the encryptedContent field (current file change) and another time during the verifiedContent field (in the submitEncryptModeForm method).

this causes

  1. duplication of nric field in 2 fields of the submission entry in the db
  2. nric masking has to mask at 2 places

I was wondering if a better approach is to reduce the duplication of extracting the sgid from jwt token/OidcService & storage of nric field in the saved submission entry in the db

I propose an alternative implementation:

  • currently, the nric is stored and encrypted in the verifiedContent field after being loaded/extracted in submitEncryptModeForm
  • instead of extracting/loading the nric twice, shall we append this fetched sgid nric directly into the mail message payload instead? this would reduce the duplication mentioned above

Details:
The src/app/modules/submission/encrypt-submission/encrypt-submission.controller.ts, line 135 onwards loads the nric once again and stores this duplicate nric in the "verifiedContent" field on top of the "encryptedContent" field.

@KenLSM KenLSM self-requested a review June 24, 2024 02:49
Copy link

linear bot commented Jun 24, 2024

@g-tejas g-tejas force-pushed the 06-21-fix_encrypt-submission_add_missing_ndi_response_fields branch 2 times, most recently from c4bf485 to 2b5ddcb Compare June 27, 2024 12:34
@g-tejas g-tejas force-pushed the 06-21-fix_encrypt-submission_add_missing_ndi_response_fields branch from 2b5ddcb to e1d4d71 Compare June 27, 2024 12:36
@g-tejas g-tejas dismissed KenLSM’s stale review June 27, 2024 13:00

before nric masking was merged

@kevin9foong
Copy link
Contributor

hey @g-tejas, the code looks good! please let me know your thoughts on the PR comment

@g-tejas g-tejas force-pushed the 06-21-fix_encrypt-submission_add_missing_ndi_response_fields branch from b0ac37d to 07ec710 Compare June 28, 2024 08:26
Copy link
Contributor

@kevin9foong kevin9foong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@g-tejas g-tejas force-pushed the 06-21-fix_encrypt-submission_add_missing_ndi_response_fields branch 5 times, most recently from 884dc49 to 5cd89a5 Compare July 1, 2024 01:50
…ng_for_email_notifications_on_encrypt-forms

fix(tests): fix e2e testing for email notifications on encrypt-forms
@g-tejas g-tejas force-pushed the 06-21-fix_encrypt-submission_add_missing_ndi_response_fields branch from 5cd89a5 to 0b7b4bc Compare July 1, 2024 08:46
@@ -120,6 +123,7 @@ export const verifyEmailSubmission = async ({
getResponseTitle(field, { mode: FormResponseMode.Email }),
...responseArray,
])
if (!submission.attachments) continue
Copy link
Contributor

@kevin9foong kevin9foong Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we can change this to if ... { } instead of continue. justification: might be easier to understand for future modifications to not accidentally include test code that is not executed

@@ -193,6 +211,7 @@ export const verifyEncryptSubmission = async (
getResponseTitle(field, { mode: FormResponseMode.Email }),
...responseArray,
])
if (!submission.attachments) continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@g-tejas g-tejas merged commit 7c5f436 into develop Jul 2, 2024
15 checks passed
@g-tejas g-tejas deleted the 06-21-fix_encrypt-submission_add_missing_ndi_response_fields branch July 2, 2024 05:15
@KenLSM KenLSM mentioned this pull request Jul 4, 2024
9 tasks
g-tejas added a commit that referenced this pull request Jul 18, 2024
* fix(encrypt-submission): add missing ndi response fields

* fix(tests): fix e2e testing for email notifs on encrypt-form

* fix: remove attachment tests temporarily

* fix: fix comment for email test

* test: add encrypt tests for nric masking in email notifs

* test: enable jest tests

* fix: fix comment for tests

* test: fix verifyEncryptSubmission test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants