@@ -7,12 +7,12 @@ const _ = require('lodash')
77const expect = chai . expect
88
99const constants = require ( '../constants.js' )
10- const helpers = require ( '../helpers .js' )
10+ const api = require ( '../api .js' )
1111const app = require ( '../../../src/index.js' )
1212
1313describe ( 'Testing Get CVE-ID endpoint' , ( ) => {
1414 // TODO: Update this test to dynamically calculate reserved count.
15- const RESESRVED_COUNT = 124
15+ const RESESRVED_COUNT = 125
1616 const YEAR_COUNT = 10
1717 const PUB_YEAR_COUNT = 4
1818 const TIME_WINDOW_COUNT = 40
@@ -111,10 +111,12 @@ describe('Testing Get CVE-ID endpoint', () => {
111111 } )
112112 } )
113113 it ( 'For non Secretariat users, should redact requested_by.user values not in requested_by.cna org' , async ( ) => {
114- const cveId = await helpers . cveIdReserveHelper ( 1 , '2023' , constants . cnaHeaders [ 'CVE-API-ORG' ] , 'non-sequential' )
114+ const reserveRes = await api . reserveCveIdAsCna ( '2023' , constants . cnaHeaders [ 'CVE-API-ORG' ] )
115+ expect ( reserveRes ) . to . have . status ( 200 )
116+ const cveId = reserveRes . body . cve_ids [ 0 ] . cve_id
115117
116118 // change users org for testing
117- await helpers . userOrgUpdateAsSecHelper ( constants . cnaHeaders [ 'CVE-API-USER' ] , constants . cnaHeaders [ 'CVE-API-ORG' ] , 'mitre' )
119+ await api . updateUserOrgAsSecretariat ( constants . cnaHeaders [ 'CVE-API-USER' ] , constants . cnaHeaders [ 'CVE-API-ORG' ] , 'mitre' )
118120
119121 await chai . request ( app )
120122 . get ( '/api/cve-id?state=RESERVED' )
@@ -128,14 +130,16 @@ describe('Testing Get CVE-ID endpoint', () => {
128130 expect ( cveIdObject . requested_by . user ) . to . equal ( 'REDACTED' )
129131
130132 // Reset user to original org
131- await helpers . userOrgUpdateAsSecHelper ( constants . cnaHeaders [ 'CVE-API-USER' ] , 'mitre' , 'win_5' )
133+ await api . updateUserOrgAsSecretariat ( constants . cnaHeaders [ 'CVE-API-USER' ] , 'mitre' , 'win_5' )
132134 } )
133135 } )
134136 it ( 'For non Secretariat users, should redact requested_by.user values when requested_by.cna is not owning_cna' , async ( ) => {
135- const cveId = await helpers . cveIdReserveHelper ( 1 , '2023' , constants . cnaHeaders [ 'CVE-API-ORG' ] , 'non-sequential' )
137+ const reserveRes = await api . reserveCveIdAsCna ( '2023' , constants . cnaHeaders [ 'CVE-API-ORG' ] )
138+ expect ( reserveRes ) . to . have . status ( 200 )
139+ const cveId = reserveRes . body . cve_ids [ 0 ] . cve_id
136140
137141 // change cve-id's owning_org for testing
138- await helpers . updateOwningOrgAsSecHelper ( cveId , constants . cnaHeaders3 [ 'CVE-API-ORG' ] )
142+ await api . updateCveIdOwningOrgAsSecretariat ( cveId , constants . cnaHeaders3 [ 'CVE-API-ORG' ] )
139143
140144 await chai . request ( app )
141145 . get ( '/api/cve-id?state=RESERVED' )
@@ -150,10 +154,12 @@ describe('Testing Get CVE-ID endpoint', () => {
150154 } )
151155 } )
152156 it ( 'For Secretariat users, should redact requested_by.user values not in requested_by.cna org' , async ( ) => {
153- const cveId = await helpers . cveIdReserveHelper ( 1 , '2023' , constants . cnaHeaders [ 'CVE-API-ORG' ] , 'non-sequential' )
157+ const reserveRes = await api . reserveCveIdAsCna ( '2023' , constants . cnaHeaders [ 'CVE-API-ORG' ] )
158+ expect ( reserveRes ) . to . have . status ( 200 )
159+ const cveId = reserveRes . body . cve_ids [ 0 ] . cve_id
154160
155161 // change users org for testing
156- await helpers . userOrgUpdateAsSecHelper ( constants . cnaHeaders [ 'CVE-API-USER' ] , constants . cnaHeaders [ 'CVE-API-ORG' ] , 'mitre' )
162+ await api . updateUserOrgAsSecretariat ( constants . cnaHeaders [ 'CVE-API-USER' ] , constants . cnaHeaders [ 'CVE-API-ORG' ] , 'mitre' )
157163
158164 await chai . request ( app )
159165 . get ( '/api/cve-id?state=RESERVED' )
@@ -167,14 +173,16 @@ describe('Testing Get CVE-ID endpoint', () => {
167173 expect ( cveIdObject . requested_by . user ) . to . equal ( constants . cnaHeaders [ 'CVE-API-USER' ] )
168174
169175 // Reset user to original org
170- await helpers . userOrgUpdateAsSecHelper ( constants . cnaHeaders [ 'CVE-API-USER' ] , 'mitre' , 'win_5' )
176+ await api . updateUserOrgAsSecretariat ( constants . cnaHeaders [ 'CVE-API-USER' ] , 'mitre' , 'win_5' )
171177 } )
172178 } )
173179 it ( 'For Secretariat users, should redact requested_by.user values when requested_by.cna is not owning_cna' , async ( ) => {
174- const cveId = await helpers . cveIdReserveHelper ( 1 , '2023' , constants . cnaHeaders [ 'CVE-API-ORG' ] , 'non-sequential' )
180+ const reserveRes = await api . reserveCveIdAsCna ( '2023' , constants . cnaHeaders [ 'CVE-API-ORG' ] )
181+ expect ( reserveRes ) . to . have . status ( 200 )
182+ const cveId = reserveRes . body . cve_ids [ 0 ] . cve_id
175183
176184 // change cve-id's owning_org for testing
177- await helpers . updateOwningOrgAsSecHelper ( cveId , constants . cnaHeaders3 [ 'CVE-API-ORG' ] )
185+ await api . updateCveIdOwningOrgAsSecretariat ( cveId , constants . cnaHeaders3 [ 'CVE-API-ORG' ] )
178186
179187 await chai . request ( app )
180188 . get ( '/api/cve-id?state=RESERVED' )
0 commit comments