Skip to content

Commit

Permalink
Merge pull request #6710 from opengovsg/release_v6.77.0
Browse files Browse the repository at this point in the history
build: release v6.77.0
  • Loading branch information
justynoh authored Sep 12, 2023
2 parents 7c4a0a9 + 6b1b9b2 commit 5d7f95b
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 185 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v6.76.1](https://github.com/opengovsg/FormSG/compare/v6.76.0...v6.76.1)
#### [v6.77.0](https://github.com/opengovsg/FormSG/compare/v6.76.0...v6.77.0)

- build: merge v6.76.1 into develop [`#6708`](https://github.com/opengovsg/FormSG/pull/6708)
- feat: soften and fix storage submission validation [`#6696`](https://github.com/opengovsg/FormSG/pull/6696)
- build: release v6.76.1 [`#6702`](https://github.com/opengovsg/FormSG/pull/6702)
- fix: invalid mixed digit input [`#6701`](https://github.com/opengovsg/FormSG/pull/6701)
- build: merge v6.76.0 into develop [`#6700`](https://github.com/opengovsg/FormSG/pull/6700)
- build: release v6.76.0 [`#6698`](https://github.com/opengovsg/FormSG/pull/6698)
- chore: bump version to 6.76.1 [`9e88567`](https://github.com/opengovsg/FormSG/commit/9e8856721af4e3a99b6c6fe0e31ac96414a46149)

#### [v6.76.0](https://github.com/opengovsg/FormSG/compare/v6.75.1...v6.76.0)

Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-frontend",
"version": "6.76.0",
"version": "6.77.0",
"homepage": ".",
"private": true,
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "FormSG",
"description": "Form Manager for Government",
"version": "6.76.1",
"version": "6.77.0",
"homepage": "https://form.gov.sg",
"authors": [
"FormSG <[email protected]>"
Expand Down
2 changes: 2 additions & 0 deletions shared/constants/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ export const featureFlags = {
turnstile: 'turnstile' as const,
validateStripeEmailDomain: 'validateStripeEmailDomain' as const,
encryptionBoundaryShift: 'encryption-boundary-shift' as const,
encryptionBoundaryShiftHardValidation:
'encryption-boundary-shift-hard-validation' as const,
}
Original file line number Diff line number Diff line change
Expand Up @@ -5420,7 +5420,6 @@ describe('admin-form.controller', () => {
expect(MockParsedResponsesObject.parseResponses).toHaveBeenCalledWith(
MOCK_FORM,
MOCK_RESPONSES,
false,
)
expect(MockAdminFormService.extractMyInfoFieldIds).toHaveBeenCalledWith(
MOCK_FORM.form_fields,
Expand Down Expand Up @@ -5955,7 +5954,6 @@ describe('admin-form.controller', () => {
expect(MockParsedResponsesObject.parseResponses).toHaveBeenCalledWith(
MOCK_FORM,
MOCK_RESPONSES,
false,
)
expect(MockAdminFormService.extractMyInfoFieldIds).not.toHaveBeenCalled()
expect(
Expand Down Expand Up @@ -6013,7 +6011,6 @@ describe('admin-form.controller', () => {
expect(MockParsedResponsesObject.parseResponses).toHaveBeenCalledWith(
MOCK_FORM,
MOCK_RESPONSES,
false,
)
expect(MockAdminFormService.extractMyInfoFieldIds).not.toHaveBeenCalled()
expect(
Expand Down Expand Up @@ -6071,7 +6068,6 @@ describe('admin-form.controller', () => {
expect(MockParsedResponsesObject.parseResponses).toHaveBeenCalledWith(
MOCK_FORM,
MOCK_RESPONSES,
false,
)
expect(MockAdminFormService.extractMyInfoFieldIds).not.toHaveBeenCalled()
expect(
Expand Down Expand Up @@ -6129,7 +6125,6 @@ describe('admin-form.controller', () => {
expect(MockParsedResponsesObject.parseResponses).toHaveBeenCalledWith(
MOCK_FORM,
MOCK_RESPONSES,
false,
)
expect(MockAdminFormService.extractMyInfoFieldIds).toHaveBeenCalledWith(
MOCK_FORM.form_fields,
Expand Down Expand Up @@ -6196,7 +6191,6 @@ describe('admin-form.controller', () => {
expect(MockParsedResponsesObject.parseResponses).toHaveBeenCalledWith(
MOCK_FORM,
MOCK_RESPONSES,
false,
)
expect(MockAdminFormService.extractMyInfoFieldIds).toHaveBeenCalledWith(
MOCK_FORM.form_fields,
Expand Down Expand Up @@ -6263,7 +6257,6 @@ describe('admin-form.controller', () => {
expect(MockParsedResponsesObject.parseResponses).toHaveBeenCalledWith(
MOCK_FORM,
MOCK_RESPONSES,
false,
)
expect(MockAdminFormService.extractMyInfoFieldIds).toHaveBeenCalledWith(
MOCK_FORM.form_fields,
Expand Down Expand Up @@ -6398,7 +6391,6 @@ describe('admin-form.controller', () => {
MOCK_FORM,
MOCK_RESPONSES,
MOCK_ENCRYPTED_CONTENT,
true,
)
expect(
MockEncryptSubmissionService.createEncryptSubmissionWithoutSave,
Expand Down Expand Up @@ -6801,7 +6793,6 @@ describe('admin-form.controller', () => {
MOCK_FORM,
MOCK_RESPONSES,
MOCK_ENCRYPTED_CONTENT,
true,
)
expect(
MockEncryptSubmissionService.createEncryptSubmissionWithoutSave,
Expand Down Expand Up @@ -6855,7 +6846,6 @@ describe('admin-form.controller', () => {
MOCK_FORM,
MOCK_RESPONSES,
MOCK_ENCRYPTED_CONTENT,
true,
)
expect(
MockEncryptSubmissionService.createEncryptSubmissionWithoutSave,
Expand Down Expand Up @@ -6909,7 +6899,6 @@ describe('admin-form.controller', () => {
MOCK_FORM,
MOCK_RESPONSES,
MOCK_ENCRYPTED_CONTENT,
true,
)
expect(
MockEncryptSubmissionService.createEncryptSubmissionWithoutSave,
Expand Down Expand Up @@ -6963,7 +6952,6 @@ describe('admin-form.controller', () => {
MOCK_FORM,
MOCK_RESPONSES,
MOCK_ENCRYPTED_CONTENT,
true,
)
expect(
MockEncryptSubmissionService.createEncryptSubmissionWithoutSave,
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/form/admin-form/admin-form.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ export const submitEncryptPreview: ControllerHandler<
}),
)
.andThen((form) =>
IncomingEncryptSubmission.init(form, responses, encryptedContent, true) // set as true as there's no need to gate anything if the its not a real submission
IncomingEncryptSubmission.init(form, responses, encryptedContent)
.map((incomingSubmission) => ({ incomingSubmission, form }))
.mapErr((error) => {
logger.error({
Expand Down Expand Up @@ -1779,7 +1779,7 @@ export const submitEmailPreview: ControllerHandler<
const parsedResponsesResult = await SubmissionService.validateAttachments(
responses,
form.responseMode,
).andThen(() => ParsedResponsesObject.parseResponses(form, responses, false)) // email mode submissions (esp previews) does not need to use encryption boundary shift code
).andThen(() => ParsedResponsesObject.parseResponses(form, responses))
if (parsedResponsesResult.isErr()) {
logger.error({
message: 'Error while parsing responses for preview submission',
Expand Down
7 changes: 1 addition & 6 deletions src/app/modules/submission/ParsedResponsesObject.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,11 @@ export default class ParsedResponsesObject {
static parseResponses(
form: IFormDocument,
responses: FieldResponse[],
encryptionBoundaryShiftEnabled: boolean,
): Result<
ParsedResponsesObject,
ProcessingError | ConflictError | ValidateFieldError
> {
const filteredResponsesResult = getFilteredResponses(
form,
responses,
encryptionBoundaryShiftEnabled,
)
const filteredResponsesResult = getFilteredResponses(form, responses, false)
if (filteredResponsesResult.isErr()) {
return err(filteredResponsesResult.error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,7 @@ const submitEmailModeForm: ControllerHandler<
form.responseMode,
)
.andThen(() =>
ParsedResponsesObject.parseResponses(
form,
req.body.responses,
false, // email mode submissions do not need to use encryption boundary shift code
),
ParsedResponsesObject.parseResponses(form, req.body.responses),
)
.map((parsedResponses) => ({ parsedResponses, form }))
.mapErr((error) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ok, Result } from 'neverthrow'
import { Result } from 'neverthrow'

import { FieldResponse, IPopulatedEncryptedForm } from '../../../../types'
import { checkIsEncryptedEncoding } from '../../../utils/encryption'
Expand Down Expand Up @@ -32,17 +32,12 @@ export default class IncomingEncryptSubmission extends IncomingSubmission {
form: IPopulatedEncryptedForm,
responses: FieldResponse[],
encryptedContent: string,
encryptionBoundaryShiftEnabled: boolean,
): Result<
IncomingEncryptSubmission,
ProcessingError | ConflictError | ValidateFieldError[]
> {
return checkIsEncryptedEncoding(encryptedContent)
.andThen(() => {
if (encryptionBoundaryShiftEnabled)
return ok(responses as FilteredResponse[])
else return getFilteredResponses(form, responses, false)
})
.andThen(() => getFilteredResponses(form, responses, true))
.andThen((filteredResponses) =>
this.getFieldMap(form, filteredResponses).map((fieldMap) => ({
responses: filteredResponses,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe('IncomingEncryptSubmission', () => {
} as unknown as IPopulatedEncryptedForm,
responses,
'',
false,
)
expect(initResult._unsafeUnwrap().responses).toEqual(responses)
})
Expand Down Expand Up @@ -129,61 +128,11 @@ describe('IncomingEncryptSubmission', () => {
} as unknown as IPopulatedEncryptedForm,
responses,
'',
false,
)
const filteredResponses = [mobileResponse, emailResponse]
expect(initResult._unsafeUnwrap().responses).toEqual(filteredResponses)
})

it('should not filter responses when new encryption boundary flag is on', () => {
mockCheckIsEncryptedEncoding.mockReturnValueOnce(ok(true))
const mobileField = generateDefaultField(BasicField.Mobile, {
isVerifiable: true,
})
const emailField = generateDefaultField(BasicField.Email, {
isVerifiable: true,
autoReplyOptions: {
hasAutoReply: true,
autoReplySubject: 'subject',
autoReplySender: '[email protected]',
autoReplyMessage: 'message',
includeFormSummary: false,
},
})
const yesNoField = generateDefaultField(BasicField.YesNo)
const ratingField = generateDefaultField(BasicField.Rating)
const basicFormFields = [mobileField, emailField, yesNoField, ratingField]
const mobileResponse = generateSingleAnswerResponse(
mobileField,
'+6587654321',
'signature',
)
const emailResponse = generateSingleAnswerResponse(
emailField,
'[email protected]',
'signature',
)
const yesNoResponse = generateSingleAnswerResponse(yesNoField, 'Yes')
const ratingResponse = generateSingleAnswerResponse(ratingField, '5')
const responses = [
mobileResponse,
emailResponse,
yesNoResponse,
ratingResponse,
]
const filteredResponses = responses
const initResult = IncomingEncryptSubmission.init(
{
responseMode: FormResponseMode.Encrypt,
form_fields: basicFormFields,
} as unknown as IPopulatedEncryptedForm,
responses,
'',
true,
)
expect(initResult._unsafeUnwrap().responses).toEqual(filteredResponses)
})

it('should fail when responses are missing', () => {
mockCheckIsEncryptedEncoding.mockReturnValueOnce(ok(true))
const mobileField = generateDefaultField(BasicField.Mobile, {
Expand Down Expand Up @@ -212,7 +161,6 @@ describe('IncomingEncryptSubmission', () => {
} as unknown as IPopulatedEncryptedForm,
responses,
'',
false,
)
expect(initResult._unsafeUnwrapErr()).toEqual(
new ConflictError('Some form fields are missing'),
Expand Down Expand Up @@ -260,7 +208,6 @@ describe('IncomingEncryptSubmission', () => {
} as unknown as IPopulatedEncryptedForm,
responses,
'',
false,
)

expect(result.isOk()).toEqual(true)
Expand All @@ -283,7 +230,6 @@ describe('IncomingEncryptSubmission', () => {
} as unknown as IPopulatedEncryptedForm,
[mobileResponse],
'',
false,
)

expect(result.isErr()).toEqual(true)
Expand All @@ -309,7 +255,6 @@ describe('IncomingEncryptSubmission', () => {
} as unknown as IPopulatedEncryptedForm,
[],
'',
false,
)

expect(result.isErr()).toEqual(true)
Expand Down
Loading

0 comments on commit 5d7f95b

Please sign in to comment.