mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-30 16:01:14 -04:00
feat(api): env var to control exam environment (#56701)
This commit is contained in:
committed by
GitHub
parent
74a71d3ff1
commit
f2ec6d6dd5
@@ -38,7 +38,7 @@ import {
|
||||
FCC_ENABLE_DEV_LOGIN_MODE,
|
||||
FCC_ENABLE_SWAGGER_UI,
|
||||
FCC_ENABLE_SHADOW_CAPTURE,
|
||||
FREECODECAMP_NODE_ENV
|
||||
FCC_ENABLE_EXAM_ENVIRONMENT
|
||||
} from './utils/env';
|
||||
import { isObjectID } from './utils/validation';
|
||||
import {
|
||||
@@ -187,8 +187,7 @@ export const build = async (
|
||||
}
|
||||
});
|
||||
|
||||
// NOTE: Code behind the `FREECODECAMP_NODE_ENV` var is not ready to be deployed yet.
|
||||
if (FREECODECAMP_NODE_ENV !== 'production') {
|
||||
if (FCC_ENABLE_EXAM_ENVIRONMENT) {
|
||||
void fastify.register(function (fastify, _opts, done) {
|
||||
fastify.addHook('onRequest', fastify.authorizeExamEnvironmentToken);
|
||||
|
||||
|
||||
@@ -12,6 +12,14 @@ import {
|
||||
import * as mock from '../../../__mocks__/env-exam';
|
||||
import { constructUserExam } from '../utils/exam';
|
||||
|
||||
jest.mock('../../utils/env', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return {
|
||||
...jest.requireActual('../../utils/env'),
|
||||
FCC_ENABLE_EXAM_ENVIRONMENT: 'true'
|
||||
};
|
||||
});
|
||||
|
||||
describe('/exam-environment/', () => {
|
||||
setupServer();
|
||||
describe('Authenticated user with exam environment authorization token', () => {
|
||||
|
||||
@@ -58,6 +58,11 @@ assert.ok(process.env.MONGOHQ_URL);
|
||||
assert.ok(process.env.COOKIE_SECRET);
|
||||
|
||||
if (process.env.FREECODECAMP_NODE_ENV !== 'development') {
|
||||
assert.notEqual(
|
||||
process.env.FCC_ENABLE_EXAM_ENVIRONMENT,
|
||||
'true',
|
||||
'Exam environment is not ready for production.'
|
||||
);
|
||||
assert.ok(process.env.SES_ID);
|
||||
assert.ok(process.env.SES_SECRET);
|
||||
assert.notEqual(
|
||||
@@ -127,6 +132,8 @@ export const FCC_ENABLE_DEV_LOGIN_MODE =
|
||||
process.env.FCC_ENABLE_DEV_LOGIN_MODE === 'true';
|
||||
export const FCC_ENABLE_SHADOW_CAPTURE =
|
||||
process.env.FCC_ENABLE_SHADOW_CAPTURE === 'true';
|
||||
export const FCC_ENABLE_EXAM_ENVIRONMENT =
|
||||
process.env.FCC_ENABLE_EXAM_ENVIRONMENT === 'true';
|
||||
export const SENTRY_DSN =
|
||||
process.env.SENTRY_DSN === 'dsn_from_sentry_dashboard'
|
||||
? ''
|
||||
|
||||
@@ -69,6 +69,7 @@ PORT=3000
|
||||
FCC_ENABLE_SWAGGER_UI=true
|
||||
FCC_ENABLE_DEV_LOGIN_MODE=true
|
||||
FCC_ENABLE_SHADOW_CAPTURE=false
|
||||
FCC_ENABLE_EXAM_ENVIRONMENT=false
|
||||
|
||||
# Email
|
||||
# use ses in production
|
||||
|
||||
Reference in New Issue
Block a user