Skip to content

Commit

Permalink
add separate env var for zoom production mode
Browse files Browse the repository at this point in the history
  • Loading branch information
serdiukov-o-nordwhale committed Apr 20, 2021
1 parent 1b0a63b commit b8bc697
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .env.example
Expand Up @@ -35,12 +35,12 @@ ZOOM_SERVER_BASEURL=https://api.facetec.com/api/v3/biometrics
# Minimal FaceTec Match Level threshold to mark enrollment as duplicate
# https://dev.zoomlogin.com/#/matching-guide
ZOOM_MINIMAL_MATCHLEVEL=1
# Enables fetching production key and initializes Zoom in production mode
ZOOM_PRODUCTION_MODE=
GUN_PUBLIC_S3=
GUN_PRIVATE_S3=
#required for gundb to work with S3
AWS_S3_BUCKET=1
#Force allow any origin in the CORS middleware. Useful for the local debugging with production flag enabled
CORS_FORCE_ANY_ORIGIN=
#allow multiple users to register with same mobile/email - for testing
ALLOW_DUPLICATE_USER_DATA=true
SKIP_EMAIL_VERIFICATION=true
Expand Down
2 changes: 1 addition & 1 deletion src/server/server-middlewares.js
Expand Up @@ -40,7 +40,7 @@ const stakingModelTasks = [
export default async (app: Router) => {
const corsConfig = {
credentials: true,
origin: env === 'production' && !Config.corsForceAnyOrigin ? /\.gooddollar\.org$/ : true
origin: env === 'production' ? /\.gooddollar\.org$/ : true
}

// parse application/x-www-form-urlencoded
Expand Down
12 changes: 6 additions & 6 deletions src/server/server.config.js
Expand Up @@ -290,6 +290,12 @@ const conf = convict({
env: 'ZOOM_LICENSE_KEY',
default: ''
},
zoomProductionMode: {
doc: 'Enables fetching production key and initializes Zoom in production mode',
format: Boolean,
env: 'ZOOM_PRODUCTION_MODE',
default: false
},
gunPrivateS3: {
key: {
format: '*',
Expand Down Expand Up @@ -318,12 +324,6 @@ const conf = convict({
default: undefined
}
},
corsForceAnyOrigin: {
doc: 'Force allow any origin in the CORS middleware',
format: Boolean,
env: 'CORS_FORCE_ANY_ORIGIN',
default: false
},
allowDuplicateUserData: {
doc: 'Allow to register with existing mobile/email',
format: Boolean,
Expand Down
12 changes: 6 additions & 6 deletions src/server/verification/__tests__/verificationAPI.js
Expand Up @@ -22,7 +22,7 @@ import { noopAsync } from '../../utils/async'

describe('verificationAPI', () => {
let server
const { skipEmailVerification, claimQueueAllowed, env } = Config
const { skipEmailVerification, claimQueueAllowed, zoomProductionMode } = Config
const userIdentifier = '0x7ac080f6607405705aed79675789701a48c76f55'

beforeAll(async done => {
Expand All @@ -38,12 +38,12 @@ describe('verificationAPI', () => {

beforeEach(() => {
// disable claim queue
Object.assign(Config, { env, claimQueueAllowed: 0 })
Object.assign(Config, { zoomProductionMode, claimQueueAllowed: 0 })
})

afterAll(async done => {
// restore original config
Object.assign(Config, { skipEmailVerification, claimQueueAllowed, env })
Object.assign(Config, { skipEmailVerification, claimQueueAllowed, zoomProductionMode })
await storage.model.deleteMany({ fullName: new RegExp('test_user_sendemail', 'i') })

server.close(err => {
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('verificationAPI', () => {
})

test('POST /verify/face/license/:licenseType returns 200, success: true and license', async () => {
Config.env = 'production'
Config.zoomProductionMode = true
helper.mockSuccessLicenseKey(licenseType, licenseKey)

await request(server)
Expand All @@ -221,7 +221,7 @@ describe('verificationAPI', () => {
test('POST /verify/face/license/:licenseType returns 400, success: false if Zoom API fails', async () => {
const message = 'No license found in the database for this platformID.'

Config.env = 'production'
Config.zoomProductionMode = true
helper.mockFailedLicenseKey(licenseType, message)

await request(server)
Expand All @@ -235,7 +235,7 @@ describe('verificationAPI', () => {
})

test("POST /verify/face/license/:licenseType returns 400, success: false when license type isn't valid", async () => {
Config.env = 'production'
Config.zoomProductionMode = true

await request(server)
.post(licenseUri('unknown'))
Expand Down
2 changes: 1 addition & 1 deletion src/server/verification/verificationAPI.js
Expand Up @@ -97,7 +97,7 @@ const setup = (app: Router, verifier: VerificationAPI, gunPublic: StorageAPI, st
const { licenseType } = params

try {
if (conf.env !== 'production') {
if (!conf.zoomProductionMode) {
throw new Error('Cannot obtain production license running non-production mode.')
}

Expand Down

0 comments on commit b8bc697

Please sign in to comment.