diff --git a/test/integration-tests/cve-id/cveIdUpdateTest.js b/test/integration-tests/cve-id/cveIdUpdateTest.js new file mode 100644 index 00000000..c274fe17 --- /dev/null +++ b/test/integration-tests/cve-id/cveIdUpdateTest.js @@ -0,0 +1,47 @@ +/* eslint-disable no-unused-expressions */ + +const chai = require('chai') +chai.use(require('chai-http')) +const expect = chai.expect + +const constants = require('../constants.js') +const app = require('../../../src/index.js') +const helpers = require('../helpers.js') + +const shortName = 'win_5' + +describe('Text PUT CVE-ID/:id', () => { + let cveId + before(async () => { + cveId = await helpers.cveIdReserveHelper(1, '2023', shortName, 'non-sequential') + }) + context('State parameter Tests', () => { + it('Endpoint should return a 400 when state org is set to published', async () => { + await chai.request(app) + .put(`/api/cve-id/${cveId}?state=PUBLISHED`) + .set(constants.headers) + .then((res, err) => { + expect(err).to.be.undefined + expect(res).to.have.status(400) + }) + }) + it('Endpoint should allow the state parameter to be set to reserved', async () => { + await chai.request(app) + .put(`/api/cve-id/${cveId}?state=REJECTED`) + .set(constants.headers) + .then((res, err) => { + expect(err).to.be.undefined + expect(res).to.have.status(200) + }) + }) + it('Endpoint should still not allow a REJECTED endpoint to be set to published', async () => { + await chai.request(app) + .put(`/api/cve-id/${cveId}?state=PUBLISHED`) + .set(constants.headers) + .then((res, err) => { + expect(err).to.be.undefined + expect(res).to.have.status(400) + }) + }) + }) +})