Skip to content

Commit

Permalink
#1063 added unit test to check adpContainer is removed when record is…
Browse files Browse the repository at this point in the history
… rejected
  • Loading branch information
jdaigneau5 committed May 26, 2023
1 parent bdfb3f2 commit 2b28096
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
20 changes: 20 additions & 0 deletions test/schemas/5.0/rejectCveExample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"cnaContainer": {
"rejectedReasons": [
{
"lang": "qe",
"value": "I professional site herself recently behavior. Situation institution meeting recognize successful.",
"supportingMedia": [
{
"type": "test/markdown",
"base64": false,
"value": "*this* _is_ supporting media in ~markdown~"
}
]
}
],
"replacedBy": [
"CVE-1999-0006"
]
}
}
5 changes: 1 addition & 4 deletions test/unit-tests/cve/insertAdpTest.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-disable no-unused-expressions */
// https://github.com/standard/standard/issues/690#issuecomment-278533482
const chai = require('chai')
const sinon = require('sinon')
const { faker } = require('@faker-js/faker')
const _ = require('lodash'
)
const _ = require('lodash')
const expect = chai.expect
const cveIdPublished5 = 'CVE-2017-4024'
const cveRecordPublished = require('../../schemas/5.0/CVE-2017-4024_published.json')
Expand Down
18 changes: 18 additions & 0 deletions test/unit-tests/cve/rejectCveAdpTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const chai = require('chai')
const expect = chai.expect
const _ = require('lodash')
const cveRecordPublished = require('../../schemas/5.0/CVE-2017-4024_published.json')
const cveRejectExample = require('../../schemas/5.0/rejectCveExample.json')

const Cve = require('../../../src/model/cve')
const cveCopy = _.cloneDeep(cveRecordPublished)

describe('Testing rejecting CVE record that has an ADP container', () => {
it('Should return rejected Cve record without ADP container', async () => {
const newRecord = await Cve.updateCveToRejected('', cveRecordPublished.containers.cna.providerMetadata, cveCopy, cveRejectExample)

expect(newRecord.containers).to.not.have.property('adp')
expect(cveRecordPublished.containers).to.have.property('adp')
expect(newRecord.cveMetadata.state).to.equal('REJECTED')
})
})

0 comments on commit 2b28096

Please sign in to comment.