Skip to content

Commit

Permalink
Merge pull request #7419 from opengovsg/release_v6.128.0
Browse files Browse the repository at this point in the history
build: release v6.128.0
  • Loading branch information
KenLSM authored Jun 20, 2024
2 parents 4cde729 + 8f91bf0 commit 0bf7ba0
Show file tree
Hide file tree
Showing 23 changed files with 773 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .template-env
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,5 @@ FORMSG_SDK_MODE=

# Used to check if BE Server is currently running on local development environment
# One of boolean: "true" | "false"
# USE_MOCK_TWILIO=
# USE_MOCK_TWILIO=
# USE_MOCK_POSTMAN_SMS=
36 changes: 32 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,24 @@ 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.128.0](https://github.com/opengovsg/FormSG/compare/v6.128.0...v6.128.0)

- fix(btn): form admin not fully resolved when retrieved from FormService [`#7420`](https://github.com/opengovsg/FormSG/pull/7420)

#### [v6.128.0](https://github.com/opengovsg/FormSG/compare/v6.127.1...v6.128.0)

> 20 June 2024

- feat(btn): frm 1717 mop flow to postman [`#7342`](https://github.com/opengovsg/FormSG/pull/7342)
- build: merge release v6.127.1 to develop [`#7416`](https://github.com/opengovsg/FormSG/pull/7416)
- fix(deps): bump libphonenumber-js from 1.11.3 to 1.11.4 in /shared [`#7415`](https://github.com/opengovsg/FormSG/pull/7415)
- hotfix: dupe form fail [`#7414`](https://github.com/opengovsg/FormSG/pull/7414)
- chore: bump version to v6.128.0 [`4b8cea2`](https://github.com/opengovsg/FormSG/commit/4b8cea2a46a258b96dc9b7be31b480481b8e30e8)

#### [v6.127.1](https://github.com/opengovsg/FormSG/compare/v6.127.0...v6.127.1)

> 19 June 2024

- build: release v6.127.0 [`#7413`](https://github.com/opengovsg/FormSG/pull/7413)
- fix: fix issue where duplicating forms fails [`a66cebf`](https://github.com/opengovsg/FormSG/commit/a66cebf8528675c5153ce9c57fe53bb3e0026fdd)

Expand Down Expand Up @@ -40,7 +56,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build: release v6.125.0 [`#7389`](https://github.com/opengovsg/FormSG/pull/7389)
- chore: bump version to v6.126.0 [`a8b0d5d`](https://github.com/opengovsg/FormSG/commit/a8b0d5d261d5a367962337183c007096c6524680)

#### [v6.125.0](https://github.com/opengovsg/FormSG/compare/v6.124.0...v6.125.0)
#### [v6.125.0](https://github.com/opengovsg/FormSG/compare/v6.124.1...v6.125.0)

> 13 June 2024

Expand All @@ -56,8 +72,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build: merge release 6.124.1 into develop [`#7371`](https://github.com/opengovsg/FormSG/pull/7371)
- fix: check for truthiness of fieldname in receiver [`#7370`](https://github.com/opengovsg/FormSG/pull/7370)
- build: merge release v6.124.0 into develop [`#7369`](https://github.com/opengovsg/FormSG/pull/7369)
- build: release v6.124.0 [`#7368`](https://github.com/opengovsg/FormSG/pull/7368)
- chore: bump version to v6.125.0 [`756fb88`](https://github.com/opengovsg/FormSG/commit/756fb88671cf5ba22fb28475eea44a06f3c6f79d)

#### [v6.124.1](https://github.com/opengovsg/FormSG/compare/v6.124.0...v6.124.1)

> 7 June 2024

- build: release v6.124.0 [`#7368`](https://github.com/opengovsg/FormSG/pull/7368)
- chore: bump version to v6.124.1 [`08eba07`](https://github.com/opengovsg/FormSG/commit/08eba07169a64e1ba5f42589c05345d32ad91a98)
- check for truthiness of fieldname in receiver [`429e1e9`](https://github.com/opengovsg/FormSG/commit/429e1e9a073da23cc7f329fae11ac4e0f1b7c66c)

Expand Down Expand Up @@ -207,7 +228,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- chore: reverting package-lock changes [`040b962`](https://github.com/opengovsg/FormSG/commit/040b96284ea317de22d9de6cf872fd4116f24c51)
- chore: bump version to v6.117.0 [`6eb4aca`](https://github.com/opengovsg/FormSG/commit/6eb4aca28514e3286c23c0834f9962de291a7fbc)

#### [v6.116.0](https://github.com/opengovsg/FormSG/compare/v6.115.0...v6.116.0)
#### [v6.116.0](https://github.com/opengovsg/FormSG/compare/v6.115.1...v6.116.0)

> 8 April 2024

Expand All @@ -218,10 +239,17 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- fix(mrf): webhook be validation [`#7247`](https://github.com/opengovsg/FormSG/pull/7247)
- chore: move react-dev-inspector to frontend/package.json [`#7245`](https://github.com/opengovsg/FormSG/pull/7245)
- refactor: add exhaustive checks, use answerArray for arrays [`#7244`](https://github.com/opengovsg/FormSG/pull/7244)
- * chore(deps-dev): bump @types/express from 4.17.17 to 4.17.21 (#7233) [`#7241`](https://github.com/opengovsg/FormSG/pull/7241)
- fix(deps): bump type-fest from 4.14.0 to 4.15.0 in /shared [`#7243`](https://github.com/opengovsg/FormSG/pull/7243)
- chore: bump version to v6.116.0 [`31e1a33`](https://github.com/opengovsg/FormSG/commit/31e1a33c96d76b69c492f5212bc48a3dabe054af)

#### [v6.115.1](https://github.com/opengovsg/FormSG/compare/v6.115.0...v6.115.1)

> 5 April 2024

- * chore(deps-dev): bump @types/express from 4.17.17 to 4.17.21 (#7233) [`#7241`](https://github.com/opengovsg/FormSG/pull/7241)
- fix: add check to block webhooks updates on mrf [`71ab0c5`](https://github.com/opengovsg/FormSG/commit/71ab0c592c15de5fddbffc9970a424af7a31d4ab)
- chore: bump version to 6.115.1 [`7d127b2`](https://github.com/opengovsg/FormSG/commit/7d127b2e8353a8a282acabe1c309cefb1e750f9c)

#### [v6.115.0](https://github.com/opengovsg/FormSG/compare/v6.114.1...v6.115.0)

> 3 April 2024
Expand Down
3 changes: 3 additions & 0 deletions __tests__/setup/.test-env
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ SSM_ENV_SITE_NAME=test

# Public API env vars
API_KEY_VERSION=v1
POSTMAN_MOP_CAMPAIGN_ID=campaign_tesst
POSTMAN_MOP_CAMPAIGN_API_KEY=key_test_123
POSTMAN_BASE_URL=https://test.postman.gov.sg/api/v2
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ services:
- WOGAA_START_ENDPOINT
- WOGAA_SUBMIT_ENDPOINT
- WOGAA_FEEDBACK_ENDPOINT

- POSTMAN_MOP_CAMPAIGN_ID
- POSTMAN_MOP_CAMPAIGN_API_KEY
- POSTMAN_BASE_URL

mockpass:
build: https://github.com/opengovsg/mockpass.git#v4.3.1
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.127.1",
"version": "6.128.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.127.1",
"version": "6.128.0",
"homepage": "https://form.gov.sg",
"authors": [
"FormSG <formsg@data.gov.sg>"
Expand Down
1 change: 1 addition & 0 deletions shared/constants/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export const featureFlags = {
myinfoSgid: 'myinfo-sgid' as const,
chartsMaxResponseCount: 'charts-max-response-count' as const,
addingTwilioDisabled: 'adding-twilio-disabled' as const,
postmanSms: 'postmanSms' as const,
}
6 changes: 3 additions & 3 deletions shared/package-lock.json

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

1 change: 1 addition & 0 deletions shared/types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const UserBase = z.object({
.object({
payment: z.boolean().optional(),
children: z.boolean().optional(),
postmanSms: z.boolean().optional(),
})
.optional(),
flags: z
Expand Down
4 changes: 2 additions & 2 deletions src/app/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const isDev =
basicVars.core.nodeEnv === Environment.Dev ||
basicVars.core.nodeEnv === Environment.Test
const nodeEnv = isDev ? basicVars.core.nodeEnv : Environment.Prod
const useMockTwilio = basicVars.core.useMockTwilio

// Load and validate configuration values which are compulsory only in production
// If environment variables are not present, an error will be thrown
Expand Down Expand Up @@ -234,7 +233,8 @@ const config: Config = {
mail: mailConfig,
cookieSettings,
isDev,
useMockTwilio,
useMockTwilio: basicVars.core.useMockTwilio,
useMockPostmanSms: basicVars.core.useMockPostmanSms,
nodeEnv,
formsgSdkMode: basicVars.formsgSdkMode,
customCloudWatchGroup: basicVars.awsConfig.customCloudWatchGroup,
Expand Down
32 changes: 32 additions & 0 deletions src/app/config/features/postman-sms.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import convict, { Schema } from 'convict'

export interface ISms {
mopCampaignId: string
mopCampaignApiKey: string
postmanBaseUrl: string
}

const postmanSmsSchema: Schema<ISms> = {
mopCampaignId: {
doc: 'Postman SMS messaging campaign ID',
format: String,
default: null,
env: 'POSTMAN_MOP_CAMPAIGN_ID',
},
mopCampaignApiKey: {
doc: 'Postman SMS messaging campaign ID',
format: String,
default: null,
env: 'POSTMAN_MOP_CAMPAIGN_API_KEY',
},
postmanBaseUrl: {
doc: 'Postman base URL',
format: String,
default: null,
env: 'POSTMAN_BASE_URL',
},
}

export const postmanSmsConfig = convict(postmanSmsSchema)
.validate({ allowed: 'strict' })
.getProperties()
7 changes: 7 additions & 0 deletions src/app/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,19 @@ export const optionalVarsSchema: Schema<IOptionalVarsSchema> = {
default: Environment.Prod,
env: 'NODE_ENV',
},
// TODO(ken): to remove after twilio is no longer used
useMockTwilio: {
doc: 'Enables twilio API mocking and directs SMS body over to maildev',
format: 'Boolean',
default: false,
env: 'USE_MOCK_TWILIO',
},
useMockPostmanSms: {
doc: 'Enables Postman SMS API mocking and directs SMS body over to maildev',
format: 'Boolean',
default: false,
env: 'USE_MOCK_POSTMAN_SMS',
},
},
rateLimit: {
submissions: {
Expand Down
1 change: 1 addition & 0 deletions src/app/models/user.server.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const compileUserModel = (db: Mongoose) => {
betaFlags: {
payment: Boolean,
children: Boolean,
postmanSms: Boolean,
},
flags: {
lastSeenFeatureUpdateVersion: Number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import getMockLogger from '__tests__/unit/backend/helpers/jest-logger'
import { ObjectId } from 'bson'
import { addHours, subHours, subMinutes, subSeconds } from 'date-fns'
import mongoose from 'mongoose'
import { errAsync, okAsync } from 'neverthrow'
import { err, errAsync, ok, okAsync } from 'neverthrow'

// These need to be mocked first before the rest of the test
import * as LoggerModule from 'src/app/config/logger'
Expand All @@ -30,14 +30,22 @@ import {
} from 'src/app/modules/verification/verification.errors'
import { MailSendError } from 'src/app/services/mail/mail.errors'
import MailService from 'src/app/services/mail/mail.service'
import PostmanSmsService from 'src/app/services/postman-sms/postman-sms.service'
import { SmsSendError } from 'src/app/services/sms/sms.errors'
import { SmsFactory } from 'src/app/services/sms/sms.factory'
import * as HashUtils from 'src/app/utils/hash'
import { IFormSchema, IVerificationSchema, UpdateFieldData } from 'src/types'
import {
IFormSchema,
IPopulatedForm,
IUserSchema,
IVerificationSchema,
UpdateFieldData,
} from 'src/types'

import { BasicField } from '../../../../../shared/types'
import { DatabaseError } from '../../core/core.errors'
import { FormNotFoundError } from '../../form/form.errors'
import * as AdminFormUtils from '../../form/admin-form/admin-form.utils'
import { ForbiddenFormError, FormNotFoundError } from '../../form/form.errors'
import {
FieldNotFoundInTransactionError,
TransactionExpiredError,
Expand Down Expand Up @@ -311,6 +319,13 @@ describe('Verification service', () => {
.spyOn(VerificationModel, 'updateHashForField')
.mockResolvedValue(mockTransactionSuccessful)
MockFormService.retrieveFormById.mockReturnValue(okAsync(mockForm))
MockFormService.retrieveFullFormById.mockReturnValue(
okAsync(mockForm as IPopulatedForm),
)

jest
.spyOn(AdminFormUtils, 'verifyUserBetaflag')
.mockReturnValue(err(new ForbiddenFormError('ForbiddenFormError')))
})

it('should send OTP and update hashes when parameters are valid', async () => {
Expand All @@ -337,6 +352,45 @@ describe('Verification service', () => {
expect(result._unsafeUnwrap()).toEqual(mockTransactionSuccessful)
})

it('should send OTP with postman if admin has feature flag on', async () => {
jest
.spyOn(AdminFormUtils, 'verifyUserBetaflag')
.mockReturnValue(ok(true as unknown as IUserSchema))

const postmanSpy = jest
.spyOn(PostmanSmsService, 'sendVerificationOtp')
.mockResolvedValueOnce(okAsync(true))

await VerificationService.sendNewOtp(mockSendNewFormOtpValidInput)

// Default mock params has fieldType: 'mobile'
expect(MockSmsFactory.sendVerificationOtp).not.toHaveBeenCalled()

expect(postmanSpy).toHaveBeenCalledOnce()
})

it('should send OTP with twilio if admin has feature flag off', async () => {
const postmanSpy = jest
.spyOn(PostmanSmsService, 'sendVerificationOtp')
.mockResolvedValueOnce(okAsync(true))

await VerificationService.sendNewOtp(mockSendNewFormOtpValidInput)

// Default mock params has fieldType: 'mobile'
expect(MockSmsFactory.sendVerificationOtp).toHaveBeenCalledWith(
MOCK_LOCAL_RECIPIENT,
MOCK_OTP,
MOCK_OTP_PREFIX,
mockTransaction.formId,
MOCK_SENDER_IP,
)

// Default mock params has fieldType: 'mobile'
expect(MockSmsFactory.sendVerificationOtp).toHaveBeenCalled()

expect(postmanSpy).not.toHaveBeenCalled()
})

it('should return TransactionNotFoundError when transaction ID does not exist', async () => {
const result = await VerificationService.sendNewOtp({
...mockSendNewFormOtpValidInput,
Expand Down
Loading

0 comments on commit 0bf7ba0

Please sign in to comment.