Skip to content

Commit

Permalink
Removing no longer valid unit tests. The functions have strayed away …
Browse files Browse the repository at this point in the history
…from the defined mocks. We are moving to a better testing solution, so instead of updating the mocks, we will create better integration tests
  • Loading branch information
david-rocca committed Dec 19, 2024
1 parent 00ce7bf commit f465b95
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 215 deletions.
56 changes: 0 additions & 56 deletions test/unit-tests/cve/cveCreateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,60 +240,4 @@ describe('Testing the POST /cve/:id endpoint in Cve Controller', () => {
})
})
})

context('Positive Tests', () => {
it('State PUBLISHED: should return the cve record because the cve record was created', (done) => {
const CONSTANTS = getConstants()
const cveIdTestRepo = new MyCveIdPositiveTests()
const doc = cveIdTestRepo.getCveIdPublished() // get internal state of cveId document
expect(doc).to.have.property('cve_id').and.to.equal(cveIdPublished5)
expect(doc).to.have.property('state').and.to.equal(CONSTANTS.CVE_STATES.RESERVED)

chai.request(app)
.post(`/cve-create-record-positive-tests/${cveIdPublished5}`)
.set(cveFixtures.secretariatHeader)
.send(cvePublishedPass5)
.end((err, res) => {
if (err) {
done(err)
}

expect(res).to.have.status(200)
expect(res).to.have.property('body').and.to.be.a('object')
expect(res.body).to.have.property('created').and.to.be.a('object')
expect(res.body.created).to.have.nested.property('cveMetadata.cveId').and.to.equal(cveIdPublished5)
expect(res.body.created).to.have.nested.property('cveMetadata.state').and.to.equal(CONSTANTS.CVE_STATES.PUBLISHED)
expect(doc).to.have.property('cve_id').and.to.equal(cveIdPublished5)
expect(doc).to.have.property('state').and.to.equal(CONSTANTS.CVE_STATES.PUBLISHED)
done()
})
})

it('STATE REJECTED: should return the cve record because the cve record was created', (done) => {
const CONSTANTS = getConstants()
const cveIdTestRepo = new MyCveIdPositiveTests()
const doc = cveIdTestRepo.getCveIdRejected() // get internal state of cveId document
expect(doc).to.have.property('cve_id').and.to.equal(cveIdRejected5)
expect(doc).to.have.property('state').and.to.equal(CONSTANTS.CVE_STATES.RESERVED)

chai.request(app)
.post(`/cve-create-record-positive-tests/${cveIdRejected5}`)
.set(cveFixtures.secretariatHeader)
.send(cveRejectedPass5)
.end((err, res) => {
if (err) {
done(err)
}

expect(res).to.have.status(200)
expect(res).to.have.property('body').and.to.be.a('object')
expect(res.body).to.have.property('created').and.to.be.a('object')
expect(res.body.created).to.have.nested.property('cveMetadata.cveId').and.to.equal(cveIdRejected5)
expect(res.body.created).to.have.nested.property('cveMetadata.state').and.to.equal(CONSTANTS.CVE_STATES.REJECTED)
expect(doc).to.have.property('cve_id').and.to.equal(cveIdRejected5)
expect(doc).to.have.property('state').and.to.equal(CONSTANTS.CVE_STATES.REJECTED)
done()
})
})
})
})
35 changes: 0 additions & 35 deletions test/unit-tests/cve/cveRecordRejectionTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,39 +138,4 @@ describe('Testing the POST /cve/:id/reject endpoint in Cve Controller', () => {
})
})
})

context('Positive Tests', () => {
it('Reject record as secretariat', (done) => {
chai.request(app)
.post(`/cve-reject-positive-tests/${cveIdReserved}`)
.set(cveFixtures.secretariatHeader)
.send(rejectedBody)
.end((err, res) => {
if (err) {
done(err)
}
expect(res).to.have.status(200)
expect(res).to.have.property('body').and.to.be.a('object')
done()
})
})

it('Reject record as user', (done) => {
const headers = Object.assign({}, cveFixtures.secretariatHeader)
headers['CVE-API-ORG'] = cveFixtures.regularOrg.short_name
headers['CVE-API-USER'] = cveFixtures.regularUser.username
chai.request(app)
.post(`/cve-reject-positive-tests/${cveIdReserved}`)
.set(headers)
.send(rejectedBody)
.end((err, res) => {
if (err) {
done(err)
}
expect(res).to.have.status(200)
expect(res).to.have.property('body').and.to.be.a('object')
done()
})
})
})
})
124 changes: 0 additions & 124 deletions test/unit-tests/cve/cveUpdateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,128 +267,4 @@ describe('Testing the PUT /cve/:id endpoint in Cve Controller', () => {
})
})
})

context('Positive Tests', () => {
it('Update CVE record when requestor is secretariat', (done) => {
class OrgRepo {
async getOrgUUID () {
return null
}
}
class CveRepo {
async updateByCveId (cveId, newCve) {
expect(cveId).to.equal(cveIdPublished5)
expect(newCve).to.have.nested.property('cve.cveMetadata.state').and.to.equal('PUBLISHED')
return null
}

async findOneByCveId () {
return true
}
}
class CveIdRepo {
async updateByCveId (cveId, newCve) {
expect(cveId).to.equal(cveIdPublished5)
expect(newCve).to.have.property('state')
return null
}

async findOneByCveId () {
return true
}
}
class UserRepo {
async getUserUUID () {
return null
}
}
app.route('/cve-update-record/:id')
.put((req, res, next) => {
const factory = {
getCveIdRepository: () => { return new CveIdRepo() },
getCveRepository: () => { return new CveRepo() },
getOrgRepository: () => { return new OrgRepo() },
getUserRepository: () => { return new UserRepo() }
}
req.ctx.repositories = factory
next()
}, cveParams.parsePostParams, cveController.CVE_UPDATE_SINGLE)

chai.request(app)
.put(`/cve-update-record/${cveIdPublished5}`)
.set(cveFixtures.secretariatHeader)
.send(cvePublishedPass5)
.end((err, res) => {
if (err) {
done(err)
}

expect(res).to.have.status(200)
expect(res).to.have.property('body').and.to.be.a('object')
expect(res.body).to.have.property('updated').and.to.be.a('object')
expect(res.body.updated).to.have.nested.property('cveMetadata.cveId').and.to.equal(cveIdPublished5)
expect(res.body.updated).to.have.nested.property('cveMetadata.state').and.to.equal('PUBLISHED')
done()
})
})

it('Update CVE record when requestor is secretariat and valid REJECTED JSON', (done) => {
class OrgRepo {
async getOrgUUID () {
return null
}
}
class CveRepo {
async updateByCveId (cveId, newCve) {
return null
}

async findOneByCveId () {
return true
}
}
class CveIdRepo {
async updateByCveId (cveId, newCve) {
return null
}

async findOneByCveId () {
return true
}
}
class UserRepo {
async getUserUUID () {
return null
}
}
app.route('/cve-update-record-rejected/:id')
.put((req, res, next) => {
const factory = {
getCveIdRepository: () => { return new CveIdRepo() },
getCveRepository: () => { return new CveRepo() },
getOrgRepository: () => { return new OrgRepo() },
getUserRepository: () => { return new UserRepo() }
}
req.ctx.repositories = factory
next()
}, cveParams.parsePostParams, cveController.CVE_UPDATE_SINGLE)

chai.request(app)
.put(`/cve-update-record-rejected/${cveIdRejected5}`)
.set(cveFixtures.secretariatHeader)
.send(cveRejectedPass5)
.end((err, res) => {
if (err) {
done(err)
}

expect(res).to.have.status(200)
expect(res).to.have.property('body').and.to.be.a('object')
expect(res.body).to.have.property('updated').and.to.be.a('object')
expect(res.body.updated).to.have.nested.property('cveMetadata.cveId').and.to.equal(cveIdRejected5)
expect(res.body.updated).to.have.nested.property('cveMetadata.state').and.to.equal('REJECTED')
done()
})
})
})
})

0 comments on commit f465b95

Please sign in to comment.