Skip to content

Commit 60bd8e2

Browse files
fix: isolate the authzValidation tests
Mocha doesn't isolate tests in their own process, which means when the tests are running they're actually all sharing a singleton instance of the Express app. This is a problem for the authz testing specifically, because it modifies a piece of global state (`useNewAuthzApi`) to select at runtime whether to use the old or new versions of the authorization API. The change in this commit manually isolates the authz tests by putting them under a separate invocation of Mocha. Signed-off-by: Andrew Lilley Brinker <abrinker@mitre.org>
1 parent ac0ce0b commit 60bd8e2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@
105105
"start:prd": "node src/swagger.js && NODE_ENV=production node src/scripts/updateOpenapiHost.js && NODE_ENV=production node src/index.js",
106106
"swagger-autogen": "node src/swagger.js",
107107
"test": "NODE_ENV=test mocha --recursive --exit || true",
108-
"test:integration": "NODE_ENV=test node-dev src/scripts/populate.mjs y; NODE_ENV=test MONGO_CONN_STRING=mongodb://docdb:27017 MONGO_DB_NAME=cve_test node-dev src/scripts/migrate.js; NODE_ENV=test mocha test/integration-tests --recursive --exit",
109-
"test:integration-local": "NODE_ENV=test node-dev src/scripts/populate.mjs y; NODE_ENV=test MONGO_CONN_STRING=mongodb://localhost:27017 MONGO_DB_NAME=cve_test node-dev src/scripts/migrate.js; NODE_ENV=test mocha test/integration-tests --recursive --exit",
108+
"test:integration": "NODE_ENV=test node-dev src/scripts/populate.mjs y; NODE_ENV=test MONGO_CONN_STRING=mongodb://docdb:27017 MONGO_DB_NAME=cve_test node-dev src/scripts/migrate.js; NODE_ENV=test mocha test/integration-tests --exclude test/integration-tests/cve/authzValidation.js --recursive --exit && NODE_ENV=test mocha test/integration-tests/cve/authzValidation.js --recursive --exit",
109+
"test:integration-local": "NODE_ENV=test node-dev src/scripts/populate.mjs y; NODE_ENV=test MONGO_CONN_STRING=mongodb://localhost:27017 MONGO_DB_NAME=cve_test node-dev src/scripts/migrate.js; NODE_ENV=test mocha test/integration-tests --exclude test/integration-tests/cve/authzValidation.js --recursive --exit && NODE_ENV=test mocha test/integration-tests/cve/authzValidation.js --recursive --exit",
110110
"test:unit-tests": "NODE_ENV=test mocha test/unit-tests --recursive --exit || true",
111111
"test:coverage": "NODE_ENV=test nyc --reporter=text mocha src/* --recursive --exit || true",
112112
"test:coverage-html": "NODE_ENV=test nyc --reporter=html mocha src/* --recursive --exit || true",

test/integration-tests/cve/cursorPaginationTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('Testing Get cve_cursor endpoint', () => {
2222
await api.createCveAsSecretariat(cveId)
2323
}
2424
})
25-
const TOTAL_COUNT = 121
25+
const TOTAL_COUNT = 119
2626

2727
context('Positive Tests', () => {
2828
it('Get cve_cursor should return all records when no parameters are specifed', async () => {

0 commit comments

Comments
 (0)