@@ -109,6 +109,36 @@ describe('Testing /registryOrg endpoints', () => {
109109 expect ( res . body . created . vulnerability_advisory_location_for_web_scraping ) . to . deep . equal ( [ 'https://example.com/scraping' ] )
110110 } )
111111 } )
112+ it ( 'Creates a new registry org with a date-only CVE website update date' , async ( ) => {
113+ const cveWebsiteUpdateDate = '2024-01-15'
114+ const orgWithWebsiteUpdateDate = {
115+ ...testRegistryOrg ,
116+ short_name : 'registry_org_test_web_date' ,
117+ program_data : {
118+ status : 'active' ,
119+ cve_website_update_date : cveWebsiteUpdateDate
120+ }
121+ }
122+
123+ await chai . request ( app )
124+ . post ( '/api/registry/org' )
125+ . set ( secretariatHeaders )
126+ . send ( orgWithWebsiteUpdateDate )
127+ . then ( ( res , err ) => {
128+ expect ( err ) . to . be . undefined
129+ expect ( res ) . to . have . status ( 200 )
130+ expect ( res . body . created ) . to . haveOwnProperty ( 'program_data' )
131+ expect ( res . body . created . program_data . cve_website_update_date ) . to . equal ( cveWebsiteUpdateDate )
132+ } )
133+
134+ await chai . request ( app )
135+ . get ( '/api/registry/org/registry_org_test_web_date' )
136+ . set ( secretariatHeaders )
137+ . then ( ( res ) => {
138+ expect ( res ) . to . have . status ( 200 )
139+ expect ( res . body . program_data . cve_website_update_date ) . to . equal ( cveWebsiteUpdateDate )
140+ } )
141+ } )
112142 } )
113143 context ( 'Negative Tests' , ( ) => {
114144 it ( 'Fails to create a new registry organization with an existing short name' , async ( ) => {
@@ -149,6 +179,27 @@ describe('Testing /registryOrg endpoints', () => {
149179 expect ( res . body . message ) . to . equal ( 'Parameters were invalid' )
150180 } )
151181 } )
182+ it ( 'Fails to create a new registry organization with an ambiguous CVE website update date' , async ( ) => {
183+ await chai . request ( app )
184+ . post ( '/api/registry/org' )
185+ . set ( secretariatHeaders )
186+ . send ( {
187+ ...testRegistryOrg ,
188+ short_name : 'test_create_ambiguous_date' ,
189+ program_data : {
190+ status : 'active' ,
191+ cve_website_update_date : '01/15/2024'
192+ }
193+ } )
194+ . then ( ( res ) => {
195+ expect ( res ) . to . have . status ( 400 )
196+ expect ( res . body . message ) . to . equal ( 'Parameters were invalid' )
197+
198+ const dateError = res . body . errors . find ( error => error . instancePath === '/program_data/cve_website_update_date' )
199+ expect ( dateError ) . to . not . be . undefined
200+ expect ( dateError . message ) . to . equal ( 'must match format "date"' )
201+ } )
202+ } )
152203 it ( 'Fails to create a new registry organization with reports_to manually provided' , async ( ) => {
153204 await chai . request ( app )
154205 . post ( '/api/registry/org' )
@@ -363,6 +414,7 @@ describe('Testing /registryOrg endpoints', () => {
363414 } )
364415 it ( 'Allows Secretariat to update program_data' , async ( ) => {
365416 const partnerActiveDate = '2024-01-15'
417+ const cveWebsiteUpdateDate = '2024-04-10T18:30:00.000Z'
366418 await chai . request ( app )
367419 . put ( '/api/registry/org/registry_org_test' )
368420 . set ( secretariatHeaders )
@@ -372,7 +424,8 @@ describe('Testing /registryOrg endpoints', () => {
372424 vulnerability_advisory_location_for_web_scraping : [ 'https://example.com/scraping' ] ,
373425 program_data : {
374426 status : 'active' ,
375- partner_active_date : partnerActiveDate
427+ partner_active_date : partnerActiveDate ,
428+ cve_website_update_date : cveWebsiteUpdateDate
376429 }
377430 } )
378431 . then ( ( res , err ) => {
@@ -382,6 +435,7 @@ describe('Testing /registryOrg endpoints', () => {
382435 expect ( res . body . updated . program_data . status ) . to . equal ( 'active' )
383436 expect ( res . body . updated . program_data ) . to . haveOwnProperty ( 'partner_active_date' )
384437 expect ( res . body . updated . program_data . partner_active_date ) . to . equal ( partnerActiveDate )
438+ expect ( res . body . updated . program_data . cve_website_update_date ) . to . equal ( '2024-04-10' )
385439 expect ( res . body . updated . program_data ) . to . not . haveOwnProperty ( 'advisory_location_require_credentials' )
386440 expect ( res . body . updated . program_data ) . to . not . haveOwnProperty ( 'vulnerability_advisory_location_for_web_scraping' )
387441 expect ( res . body . updated . advisory_location_require_credentials ) . to . be . true
0 commit comments