-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1087 from CVEProject/dr-1076
Resolves #1076 - ADP short name parameter
- Loading branch information
Showing
7 changed files
with
192 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* 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 _ = require('lodash') | ||
|
||
const shortName = 'win_5' | ||
|
||
describe('Test cna_modified parameter for get CVE', () => { | ||
let cveId | ||
before(async () => { | ||
cveId = await helpers.cveIdReserveHelper(1, '2023', shortName, 'non-sequential') | ||
await helpers.cveRequestAsCnaHelper(cveId) | ||
await helpers.cveUpdateAsCnaHelperWithAdpContainer(cveId, constants.testAdp) | ||
}) | ||
context('Positive Test', () => { | ||
it('CVE should not be returned with adp_short_name set to fake_org as it does not exist', async () => { | ||
await chai.request(app) | ||
.get('/api/cve/?adp_short_name=fake_org') | ||
.set(constants.headers) | ||
.then((res, err) => { | ||
expect(err).to.be.undefined | ||
expect(res).to.have.status(200) | ||
expect(_.some(res.body.cveRecords, { cveMetadata: { cveId: cveId } })).to.be.false | ||
}) | ||
}) | ||
it(`CVE should be returned with adp_short_name set to ${shortName} as it has been created`, async () => { | ||
await chai.request(app) | ||
.get(`/api/cve/?adp_short_name=${shortName}`) | ||
.set(constants.headers) | ||
.then((res, err) => { | ||
expect(err).to.be.undefined | ||
expect(res).to.have.status(200) | ||
expect(_.some(res.body.cveRecords, { cveMetadata: { cveId: cveId } })).to.be.true | ||
}) | ||
}) | ||
it(`Get CVE with adp_short_name set to ${shortName} AND date.gt should return when searched with a known earlier than date`, async () => { | ||
await chai.request(app) | ||
.get(`/api/cve/?time_modified.gt=2022-01-01T00:00:00&adp_short_name=${shortName}`) | ||
.set(constants.headers) | ||
.then((res, err) => { | ||
expect(err).to.be.undefined | ||
expect(res).to.have.status(200) | ||
expect(_.some(res.body.cveRecords, { cveMetadata: { cveId: cveId } })).to.be.true | ||
}) | ||
}) | ||
it(`Get CVE with with adp_short_name set to ${shortName} AND date.gt should return and empty list when searched with a known bad earlier than date`, async () => { | ||
await chai.request(app) | ||
.get(`/api/cve/?time_modified.gt=2100-01-01T00:00:00&adp_short_name=${shortName}`) | ||
.set(constants.headers) | ||
.then((res, err) => { | ||
expect(err).to.be.undefined | ||
expect(res).to.have.status(200) | ||
expect(_.some(res.body.cveRecords, { cveMetadata: { cveId: cveId } })).to.be.false | ||
}) | ||
}) | ||
|
||
it(`Get CVE with adp_short_name set to ${shortName} AND date.lt should return when searched with a known later than date`, async () => { | ||
await chai.request(app) | ||
.get(`/api/cve/?time_modified.lt=2100-01-01T00:00:00&adp_short_name=${shortName}`) | ||
.set(constants.headers) | ||
.then((res, err) => { | ||
expect(err).to.be.undefined | ||
expect(res).to.have.status(200) | ||
expect(_.some(res.body.cveRecords, { cveMetadata: { cveId: cveId } })).to.be.true | ||
}) | ||
}) | ||
it(`Get CVE with adp_short_name set to ${shortName} AND date.lt should return and empty list when searched with a known bad later than date`, async () => { | ||
await chai.request(app) | ||
.get(`/api/cve/?time_modified.lt=2022-01-01T00:00:00&adp_short_name=${shortName}`) | ||
.set(constants.headers) | ||
.then((res, err) => { | ||
expect(err).to.be.undefined | ||
expect(res).to.have.status(200) | ||
expect(_.some(res.body.cveRecords, { cveMetadata: { cveId: cveId } })).to.be.false | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters