Repository: CVEProject/cve-services (js)

Issue:
Suggest where to confirm published records
Per a suggestion from @kernelsmith, update the success message for POST /cve/:id/cna to include where to view a submission and how soon it will be there.

For instance, make the message something like, ""this submission should appear on https://cve.org/ within 15 minutes"

If running on the Test instance, the message should point to https://test.cve.org/



Pull request:
Resolves #955 CVE record creation message shows when and where to view it
Closes Issue #955

## Summary
The response message for POST and PUT `/cve/:id/cna` now returns more information, detailing where to view the submitted CNA record. Specifically, 'This submission should appear on https://cve.mitre.org/ within 15 minutes.' Or https://test.cve.org/ on the TEST environment.

## Important Changes
`cve.controller.js`
- Updated response message for submitCna and updateCna

## Testing
Steps to manually test updated functionality, if possible

- [ ] 1) Ensure the correct response message is return for these endpoints, including the correct URLs.


Patch:
diff --git a/src/controller/cve.controller/cve.controller.js b/src/controller/cve.controller/cve.controller.js
index 1b06c283..15183683 100644
--- a/src/controller/cve.controller/cve.controller.js
+++ b/src/controller/cve.controller/cve.controller.js
@@ -4,6 +4,7 @@ const errors = require('./error')
 const getConstants = require('../../constants').getConstants
 const error = new errors.CveControllerError()
 const booleanIsTrue = require('../../utils/utils').booleanIsTrue
+const url = process.env.NODE_ENV === 'staging' ? 'https://test.cve.org/' : 'https://cve.org/'
 
 // Helper function to create providerMetadata object
 function createProviderMetadata (orgId, shortName, updateDate) {
@@ -334,7 +335,7 @@ async function submitCna (req, res, next) {
     }
 
     const responseMessage = {
-      message: id + ' record was successfully created.',
+      message: id + ' record was successfully created. This submission should appear on ' + url + ' within 15 minutes.',
       created: cveModel.cve
     }
 
@@ -423,7 +424,7 @@ async function updateCna (req, res, next) {
     }
 
     const responseMessage = {
-      message: id + ' record was successfully updated.',
+      message: id + ' record was successfully updated. This submission should appear on ' + url + ' within 15 minutes.',
       updated: cveModel.cve
     }
 


Test patch:
diff --git a/test/unit-tests/cve/cveCnaContainerCreateTest.js b/test/unit-tests/cve/cveCnaContainerCreateTest.js
index 39e0b48f..ebc484eb 100644
--- a/test/unit-tests/cve/cveCnaContainerCreateTest.js
+++ b/test/unit-tests/cve/cveCnaContainerCreateTest.js
@@ -13,6 +13,7 @@ app.use(middleware.createCtxAndReqUUID)
 const nonExistentCveId = 'CVE-2020-1425'
 const cveIdPublished5 = 'CVE-2017-4024'
 const cveIdReserved = 'CVE-2017-5835'
+const url = process.env.NODE_ENV === 'staging' ? 'https://test.cve.org/' : 'https://cve.org/' // Used in submitCna response messages
 const cveCnaContainerFail = require('../../schemas/cna-container/cna-container_fail.json')
 const cveCnaContainerPass = require('../../schemas/cna-container/cna-container_pass.json')
 const errors = require('../../../src/controller/cve.controller/error')
@@ -229,7 +230,7 @@ describe('Testing the POST /cve/:id/cna endpoint in Cve Controller', () => {
 
           expect(res).to.have.status(200)
           expect(res).to.have.property('body').and.to.be.a('object')
-          expect(res.body.message).to.equal(`${cveIdReserved} record was successfully created.`)
+          expect(res.body.message).to.equal(`${cveIdReserved} record was successfully created. This submission should appear on ${url} within 15 minutes.`)
           done()
         })
     })
@@ -249,7 +250,7 @@ describe('Testing the POST /cve/:id/cna endpoint in Cve Controller', () => {
 
           expect(res).to.have.status(200)
           expect(res).to.have.property('body').and.to.be.a('object')
-          expect(res.body.message).to.equal(`${cveIdReserved} record was successfully created.`)
+          expect(res.body.message).to.equal(`${cveIdReserved} record was successfully created. This submission should appear on ${url} within 15 minutes.`)
           done()
         })
     })
diff --git a/test/unit-tests/cve/cveCnaContainerUpdateTest.js b/test/unit-tests/cve/cveCnaContainerUpdateTest.js
index 93497104..cad7c512 100644
--- a/test/unit-tests/cve/cveCnaContainerUpdateTest.js
+++ b/test/unit-tests/cve/cveCnaContainerUpdateTest.js
@@ -13,6 +13,7 @@ app.use(middleware.createCtxAndReqUUID)
 const nonExistentCveId = 'CVE-2020-1425'
 const cveIdPublished5 = 'CVE-2017-4024'
 const cveIdReserved = 'CVE-2017-5835'
+const url = process.env.NODE_ENV === 'staging' ? 'https://test.cve.org/' : 'https://cve.org/' // Used in updateCna response messages
 const cveCnaContainerFail = require('../../schemas/cna-container/cna-container_fail.json')
 const cveCnaContainerPass = require('../../schemas/cna-container/cna-container_pass.json')
 const cveRecordPublished = require('../../schemas/5.0/CVE-2017-4024_published.json')
@@ -260,7 +261,7 @@ describe('Testing the PUT /cve/:id/cna endpoint in Cve Controller', () => {
 
           expect(res).to.have.status(200)
           expect(res).to.have.property('body').and.to.be.a('object')
-          expect(res.body.message).to.equal(`${cveIdPublished5} record was successfully updated.`)
+          expect(res.body.message).to.equal(`${cveIdPublished5} record was successfully updated. This submission should appear on ${url} within 15 minutes.`)
           done()
         })
     })
@@ -280,7 +281,7 @@ describe('Testing the PUT /cve/:id/cna endpoint in Cve Controller', () => {
 
           expect(res).to.have.status(200)
           expect(res).to.have.property('body').and.to.be.a('object')
-          expect(res.body.message).to.equal(`${cveIdPublished5} record was successfully updated.`)
+          expect(res.body.message).to.include(`${cveIdPublished5} record was successfully updated. This submission should appear on ${url} within 15 minutes.`)
           expect(res.body.created).to.not.equal(cveRecordPublished)
           done()
         })